forked from fediversity/fediversity
Compare commits
2 commits
b5a96a70b8
...
782821ed36
| Author | SHA1 | Date | |
|---|---|---|---|
| 782821ed36 | |||
| 80e2a9b909 |
12 changed files with 116 additions and 32 deletions
|
|
@ -57,11 +57,17 @@ jobs:
|
|||
- uses: actions/checkout@v4
|
||||
- run: nix build .#checks.x86_64-linux.deployment-panel -L
|
||||
|
||||
check-deployment-model:
|
||||
check-deployment-model-ssh:
|
||||
runs-on: native
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- run: nix build .#checks.x86_64-linux.deployment-model -L
|
||||
- run: nix build .#checks.x86_64-linux.deployment-model-ssh -L
|
||||
|
||||
check-deployment-model-nixops4:
|
||||
runs-on: native
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- run: nix build .#checks.x86_64-linux.deployment-model-nixops4 -L
|
||||
|
||||
## NOTE: NixOps4 does not provide a good “dry run” mode, so we instead check
|
||||
## proxies for resources, namely whether their `.#vmOptions.<machine>` and
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ let
|
|||
pkgs = import nixpkgs { inherit system; };
|
||||
inherit (pkgs) lib;
|
||||
deployment-config = config;
|
||||
inherit (deployment-config) nodeName;
|
||||
inherit (lib) mkOption types;
|
||||
inherit (import ./constants.nix) targetMachines pathToRoot pathFromRoot;
|
||||
eval =
|
||||
module:
|
||||
(lib.evalModules {
|
||||
|
|
@ -106,7 +106,7 @@ let
|
|||
{ ... }:
|
||||
{
|
||||
imports = [
|
||||
./options.nix
|
||||
./data-model-options.nix
|
||||
../common/sharedOptions.nix
|
||||
../common/targetNode.nix
|
||||
"${nixpkgs}/nixos/modules/profiles/qemu-guest.nix"
|
||||
|
|
@ -130,7 +130,7 @@ let
|
|||
nixos-configuration = mkNixosConfiguration environment requests;
|
||||
ssh = {
|
||||
username = "root";
|
||||
inherit (deployment-config) host;
|
||||
host = nodeName;
|
||||
key-file = null;
|
||||
};
|
||||
};
|
||||
|
|
@ -146,7 +146,7 @@ let
|
|||
providers = {
|
||||
inherit (inputs.nixops4.modules.nixops4Provider) local;
|
||||
};
|
||||
resources = lib.genAttrs targetMachines (nodeName: {
|
||||
resources.${nodeName} = {
|
||||
type = providers.local.exec;
|
||||
imports = [
|
||||
inputs.nixops4-nixos.modules.nixops4Resource.nixos
|
||||
|
|
@ -154,8 +154,8 @@ let
|
|||
];
|
||||
nixos.module = mkNixosConfiguration environment requests;
|
||||
_module.args = { inherit inputs sources; };
|
||||
inherit nodeName pathToRoot pathFromRoot;
|
||||
});
|
||||
inherit (deployment-config) nodeName pathToRoot pathFromRoot;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
@ -163,7 +163,7 @@ in
|
|||
'')}
|
||||
|
||||
${
|
||||
if true then
|
||||
if config.useFlake then
|
||||
''
|
||||
## NOTE: This is super slow. It could probably be optimised in Nix, for
|
||||
## instance by allowing to grab things directly from the host's store.
|
||||
|
|
|
|||
9
deployment/check/data-model-nixops4/constants.nix
Normal file
9
deployment/check/data-model-nixops4/constants.nix
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
targetMachines = [
|
||||
"nixops4"
|
||||
];
|
||||
pathToRoot = ../../..;
|
||||
pathFromRoot = ./.;
|
||||
enableAcme = true;
|
||||
useFlake = true;
|
||||
}
|
||||
22
deployment/check/data-model-nixops4/default.nix
Normal file
22
deployment/check/data-model-nixops4/default.nix
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
runNixOSTest,
|
||||
inputs,
|
||||
sources,
|
||||
}:
|
||||
|
||||
runNixOSTest {
|
||||
imports = [
|
||||
../../data-model.nix
|
||||
../../function.nix
|
||||
../common/nixosTest.nix
|
||||
./nixosTest.nix
|
||||
];
|
||||
_module.args = { inherit inputs sources; };
|
||||
inherit (import ./constants.nix)
|
||||
targetMachines
|
||||
pathToRoot
|
||||
pathFromRoot
|
||||
enableAcme
|
||||
useFlake
|
||||
;
|
||||
}
|
||||
|
|
@ -17,9 +17,12 @@
|
|||
];
|
||||
|
||||
nixops4Deployments.check-deployment-model =
|
||||
(import ./deployment/check/data-model/deployment.nix {
|
||||
(import ./deployment/check/common/data-model.nix {
|
||||
inherit system inputs;
|
||||
config.host = "nixops4";
|
||||
config = {
|
||||
inherit (import ./deployment/check/data-model-nixops4/constants.nix) pathToRoot pathFromRoot;
|
||||
nodeName = "nixops4";
|
||||
};
|
||||
})."nixops4-deployment".nixops4;
|
||||
}
|
||||
);
|
||||
52
deployment/check/data-model-nixops4/nixosTest.nix
Normal file
52
deployment/check/data-model-nixops4/nixosTest.nix
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
inputs,
|
||||
...
|
||||
}:
|
||||
{
|
||||
_class = "nixosTest";
|
||||
imports = [
|
||||
../common/data-model-options.nix
|
||||
];
|
||||
|
||||
name = "deployment-model";
|
||||
sourceFileset = lib.fileset.unions [
|
||||
../../data-model.nix
|
||||
../../function.nix
|
||||
../common/data-model.nix
|
||||
../common/data-model-options.nix
|
||||
./constants.nix
|
||||
(config.pathToCwd + "/flake-under-test.nix")
|
||||
];
|
||||
|
||||
nodes.deployer =
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
environment.systemPackages = with pkgs; [
|
||||
inputs.nixops4.packages.${system}.default
|
||||
jq
|
||||
];
|
||||
|
||||
# FIXME: sad times
|
||||
system.extraDependencies = with pkgs; [
|
||||
jq
|
||||
jq.inputDerivation
|
||||
];
|
||||
|
||||
system.extraDependenciesFromModule =
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
environment.systemPackages = with pkgs; [
|
||||
hello
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
extraTestScript = ''
|
||||
with subtest("nixops4"):
|
||||
nixops4.fail("hello 1>&2")
|
||||
deployer.succeed("nixops4 apply check-deployment-model --show-trace --verbose --no-interactive 1>&2")
|
||||
nixops4.succeed("su - operator -c hello 1>&2")
|
||||
'';
|
||||
}
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
{
|
||||
targetMachines = [
|
||||
"ssh"
|
||||
"nixops4"
|
||||
];
|
||||
pathToRoot = ../../..;
|
||||
pathFromRoot = ./.;
|
||||
|
|
@ -9,12 +9,13 @@ let
|
|||
inherit (import ./constants.nix) pathToRoot;
|
||||
escapedJson = v: lib.replaceStrings [ "\"" ] [ "\\\\\"" ] (lib.strings.toJSON v);
|
||||
deployment-config = {
|
||||
inherit (import ./constants.nix) pathToRoot pathFromRoot;
|
||||
inherit (config) enableAcme;
|
||||
acmeNodeIP = if config.enableAcme then config.nodes.acme.networking.primaryIPAddress else null;
|
||||
host = "ssh";
|
||||
nodeName = "ssh";
|
||||
};
|
||||
inherit
|
||||
((import ./deployment.nix {
|
||||
((import ../common/data-model.nix {
|
||||
inherit (pkgs) system;
|
||||
inherit inputs;
|
||||
config = deployment-config;
|
||||
|
|
@ -28,33 +29,25 @@ in
|
|||
{
|
||||
_class = "nixosTest";
|
||||
imports = [
|
||||
./options.nix
|
||||
../common/data-model-options.nix
|
||||
];
|
||||
|
||||
name = "deployment-model";
|
||||
sourceFileset = lib.fileset.unions [
|
||||
../../data-model.nix
|
||||
../../function.nix
|
||||
../common/data-model.nix
|
||||
../common/data-model-options.nix
|
||||
./constants.nix
|
||||
./deployment.nix
|
||||
./options.nix
|
||||
(config.pathToCwd + "/flake-under-test.nix")
|
||||
];
|
||||
|
||||
nodes.deployer =
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
environment.systemPackages = with pkgs; [
|
||||
inputs.nixops4.packages.${system}.default
|
||||
jq
|
||||
];
|
||||
|
||||
# FIXME: sad times
|
||||
system.extraDependencies = with pkgs; [
|
||||
jq
|
||||
jq.inputDerivation
|
||||
];
|
||||
|
||||
system.extraDependenciesFromModule =
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
|
|
@ -65,11 +58,6 @@ in
|
|||
};
|
||||
|
||||
extraTestScript = ''
|
||||
with subtest("nixops4"):
|
||||
nixops4.fail("hello 1>&2")
|
||||
deployer.succeed("nixops4 apply check-deployment-model --show-trace --verbose --no-interactive 1>&2")
|
||||
nixops4.succeed("su - operator -c hello 1>&2")
|
||||
|
||||
with subtest("ssh: Check the status before deployment"):
|
||||
ssh.fail("hello 1>&2")
|
||||
|
||||
|
|
@ -85,7 +73,7 @@ in
|
|||
import ${pathToRoot}/deployment/nixos.nix {
|
||||
inherit system;
|
||||
configuration = (
|
||||
import ${pathToRoot}/deployment/check/data-model/deployment.nix {
|
||||
import ${pathToRoot}/deployment/check/common/data-model.nix {
|
||||
inherit system;
|
||||
config = builtins.fromJSON "${escapedJson deployment-config}";
|
||||
}
|
||||
|
|
@ -22,7 +22,12 @@
|
|||
inherit inputs sources;
|
||||
};
|
||||
|
||||
deployment-model = import ./check/data-model {
|
||||
deployment-model-ssh = import ./check/data-model-ssh {
|
||||
inherit (pkgs.testers) runNixOSTest;
|
||||
inherit inputs sources;
|
||||
};
|
||||
|
||||
deployment-model-nixops4 = import ./check/data-model-nixops4 {
|
||||
inherit (pkgs.testers) runNixOSTest;
|
||||
inherit inputs sources;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue