Compare commits

..

76 commits

Author SHA1 Message Date
1de353fada
switch reusable script to package, facilitating inspection and reuse 2025-09-03 12:51:06 +02:00
18bcae835e
fix nixops4 for adjusted arguments 2025-09-03 11:53:02 +02:00
9a60948765
WIP: proxmox deployment 2025-09-03 09:20:17 +02:00
7f1dabe7cb
restore path-based behavior for non-data-model tests 2025-09-01 15:20:07 +02:00
253352616b
reusable TF deployment
note that, other than being easier to call, this maintains the TF
deployment's status of remaining a glorified wrapper of the SSH
deployment.
2025-09-01 15:20:07 +02:00
de19210d1d
stablize pathToRoot for TF 2025-09-01 15:20:07 +02:00
a3ffd6d23b
fix pathFromRoot to work on strings, as its removePrefix does not actually work with store versions of sub-folders 2025-09-01 15:20:07 +02:00
dd6e8850f3
stablize pathToRoot by builtins.path 2025-09-01 15:20:07 +02:00
d35de0b457
add data model test for TF 2025-09-01 15:20:07 +02:00
51b72c79c7
simplify deployment/nixos.nix 2025-09-01 15:20:07 +02:00
76a07a6cf1
split tests to allow running the faster ssh test separately 2025-09-01 15:20:07 +02:00
0aeac419e4
factor out data model 2025-09-01 15:20:07 +02:00
220fe52612
add nixops4 data model test 2025-09-01 15:20:07 +02:00
d6731bbc7d
adjust deployment type
this is a cop-out possible until
fricklerhandwerk/Fediversity#15.
after that, this will require actually figuring out how to get `options`
for `deployment.nix` - which may need `evalModules` with
`data-model.nix`.
2025-09-01 15:20:07 +02:00
a245f52e5b
restore data model with { resources } wrappers, this time working 2025-09-01 15:20:07 +02:00
2ae4ca3f68
simpler data model, not sure it's desirable but at least it's consistent 2025-09-01 15:20:06 +02:00
9907404e94
actually rely on user package from data model 2025-09-01 15:20:06 +02:00
22accb50c0
pass system 2025-09-01 15:20:06 +02:00
6e70640caa
update test 2025-09-01 15:20:06 +02:00
5ce2f2e8ed
update deployment 2025-09-01 15:20:06 +02:00
733c500cd1
simplify auth to not accept password 2025-09-01 15:20:06 +02:00
c818e55194
rename deployment to deployment-type, disambiguating from environments' deployment 2025-09-01 15:20:06 +02:00
f705e56707
fix attrTag by adding mkOption 2025-09-01 15:20:06 +02:00
0249324d86
wrap application resources to match the input of apply 2025-09-01 15:20:06 +02:00
4d348fb9cb
stylize user-specified names by quotes to clarify their status 2025-09-01 15:20:06 +02:00
06fc1e8666
fix a bug of mismatching names in data model test
matches the name of `shell` to `operator-environment`.
2025-09-01 15:20:06 +02:00
dc07eb68c3
try and use deployment 2025-09-01 15:20:06 +02:00
871384d51f
spacing 2025-09-01 15:20:06 +02:00
d37a90723f
simplify imputDerivations 2025-09-01 15:20:06 +02:00
ebfe19ab5c
unimport qemu-guest 2025-09-01 15:20:06 +02:00
95a450023a
simplify inputDerivations 2025-09-01 15:20:06 +02:00
f75fb5eec0
simplify deployment 2025-09-01 15:20:06 +02:00
1f35ca5fe8
skip is-active sshd 2025-09-01 15:20:06 +02:00
a76b3cc4a3
- auto 2025-09-01 15:20:06 +02:00
871b6bd906
move fail in 2025-09-01 15:20:06 +02:00
eec987af06
- BatchMode 2025-09-01 15:20:06 +02:00
240d68617e
rm unused ssh settings 2025-09-01 15:20:06 +02:00
c9dc6ee392
dedupe inputDerivations 2025-09-01 15:20:06 +02:00
98599cebf4
rm cowsay 2025-09-01 15:20:06 +02:00
9746ad0e92
remove unused JSON-serialized args (sources) 2025-09-01 15:20:06 +02:00
bcb0fd5318
factor out to nixos.nix 2025-09-01 15:20:06 +02:00
41b4fa6476
rm users 2025-09-01 15:20:06 +02:00
13a97eadaf
simplify grub 2025-09-01 15:20:06 +02:00
a0e330eb85
rm users 2025-09-01 15:20:06 +02:00
fe4916c854
reenable ipv6 2025-09-01 15:20:06 +02:00
1c362d83b9
reenable firewall 2025-09-01 15:20:06 +02:00
4c360d2cd9
rm comments 2025-09-01 15:20:06 +02:00
4db88cf8df
rm getty 2025-09-01 15:20:06 +02:00
e6c590b4d7
mv attempts 2025-09-01 15:20:06 +02:00
03ea2730b0
download-attempts: settle for just targetNode 2025-09-01 15:20:06 +02:00
f8b508fa43
rm comment 2025-09-01 15:20:06 +02:00
2b66f15e7c
restore imports 2025-09-01 15:20:06 +02:00
cac911a16b
dedupe nixosTest.nix 2025-09-01 15:20:06 +02:00
4249a64c10
qemu guest 2025-09-01 15:20:06 +02:00
c1897a3684
grub 2025-09-01 15:20:06 +02:00
562e511ed8
auto login 2025-09-01 15:20:06 +02:00
c7f2e2b7aa
networking 2025-09-01 15:20:06 +02:00
d363957e37
users 2025-09-01 15:20:06 +02:00
9e3c3b9ee0
handle test outcome 2025-09-01 15:20:06 +02:00
d5bd886757
specialArgs: sources 2025-09-01 15:20:06 +02:00
67484b70ee
nix in tests: download-attempts = 1 2025-09-01 15:20:06 +02:00
767ffd9f87
ensure inputs 2025-09-01 15:20:06 +02:00
80f2bbcc4d
rm paste 2025-09-01 15:20:06 +02:00
8d5c9781d5
move stuff not needed in test out 2025-09-01 15:20:06 +02:00
ea78e850af
ensure availability of needed inputs 2025-09-01 15:20:06 +02:00
2a550e6963
reduce download attempts in test 2025-09-01 15:20:06 +02:00
34a5a62ba3
settle for hello, ditching cowsay 2025-09-01 15:20:06 +02:00
c0a5f28adf
move imports from paste to targetNode to increase parity between paste and nixosTest 2025-09-01 15:20:06 +02:00
9adfb3eae9
ditch superfluous substituters 2025-09-01 15:20:06 +02:00
7d3afbb469
pasteable command for trying without rebuilding vm 2025-09-01 15:20:06 +02:00
ff5fd5047f
add keys 2025-09-01 15:20:06 +02:00
d2b5d7e607
wip: use ssh in test 2025-09-01 15:20:06 +02:00
382bcda9d2
add deployment method: ssh 2025-09-01 15:20:06 +02:00
35e49c04f4
un-nixops 2025-09-01 15:20:06 +02:00
bb79f366e9
scaffold deployment/check/data-model from ./basic
modelify
2025-09-01 15:20:06 +02:00
63c6221479
allow different deployment types 2025-09-01 15:20:06 +02:00
9 changed files with 147 additions and 313 deletions

View file

@ -1,5 +1,4 @@
on: on:
workflow_dispatch: # allows manual triggering
pull_request: pull_request:
types: types:
- opened - opened

View file

@ -105,7 +105,8 @@ let
options.enable = lib.mkEnableOption "Hello in the shell"; options.enable = lib.mkEnableOption "Hello in the shell";
}; };
implementation = cfg: { implementation = cfg: {
resources = lib.optionalAttrs cfg.enable { input = cfg;
output.resources = lib.optionalAttrs cfg.enable {
hello.login-shell.packages.hello = pkgs.hello; hello.login-shell.packages.hello = pkgs.hello;
}; };
}; };
@ -138,21 +139,17 @@ let
implementation = implementation =
{ {
required-resources, required-resources,
deployment-name, ...
}: }:
{ {
ssh-host = { input = required-resources;
output.ssh-host = {
nixos-configuration = mkNixosConfiguration environment required-resources; nixos-configuration = mkNixosConfiguration environment required-resources;
system = targetSystem;
ssh = { ssh = {
username = "root"; username = "root";
host = nodeName; host = nodeName;
key-file = null; key-file = null;
inherit sshOpts;
}; };
module = self;
inherit args deployment-name;
root-path = pathToRoot;
}; };
}; };
}; };
@ -164,7 +161,8 @@ let
... ...
}: }:
{ {
nixops4 = input = required-resources;
output.nixops4 =
{ providers, ... }: { providers, ... }:
{ {
providers = { providers = {
@ -191,7 +189,8 @@ let
deployment-name, deployment-name,
}: }:
{ {
tf-host = { input = required-resources;
output.tf-host = {
nixos-configuration = mkNixosConfiguration environment required-resources; nixos-configuration = mkNixosConfiguration environment required-resources;
system = targetSystem; system = targetSystem;
ssh = { ssh = {
@ -214,7 +213,8 @@ let
deployment-name, deployment-name,
}: }:
{ {
tf-proxmox-host = { input = required-resources;
output.tf-proxmox-host = {
nixos-configuration = mkNixosConfiguration environment required-resources; nixos-configuration = mkNixosConfiguration environment required-resources;
system = targetSystem; system = targetSystem;
ssh = { ssh = {

View file

@ -9,9 +9,9 @@ let
inherit (pkgs) system; inherit (pkgs) system;
deployment-config = { deployment-config = {
inherit pathToRoot pathFromRoot; inherit pathToRoot pathFromRoot;
inherit (config) enableAcme;
acmeNodeIP = if config.enableAcme then config.nodes.acme.networking.primaryIPAddress else null;
nodeName = "ssh"; nodeName = "ssh";
targetSystem = system;
sshOpts = [ ];
}; };
deploy = deploy =
(import ../common/data-model.nix { (import ../common/data-model.nix {
@ -30,10 +30,6 @@ in
sourceFileset = lib.fileset.unions [ sourceFileset = lib.fileset.unions [
../../data-model.nix ../../data-model.nix
../../function.nix ../../function.nix
../../nixos.nix
../../run/ssh-single-host/run.sh
../../../npins/default.nix
../../../npins/sources.json
../common/data-model.nix ../common/data-model.nix
../common/data-model-options.nix ../common/data-model-options.nix
./constants.nix ./constants.nix

View file

@ -11,7 +11,10 @@ let
inherit pathToRoot pathFromRoot; inherit pathToRoot pathFromRoot;
nodeName = "mypve"; nodeName = "mypve";
targetSystem = system; targetSystem = system;
sshOpts = [ ]; sshOpts = [
"ConnectTimeout=1"
"ServerAliveInterval=1"
];
}; };
deployment = deployment =
(import ../common/data-model.nix { (import ../common/data-model.nix {
@ -19,6 +22,7 @@ let
config = deployment-config; config = deployment-config;
# opt not to pass `inputs`, as we could only pass serializable arguments through to its self-call # opt not to pass `inputs`, as we could only pass serializable arguments through to its self-call
})."tf-proxmox-deployment".tf-proxmox-host; })."tf-proxmox-deployment".tf-proxmox-host;
# deployment = setup.tf-proxmox-host;
# tracking non-tarball downloads seems unsupported still in npins: # tracking non-tarball downloads seems unsupported still in npins:
# https://github.com/andir/npins/issues/163 # https://github.com/andir/npins/issues/163
minimalIso = pkgs.fetchurl { minimalIso = pkgs.fetchurl {
@ -87,7 +91,6 @@ in
(pkgs.callPackage ../../run/tf-proxmox/tf.nix { inherit sources; }) (pkgs.callPackage ../../run/tf-proxmox/tf.nix { inherit sources; })
jq jq
nixos-generators nixos-generators
deployment.run
]; ];
# needed only when building from deployer # needed only when building from deployer
@ -121,80 +124,23 @@ in
then then
lib.trace "yes" [ lib.trace "yes" [
# lib.traceVal pkg.inputDerivation # not of type `path in the Nix store' # lib.traceVal pkg.inputDerivation # not of type `path in the Nix store'
( ((x: builtins.trace "${builtins.toString pkg}: ${builtins.toString (lib.isPath x.inputDerivation)}" x) pkg).inputDerivation
(
x: builtins.trace "${builtins.toString pkg}: ${builtins.toString (lib.isPath x.inputDerivation)}" x
)
pkg
).inputDerivation
] ]
else else
lib.trace "no" [ ] lib.trace "no" [ ]
) )
) machine.environment.systemPackages) ) machine.environment.systemPackages)
++ [ ++ [
( ((x: builtins.trace "machine.system.build.toplevel.inputDerivation: ${builtins.toString (lib.isPath x)}" x) machine.system.build.toplevel.inputDerivation)
( ((x: builtins.trace "machine.system.build.etc.inputDerivation: ${builtins.toString (lib.isPath x)}" x) machine.system.build.etc.inputDerivation)
x: ((x: builtins.trace "machine.system.build.etcBasedir.inputDerivation: ${builtins.toString (lib.isPath x)}" x) machine.system.build.etcBasedir.inputDerivation)
builtins.trace "machine.system.build.toplevel.inputDerivation: ${builtins.toString (lib.isPath x)}" x ((x: builtins.trace "machine.system.build.etcMetadataImage.inputDerivation: ${builtins.toString (lib.isPath x)}" x) machine.system.build.etcMetadataImage.inputDerivation)
) ((x: builtins.trace "machine.system.build.extraUtils.inputDerivation: ${builtins.toString (lib.isPath x)}" x) machine.system.build.extraUtils.inputDerivation)
machine.system.build.toplevel.inputDerivation ((x: builtins.trace "machine.system.path.inputDerivation: ${builtins.toString (lib.isPath x)}" x) machine.system.path.inputDerivation)
) ((x: builtins.trace "machine.system.build.setEnvironment.inputDerivation: ${builtins.toString (lib.isPath x)}" x) machine.system.build.setEnvironment.inputDerivation)
( ((x: builtins.trace "machine.system.build.vm.inputDerivation: ${builtins.toString (lib.isPath x)}" x) machine.system.build.vm.inputDerivation)
( ((x: builtins.trace "machine.system.build.bootStage1.inputDerivation: ${builtins.toString (lib.isPath x)}" x) machine.system.build.bootStage1.inputDerivation)
x: builtins.trace "machine.system.build.etc.inputDerivation: ${builtins.toString (lib.isPath x)}" x ((x: builtins.trace "machine.system.build.bootStage2.inputDerivation: ${builtins.toString (lib.isPath x)}" x) machine.system.build.bootStage2.inputDerivation)
)
machine.system.build.etc.inputDerivation
)
(
(
x:
builtins.trace "machine.system.build.etcBasedir.inputDerivation: ${builtins.toString (lib.isPath x)}" x
)
machine.system.build.etcBasedir.inputDerivation
)
(
(
x:
builtins.trace "machine.system.build.etcMetadataImage.inputDerivation: ${builtins.toString (lib.isPath x)}" x
)
machine.system.build.etcMetadataImage.inputDerivation
)
(
(
x:
builtins.trace "machine.system.build.extraUtils.inputDerivation: ${builtins.toString (lib.isPath x)}" x
)
machine.system.build.extraUtils.inputDerivation
)
((x: builtins.trace "machine.system.path.inputDerivation: ${builtins.toString (lib.isPath x)}" x)
machine.system.path.inputDerivation
)
(
(
x:
builtins.trace "machine.system.build.setEnvironment.inputDerivation: ${builtins.toString (lib.isPath x)}" x
)
machine.system.build.setEnvironment.inputDerivation
)
(
(x: builtins.trace "machine.system.build.vm.inputDerivation: ${builtins.toString (lib.isPath x)}" x)
machine.system.build.vm.inputDerivation
)
(
(
x:
builtins.trace "machine.system.build.bootStage1.inputDerivation: ${builtins.toString (lib.isPath x)}" x
)
machine.system.build.bootStage1.inputDerivation
)
(
(
x:
builtins.trace "machine.system.build.bootStage2.inputDerivation: ${builtins.toString (lib.isPath x)}" x
)
machine.system.build.bootStage2.inputDerivation
)
pkgs.gnu-config pkgs.gnu-config
# pkgs.gnu-config.inputDerivation # pkgs.gnu-config.inputDerivation
pkgs.byacc pkgs.byacc
@ -240,13 +186,7 @@ in
if v ? source.inputDerivation then if v ? source.inputDerivation then
[ [
# v.source.inputDerivation # v.source.inputDerivation
( ((x: builtins.trace "${builtins.toString (lib.attrNames v)}: ${builtins.toString (lib.isPath x.source.inputDerivation)}" x) v).source.inputDerivation
(
x:
builtins.trace "${builtins.toString (lib.attrNames v)}: ${builtins.toString (lib.isPath x.source.inputDerivation)}" x
)
v
).source.inputDerivation
] ]
else else
[ ] [ ]
@ -269,7 +209,7 @@ in
with subtest("Run the deployment"): with subtest("Run the deployment"):
# target.fail("hello 1>&2") # target.fail("hello 1>&2")
deployer.succeed(""" deployer.succeed("""
${lib.getExe deployment.run} ${deployment.run}
""") """)
# target.wait_for_unit("multi-user.target") # target.wait_for_unit("multi-user.target")
# target.succeed("su - operator -c hello 1>&2") # target.succeed("su - operator -c hello 1>&2")

View file

@ -10,14 +10,17 @@ let
inherit pathToRoot pathFromRoot; inherit pathToRoot pathFromRoot;
nodeName = "target"; nodeName = "target";
targetSystem = system; targetSystem = system;
sshOpts = [ ]; sshOpts = [
"ConnectTimeout=1"
"ServerAliveInterval=1"
];
}; };
deploy = deployment =
(import ../common/data-model.nix { (import ../common/data-model.nix {
inherit system; inherit system;
config = deployment-config; config = deployment-config;
# opt not to pass `inputs`, as we could only pass serializable arguments through to its self-call # opt not to pass `inputs`, as we could only pass serializable arguments through to its self-call
})."tf-deployment".tf-host.run; })."tf-deployment".tf-host;
in in
{ {
_class = "nixosTest"; _class = "nixosTest";
@ -36,7 +39,6 @@ in
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
(pkgs.callPackage ../../run/tf-single-host/tf.nix { }) (pkgs.callPackage ../../run/tf-single-host/tf.nix { })
jq jq
deploy
]; ];
# needed only when building from deployer # needed only when building from deployer
@ -55,7 +57,7 @@ in
with subtest("ssh: Run the deployment"): with subtest("ssh: Run the deployment"):
deployer.succeed(""" deployer.succeed("""
${lib.getExe deploy} ${deployment.run}
""") """)
target.wait_for_unit("multi-user.target") target.wait_for_unit("multi-user.target")
target.succeed("su - operator -c hello 1>&2") target.succeed("su - operator -c hello 1>&2")

View file

@ -98,9 +98,9 @@ in
{ {
options.enable = lib.mkEnableOption "Hello in the shell"; options.enable = lib.mkEnableOption "Hello in the shell";
}; };
implementation = implementation = cfg: {
cfg: { input = cfg;
resources = lib.optionalAttrs cfg.enable { output.resources = lib.optionalAttrs cfg.enable {
hello.login-shell.packages.hello = pkgs.hello; hello.login-shell.packages.hello = pkgs.hello;
}; };
}; };
@ -110,7 +110,8 @@ in
{ {
resources."operator-environment".login-shell.username = "operator"; resources."operator-environment".login-shell.username = "operator";
implementation = requests: { implementation = requests: {
nixops4 = ( input = requests;
output.nixops4 =
{ providers, ... }: { providers, ... }:
{ {
providers = { providers = {
@ -133,8 +134,7 @@ in
}; };
}; };
}; };
} };
);
}; };
}; };
}; };

View file

@ -29,7 +29,7 @@ let
lib.strings.toJSON v lib.strings.toJSON v
); );
functionType = submodule ./function.nix; functionType = import ./function.nix;
application-resources = submodule { application-resources = submodule {
options.resources = mkOption { options.resources = mkOption {
# TODO: maybe transpose, and group the resources by type instead # TODO: maybe transpose, and group the resources by type instead
@ -87,73 +87,12 @@ let
deployment-type = attrTag { deployment-type = attrTag {
ssh-host = mkOption { ssh-host = mkOption {
description = "A deployment by SSH to update a single existing NixOS host."; description = "A deployment by SSH to update a single existing NixOS host.";
type = submodule (ssh-host: { type = submodule {
options = { options = {
system = mkOption {
description = "The architecture of the system to deploy to.";
type = types.str;
};
inherit nixos-configuration; inherit nixos-configuration;
ssh = host-ssh; ssh = host-ssh;
module = mkOption {
description = "The module to call to obtain the NixOS configuration from.";
type = types.str;
};
args = mkOption {
description = "The arguments with which to call the module to obtain the NixOS configuration.";
type = types.attrs;
};
deployment-name = mkOption {
description = "The name of the deployment for which to obtain the NixOS configuration.";
type = types.str;
};
root-path = mkOption {
description = "The path to the root of the repository.";
type = types.path;
};
run = mkOption {
type = types.package;
# error: The option `ssh-deployment.ssh-host.run' is read-only, but it's set multiple times.
# readOnly = true;
default =
let
inherit (ssh-host.config)
system
ssh
module
args
deployment-name
root-path
;
inherit (ssh)
host
username
key-file
sshOpts
;
environment = {
key_file = key-file;
deployment_name = deployment-name;
root_path = root-path;
ssh_opts = sshOpts;
inherit
system
host
username
module
args
;
deployment_type = "ssh-host";
};
in
pkgs.writeShellScriptBin "deploy-ssh.sh" ''
env ${
toString (lib.mapAttrsToList (k: v: "${k}=\"${toBash v}\"") environment)
} bash ./deployment/run/ssh-single-host/run.sh
'';
}; };
}; };
});
}; };
nixops4 = mkOption { nixops4 = mkOption {
description = "A NixOps4 NixOS deployment. For an example, see https://github.com/nixops4/nixops4-nixos/blob/main/example/deployment.nix."; description = "A NixOps4 NixOS deployment. For an example, see https://github.com/nixops4/nixops4-nixos/blob/main/example/deployment.nix.";
@ -257,7 +196,7 @@ let
type = types.path; type = types.path;
}; };
run = mkOption { run = mkOption {
type = types.package; type = types.str;
# error: The option `tf-deployment.tf-host.run' is read-only, but it's set multiple times. # error: The option `tf-deployment.tf-host.run' is read-only, but it's set multiple times.
# readOnly = true; # readOnly = true;
default = default =
@ -292,7 +231,7 @@ let
}; };
tf-env = pkgs.callPackage ./run/tf-proxmox/tf-env.nix { }; tf-env = pkgs.callPackage ./run/tf-proxmox/tf-env.nix { };
in in
pkgs.writeShellScriptBin "deploy-ssh.sh" '' ''
env ${toString (lib.mapAttrsToList (k: v: "TF_VAR_${k}=\"${toBash v}\"") environment)} \ env ${toString (lib.mapAttrsToList (k: v: "TF_VAR_${k}=\"${toBash v}\"") environment)} \
tf_env=${tf-env} bash ./deployment/run/tf-proxmox/run.sh tf_env=${tf-env} bash ./deployment/run/tf-proxmox/run.sh
''; '';
@ -364,19 +303,18 @@ in
}; };
resources = mkOption { resources = mkOption {
description = "Compute resources required by an application"; description = "Compute resources required by an application";
type = application.config.config-mapping.function-type; type = functionTo application.config.config-mapping.output-type;
readOnly = true; readOnly = true;
default = application.config.config-mapping.apply; default = input: (application.config.implementation input).output;
}; };
# TODO(@fricklerhandwerk): this needs a better name # TODO(@fricklerhandwerk): this needs a better name, it's just the type
config-mapping = mkOption { config-mapping = mkOption {
description = "Function type for the mapping from application configuration to required resources"; description = "Function type for the mapping from application configuration to required resources";
type = functionType; type = submodule functionType;
readOnly = true; readOnly = true;
default = { default = {
input-type = submodule application.config.module; input-type = submodule application.config.module;
output-type = application-resources; output-type = application-resources;
implementation = application.config.implementation;
}; };
}; };
}; };
@ -408,7 +346,7 @@ in
}; };
resource-mapping = mkOption { resource-mapping = mkOption {
description = "Function type for the mapping from resources to a deployment"; description = "Function type for the mapping from resources to a deployment";
type = functionType; type = submodule functionType;
readOnly = true; readOnly = true;
default = { default = {
input-type = submodule { input-type = submodule {
@ -422,26 +360,16 @@ in
}; };
}; };
output-type = deployment-type; output-type = deployment-type;
implementation = environment.config.implementation;
}; };
}; };
config-mapping = mkOption { # TODO(@fricklerhandwerk): maybe this should be a separate thing such as `fediversity-setup`,
description = "Mapping from a configuration to a deployment"; # which makes explicit which applications and environments are available.
type = functionType; # then the deployments can simply be the result of the function application baked into this module.
deployment = mkOption {
description = "Generate a deployment from a configuration, by applying an environment's resource policies to the applications' resource mappings";
type = functionTo (environment.config.resource-mapping.output-type);
readOnly = true; readOnly = true;
default = { default =
input-type = submodule {
options = {
deployment-name = mkOption {
type = types.str;
};
configuration = mkOption {
type = config.configuration;
};
};
};
output-type = deployment-type;
implementation =
{ {
deployment-name, deployment-name,
configuration, configuration,
@ -452,17 +380,8 @@ in
name: application-settings: config.applications.${name}.resources application-settings name: application-settings: config.applications.${name}.resources application-settings
) configuration.applications; ) configuration.applications;
in in
environment.config.resource-mapping.apply { inherit required-resources deployment-name; }; (environment.config.implementation { inherit required-resources deployment-name; }).output;
};
};
# TODO(@fricklerhandwerk): maybe this should be a separate thing such as `fediversity-setup`,
# which makes explicit which applications and environments are available.
# then the deployments can simply be the result of the function application baked into this module.
deployment = mkOption {
description = "Generate a deployment from a configuration, by applying an environment's resource policies to the applications' resource mappings";
type = environment.config.config-mapping.function-type;
readOnly = true;
default = environment.config.config-mapping.apply;
}; };
}; };
}) })

View file

@ -19,11 +19,6 @@ in
type = optionType; type = optionType;
}; };
function-type = mkOption { function-type = mkOption {
type = optionType;
readOnly = true;
default = functionTo config.output-type;
};
wrapper-type = mkOption {
type = optionType; type = optionType;
readOnly = true; readOnly = true;
default = functionTo (submodule { default = functionTo (submodule {
@ -37,22 +32,5 @@ in
}; };
}); });
}; };
implementation = mkOption {
type = config.function-type;
default = _: { };
};
wrapper = mkOption {
type = config.wrapper-type;
readOnly = true;
default = input: fn: {
inherit input;
output = config.implementation fn.config.input;
};
};
apply = mkOption {
type = config.function-type;
readOnly = true;
default = input: (config.wrapper input).output;
};
}; };
} }

2
deployment/run/ssh-single-host/run.sh Executable file → Normal file
View file

@ -39,7 +39,7 @@ NIX_SSHOPTS="${sshOpts[*]}" nix-copy-closure --to "$destination" "$outPath" --gz
# shellcheck disable=SC2029 # shellcheck disable=SC2029
ssh "${sshOpts[@]}" "$destination" "nix-env --profile /nix/var/nix/profiles/system --set $outPath" ssh "${sshOpts[@]}" "$destination" "nix-env --profile /nix/var/nix/profiles/system --set $outPath"
# shellcheck disable=SC2029 # shellcheck disable=SC2029
output=$(ssh -o "ConnectTimeout=1" -o "ServerAliveInterval=1" "${sshOpts[@]}" "$destination" "nohup $outPath/bin/switch-to-configuration switch &" 2>&1) || echo "status code: $?" output=$(ssh "${sshOpts[@]}" "$destination" "nohup $outPath/bin/switch-to-configuration switch &" 2>&1) || echo "status code: $?"
echo "output: $output" echo "output: $output"
if [[ $output != *"Timeout, server $host not responding"* ]]; then if [[ $output != *"Timeout, server $host not responding"* ]]; then
echo "non-timeout error: $output" echo "non-timeout error: $output"