diff options
author | notgne2 | 2020-10-26 11:29:01 -0700 |
---|---|---|
committer | notgne2 | 2020-10-26 11:29:01 -0700 |
commit | 8b3b91344abe6b6361b22943a0176e41fb2d585c (patch) | |
tree | 6cd7116bd2ff19e5e8dbf2c9004dbfb636c2df3d | |
parent | 155f4bf45204b3090cc07271d2648ac7c024bbd1 (diff) |
Improve checks usage, add check for activation script existing
-rw-r--r-- | flake.nix | 24 |
1 files changed, 21 insertions, 3 deletions
@@ -34,7 +34,7 @@ program = "${self.defaultPackage."${system}"}/bin/deploy"; }; - lib = { + lib = rec { setActivate = base: activate: pkgs.buildEnv { name = ("activatable-" + base.name); paths = [ @@ -51,8 +51,26 @@ ]; }; - checkSchema = deploy: pkgs.runCommandNoCC "jsonschema-deploy-system" { } - "${pkgs.python3.pkgs.jsonschema}/bin/jsonschema -i ${pkgs.writeText "deploy.json" (builtins.toJSON deploy)} ${./interface/deploy.json} && touch $out"; + # DEPRECATED + checkSchema = checks.schema; + + deployChecks = deploy: builtins.mapAttrs (_: check: check deploy) checks; + + checks = { + schema = deploy: pkgs.runCommandNoCC "jsonschema-deploy-system" { } '' + ${pkgs.python3.pkgs.jsonschema}/bin/jsonschema -i ${pkgs.writeText "deploy.json" (builtins.toJSON deploy)} ${./interface/deploy.json} && touch $out + ''; + + activate = deploy: + let + allPaths = pkgs.lib.flatten (pkgs.lib.mapAttrsToList (nodeName: node: pkgs.lib.mapAttrsToList (profileName: profile: profile.path) node.profiles) deploy.nodes); + in + pkgs.runCommandNoCC "deploy-rs-check-activate" { } '' + for i in ${builtins.concatStringsSep " " allPaths}; do test -f "$i/deploy-rs-activate" || (echo "A profile path is missing an activation script" && exit 1); done + + touch $out + ''; + }; }; }); } |