This repository has been archived by the owner on Jun 17, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 41
gac: split deployments/configurator.nix
#601
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}" = { | ||
_file = ./configurator.nix; | ||
inherit (config.node) region accessKeyId; | ||
description = "SSH"; | ||
rules = [{ | ||
protocol = "tcp"; # TCP | ||
fromPort = 22; toPort = 22; | ||
sourceIp = config.cluster.deployerIP + "/32"; | ||
}]; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>; | ||
}; | ||
}; | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 donenixops set-args --arg globals 'import ./globals.nix ....'
There was a problem hiding this comment.
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
'sglobals
but wouldn't it just make things more difficult to reason about? @deepfire thoughts?