diff --git a/.forgejo/workflows/ci.yaml b/.forgejo/workflows/ci.yaml index bd65f57d..be39a2f2 100644 --- a/.forgejo/workflows/ci.yaml +++ b/.forgejo/workflows/ci.yaml @@ -43,7 +43,7 @@ jobs: runs-on: native steps: - uses: actions/checkout@v4 - - run: nix build .#checks.x86_64-linux.deployment-basic -L + - run: cd deployment && nix-build -A tests check-deployment-cli: runs-on: native diff --git a/deployment/check/basic/nixosTest.nix b/deployment/check/basic/nixosTest.nix index 93c8ad23..6ffcb612 100644 --- a/deployment/check/basic/nixosTest.nix +++ b/deployment/check/basic/nixosTest.nix @@ -1,5 +1,8 @@ -{ inputs, lib, ... }: - +{ + lib, + sources ? import ../npins, + ... +}: { _class = "nixosTest"; @@ -11,18 +14,8 @@ ]; nodes.deployer = - { pkgs, ... }: + { nodes, ... }: { - environment.systemPackages = [ - inputs.nixops4.packages.${pkgs.system}.default - ]; - - # FIXME: sad times - system.extraDependencies = with pkgs; [ - jq - jq.inputDerivation - ]; - system.extraDependenciesFromModule = { pkgs, ... }: { @@ -30,19 +23,60 @@ hello cowsay ]; + + virtualisation = { + ## Memory use is expected to be dominated by the NixOS evaluation, + ## which happens on the deployer. + memorySize = 4096; + diskSize = 10 * 1024; + cores = 2; + }; + + nix.settings = { + substituters = lib.mkForce [ ]; + hashed-mirrors = null; + connect-timeout = 1; + }; + + system.extraDependencies = + with pkgs; + [ + jq + jq.inputDerivation + sources.nixpkgs + + pkgs.stdenv + pkgs.stdenvNoCC + + pkgs.cowsay + pkgs.cowsay.inputDerivation # NOTE: Crucial!!! + + ## Some derivations will be different compared to target's initial + ## state, so we'll need to be able to build something similar. + ## Generally the derivation inputs aren't that different, so we + ## use the initial state of the target as a base. + nodes.target.system.build.toplevel.inputDerivation + nodes.target.system.build.etc.inputDerivation + nodes.target.system.path.inputDerivation + nodes.target.system.build.bootStage1.inputDerivation + nodes.target.system.build.bootStage2.inputDerivation + ] + ++ lib.concatLists ( + lib.mapAttrsToList ( + _k: v: if v ? source.inputDerivation then [ v.source.inputDerivation ] else [ ] + ) nodes.target.environment.etc + ); }; }; extraTestScript = '' with subtest("Check the status before deployment"): - hello.fail("hello 1>&2") - cowsay.fail("cowsay 1>&2") + target.fail("cowsay hi 1>&2") with subtest("Run the deployment"): - deployer.succeed("nixops4 apply check-deployment-basic --show-trace --no-interactive 1>&2") + deployer.succeed("cd work && tofu apply --show-trace --no-interactive") with subtest("Check the deployment"): - hello.succeed("hello 1>&2") - cowsay.succeed("cowsay hi 1>&2") + target.succeed("cowsay hi 1>&2") ''; } diff --git a/deployment/default.nix b/deployment/default.nix index c76489bd..f4ca894f 100644 --- a/deployment/default.nix +++ b/deployment/default.nix @@ -1,3 +1,4 @@ +<<<<<<< HEAD ## `makeMakeDeployment` -- Function to help hosting providers make a ## `makeDeployment` function. ## @@ -214,5 +215,17 @@ in } ); }; +======= +{ + system ? builtins.currentSystem, + sources ? import ../npins, + pkgs ? import sources.nixpkgs { + inherit system; + }, +}: +{ + tests = { + deployment-basic = import ./check/basic/nixosTest.nix { inherit pkgs; }; +>>>>>>> fac372b3 (strip test as a start to convert it) }; } diff --git a/infra/sync-nix/.npins.json b/infra/sync-nix/.npins.json deleted file mode 100644 index e679cf7e..00000000 --- a/infra/sync-nix/.npins.json +++ /dev/null @@ -1 +0,0 @@ -{"agenix":"/nix/store/glsqq1xn5al7d528hvlbm4hl3ladxmka-source","disko":"/nix/store/7wf9q0mb1i43x9dr1qlyfaraq15n6sii-source","flake-inputs":"/nix/store/fqln0bcp6mp75k4sl0cav2f0np60lwhj-source","git-hooks":"/nix/store/8bh3jgq1riy3jxm07vy4xxzvk9xd74pc-source","gitignore":"/nix/store/g5v3sgqy6a0fsmas7mnapc196flrplix-source","home-manager":"/nix/store/cq3b3cx5rv9d0zj57kch9wmxzc2rm8dc-source","htmx":"/nix/store/mwqqk0qmldzvv4xj9kq2lbah2flhc44z-source","nix-unit":"/nix/store/4g1vvy7bhwh16cyd2r8ibq7n6ygk1wvk-source","nixpkgs":"/nix/store/w0y3wsqi67rlg544myycqxcg2hh17j1v-source"}