diff options
| -rw-r--r-- | krops.nix | 45 |
1 files changed, 33 insertions, 12 deletions
@@ -21,9 +21,11 @@ # target where to deploy it, instead of spec.nix's target # switch what switch-to-configuration does: switch (the default), boot, # or test (no new generation) -# mobile-nixos -# a directory to use as <mobile-nixos>, as it is, instead of the -# pinned revision, e.g. to try another kernel +# checkouts +# sources to deliver from a directory, as it is, instead of +# their pinned revisions: a comma-separated list of NAME (the +# directory ~/sync/src/NAME) or NAME=PATH (an absolute path), +# e.g. mobile-nixos to try another kernel # # REMOTE BUILDS # A host whose spec.nix lists builders (targets like populate's, @@ -48,12 +50,30 @@ , name , target ? null , switch ? "switch" -, mobile-nixos ? null +, checkouts ? "" }@args: assert builtins.elem switch [ "switch" "boot" "test" ]; let + checkoutSources = lib.listToAttrs (map + (item: let + parts = builtins.match "([^=]+)(=(.*))?" item; + source = builtins.elemAt parts 0; + path = builtins.elemAt parts 2; + in + assert path == null || lib.hasPrefix "/" path + || throw "krops.nix: checkouts: ${item}: not an absolute path"; + lib.nameValuePair source { + file = { + # The target's .git stays, for when the pinned revision is back. + deleteExcluded = false; + filters = [ { type = "exclude"; pattern = ".git"; } ]; + path = if path != null then path else toString ~/sync/src + "/${source}"; + }; + }) + (builtins.filter (item: item != "") (lib.splitString "," checkouts))); + # A source pinned in sources.json, fetched with git. gitSource = source: let entry = (lib.importJSON ./sources.json).${source}; @@ -76,20 +96,21 @@ rec { target = if args.target or null != null then args.target else spec.target; - sources = { + sources = + let + unknown = lib.subtractLists (lib.attrNames pinnedSources) (lib.attrNames checkoutSources); + in + assert unknown == [] || throw "krops.nix: checkouts: no such source: ${lib.concatStringsSep ", " unknown}"; + pinnedSources // checkoutSources; + + pinnedSources = { crate2nix = gitSource "crate2nix"; hrm.file = { path = toString ~/sync/src/hrm; }; mobile-nixos = lib.mkIf (lib.elem name [ "qi" ]) - (if mobile-nixos != null then { - file = { - filters = [ { type = "exclude"; pattern = ".git"; } ]; - path = mobile-nixos; - }; - } else - gitSource "mobile-nixos"); + (gitSource "mobile-nixos"); nixos-config.symlink = { target = "hrm/systems/${name}/config.nix"; }; |
