Skip to content
This repository has been archived by the owner on Jun 17, 2020. It is now read-only.

gac: split deployments/configurator.nix #601

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 5 additions & 40 deletions deployments/configurator.nix
Original file line number Diff line number Diff line change
@@ -1,41 +1,6 @@
{ accessKeyId
, deployerIP
, config
, ...
}:
with (import <nixpkgs> {}).lib;
{
## Per-machine defaults:
defaults = {
# For Nixops configs, the `config` object we constructed in `/config.nix` should be sufficient;
# for NixOS configs however, we need to make a distinction between defaults and and user-supplied parameters.
imports = [ <module/configurator.nix> ];

# The configurator *module* basically just changes the precedence of everything in `optionDefaults` and `userConfig` and merges them
# together. The reason we have to send it off to a NixOS module is because we literally can't do it here in nixops. Trust, I tried. There be dragons and hydrae 🐉🐲.
configurator = {
# So yeah `config` already has both defaults and user-defined parameters but we can't tell which is which
optionDefaults = config;
# So we also pass the bare user config so that we can work the magic of set theory (I think?)
userConfig = import <config>;
};
};

## Universal resource logic:
resources.ec2KeyPairs."cardano-keypair-${config.node.org}-${config.node.region}" = {
inherit accessKeyId; inherit (config.node) region;
};

resources.ec2SecurityGroups = {
"allow-deployer-ssh-${config.node.region}-${config.node.org}" = {
_file = ./configurator.nix;
inherit accessKeyId; inherit (config.node) region;
description = "SSH";
rules = [{
protocol = "tcp"; # TCP
fromPort = 22; toPort = 22;
sourceIp = deployerIP + "/32";
}];
};
};
builtins.trace "[WARN] deployments/configurator.nix has been split into deployments/gac/configurator.nix and deployments/gac/common-aws.nix please update your symlinks" {
require = [
./gac/configurator.nix
./gac/common-aws.nix
];
}
21 changes: 21 additions & 0 deletions deployments/gac/common-aws.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{ config, ... }:

{
## Universal resource logic:
resources.ec2KeyPairs."cardano-keypair-${config.node.org}-${config.node.region}" = {
inherit (config.node) region accessKeyId;
};

resources.ec2SecurityGroups = {
"allow-deployer-ssh-${config.node.region}-${config.node.org}" = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with the latest changes in the master branch, you can also do:
require = [ ./security-groups/allow-deployer-ssh.nix ];
but that relies on io having done nixops set-args --arg globals 'import ./globals.nix ....'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could do some gymnastics to get around io's globals but wouldn't it just make things more difficult to reason about? @deepfire thoughts?

_file = ./configurator.nix;
inherit (config.node) region accessKeyId;
description = "SSH";
rules = [{
protocol = "tcp"; # TCP
fromPort = 22; toPort = 22;
sourceIp = config.cluster.deployerIP + "/32";
}];
};
};
}
19 changes: 19 additions & 0 deletions deployments/gac/configurator.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{ config , ... }:

{
## Per-machine defaults:
defaults = {
# For Nixops configs, the `config` object we constructed in `/config.nix` should be sufficient;
# for NixOS configs however, we need to make a distinction between defaults and and user-supplied parameters.
imports = [ <module/configurator.nix> ];

# The configurator *module* basically just changes the precedence of everything in `optionDefaults` and `userConfig` and merges them
# together. The reason we have to send it off to a NixOS module is because we literally can't do it here in nixops. Trust, I tried. There be dragons and hydrae 🐉🐲.
configurator = {
# So yeah `config` already has both defaults and user-defined parameters but we can't tell which is which
optionDefaults = config;
# So we also pass the bare user config so that we can work the magic of set theory (I think?)
userConfig = import <config>;
};
};
}