diff options
author | lassulus <lassulus@lassul.us> | 2018-03-06 20:21:02 +0100 |
---|---|---|
committer | lassulus <lassulus@lassul.us> | 2018-03-06 20:21:02 +0100 |
commit | 27e3b79bc00fe5724864066b7ce7cf1945f5e75d (patch) | |
tree | 6342ba296dfd82063af204c26c2005351810d758 | |
parent | e00bacc232833cd39bdde33ef01f2189224929ad (diff) | |
parent | d450e63fd61a31e3b34da38f48260e1bfbb013cc (diff) |
Merge remote-tracking branch 'prism/tv'
-rw-r--r-- | jeschli/source.nix | 6 | ||||
-rw-r--r-- | lib/types.nix | 115 | ||||
-rw-r--r-- | mv/source.nix | 6 | ||||
-rw-r--r-- | nin/source.nix | 5 | ||||
-rw-r--r-- | tv/2configs/gitrepos.nix | 3 | ||||
-rw-r--r-- | tv/source.nix | 6 |
6 files changed, 85 insertions, 56 deletions
diff --git a/jeschli/source.nix b/jeschli/source.nix index 382dd61..fe1de8f 100644 --- a/jeschli/source.nix +++ b/jeschli/source.nix @@ -4,6 +4,11 @@ host@{ name, secure ? false, override ? {} }: let then "buildbot" else "jeschli"; _file = <stockholm> + "/jeschli/1systems/${name}/source.nix"; + pkgs = import <nixpkgs> { + overlays = map import [ + <stockholm/krebs/5pkgs> + ]; + }; in evalSource (toString _file) [ { @@ -17,6 +22,7 @@ in jeschli = "${getEnv "HOME"}/secrets/${name}"; }; stockholm.file = toString <stockholm>; + stockholm-version.pipe = "${pkgs.stockholm}/bin/get-version"; } override ] diff --git a/lib/types.nix b/lib/types.nix index b857949..1cf2d96 100644 --- a/lib/types.nix +++ b/lib/types.nix @@ -2,7 +2,7 @@ let inherit (lib) - all any concatMapStringsSep concatStringsSep const filter flip + all any attrNames concatMapStringsSep concatStringsSep const filter flip genid hasSuffix head isInt isString length mergeOneOption mkOption mkOptionType optional optionalAttrs optionals range splitString stringLength substring test testString typeOf; @@ -231,90 +231,93 @@ rec { source = submodule ({ config, ... }: { options = { type = let - types = [ - "file" - "git" - "pass" - "symlink" - ]; + known-types = attrNames source-types; + type-candidates = filter (k: config.${k} != null) known-types; in mkOption { - type = enum types; - default = let - cands = filter (k: config.${k} != null) types; - in - if length cands == 1 - then head cands - else throw "cannot determine type"; - }; - file = let - file-path = (file-source.getSubOptions "FIXME").path.type; - in mkOption { - type = nullOr (either file-source file-path); - default = null; + default = if length type-candidates == 1 + then head type-candidates + else throw "cannot determine type"; + type = enum known-types; + }; + file = mkOption { apply = x: - if file-path.check x + if absolute-pathname.check x then { path = x; } else x; + default = null; + type = nullOr (either absolute-pathname source-types.file); }; git = mkOption { - type = nullOr git-source; default = null; + type = nullOr source-types.git; }; pass = mkOption { - type = nullOr pass-source; default = null; + type = nullOr source-types.pass; }; - symlink = let - symlink-target = (symlink-source.getSubOptions "FIXME").target.type; - in mkOption { - type = nullOr (either symlink-source symlink-target); + pipe = mkOption { + apply = x: + if absolute-pathname.check x + then { command = x; } + else x; + default = null; + type = nullOr (either absolute-pathname source-types.pipe); + }; + symlink = mkOption { + type = nullOr (either pathname source-types.symlink); default = null; apply = x: - if symlink-target.check x + if pathname.check x then { target = x; } else x; }; }; }); - file-source = submodule { - options = { - path = mkOption { - type = absolute-pathname; + source-types = { + file = submodule { + options = { + path = mkOption { + type = absolute-pathname; + }; }; }; - }; - - git-source = submodule { - options = { - ref = mkOption { - type = str; # TODO types.git.ref - }; - url = mkOption { - type = str; # TODO types.git.url + git = submodule { + options = { + ref = mkOption { + type = str; # TODO types.git.ref + }; + url = mkOption { + type = str; # TODO types.git.url + }; }; }; - }; - - pass-source = submodule { - options = { - dir = mkOption { - type = absolute-pathname; + pass = submodule { + options = { + dir = mkOption { + type = absolute-pathname; + }; + name = mkOption { + type = pathname; # TODO relative-pathname + }; }; - name = mkOption { - type = pathname; # TODO relative-pathname + }; + pipe = submodule { + options = { + command = mkOption { + type = absolute-pathname; + }; }; }; - }; - - symlink-source = submodule { - options = { - target = mkOption { - type = pathname; # TODO relative-pathname + symlink = submodule { + options = { + target = mkOption { + type = pathname; # TODO relative-pathname + }; }; }; - }; + }; suffixed-str = suffs: mkOptionType { diff --git a/mv/source.nix b/mv/source.nix index 5f6b2fe..1a7b839 100644 --- a/mv/source.nix +++ b/mv/source.nix @@ -4,6 +4,11 @@ host@{ name, override ? {} }: let then "buildbot" else "mv"; _file = <stockholm> + "/mv/1systems/${name}/source.nix"; + pkgs = import <nixpkgs> { + overlays = map import [ + <stockholm/krebs/5pkgs> + ]; + }; in evalSource (toString _file) [ { @@ -18,6 +23,7 @@ in mv = "/home/mv/secrets/${name}"; }; stockholm.file = toString <stockholm>; + stockholm-version.pipe = "${pkgs.stockholm}/bin/get-version"; } override ] diff --git a/nin/source.nix b/nin/source.nix index ce18793..5b2caec 100644 --- a/nin/source.nix +++ b/nin/source.nix @@ -4,6 +4,11 @@ host@{ name, secure ? false }: let then "buildbot" else "nin"; _file = <stockholm> + "/nin/1systems/${name}/source.nix"; + pkgs = import <nixpkgs> { + overlays = map import [ + <stockholm/krebs/5pkgs> + ]; + }; in evalSource (toString _file) { nixos-config.symlink = "stockholm/nin/1systems/${name}/config.nix"; diff --git a/tv/2configs/gitrepos.nix b/tv/2configs/gitrepos.nix index dc50be4..c3418e7 100644 --- a/tv/2configs/gitrepos.nix +++ b/tv/2configs/gitrepos.nix @@ -42,6 +42,9 @@ let { kirk = { cgit.desc = "IRC tools"; }; + kops = { + cgit.desc = "deployment tools"; + }; load-env = {}; loldns = { cgit.desc = "toy DNS server"; diff --git a/tv/source.nix b/tv/source.nix index b5e3f7c..e5e5e04 100644 --- a/tv/source.nix +++ b/tv/source.nix @@ -6,6 +6,11 @@ with import <stockholm/lib>; }@host: let builder = if dummy_secrets then "buildbot" else "tv"; _file = <stockholm> + "/tv/1systems/${name}/source.nix"; + pkgs = import <nixpkgs> { + overlays = map import [ + <stockholm/krebs/5pkgs> + ]; + }; in evalSource (toString _file) [ { @@ -20,6 +25,7 @@ in tv = "/home/tv/secrets/${name}"; }; stockholm.file = toString <stockholm>; + stockholm-version.pipe = "${pkgs.stockholm}/bin/get-version"; } (mkIf (builder == "tv") { secrets-common.file = "/home/tv/secrets/common"; |