From 3ac7941968e20ebaf553a7e44f8dbfb990de4eb1 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 28 Feb 2018 14:30:11 +0100 Subject: types: refactor source --- krebs/3modules/repo-sync.nix | 6 +-- lib/types.nix | 102 +++++++++++++++++++------------------------ 2 files changed, 48 insertions(+), 60 deletions(-) diff --git a/krebs/3modules/repo-sync.nix b/krebs/3modules/repo-sync.nix index b2e3aa7c5..45d9d81c3 100644 --- a/krebs/3modules/repo-sync.nix +++ b/krebs/3modules/repo-sync.nix @@ -18,10 +18,10 @@ let type = types.attrsOf (types.submodule ({ config, ... }: { options = { origin = mkOption { - type = types.git-source; + type = types.source-types.git; }; mirror = mkOption { - type = types.git-source; + type = types.source-types.git; }; }; config = { @@ -31,7 +31,7 @@ let })); }; latest = mkOption { - type = types.nullOr types.git-source; + type = types.nullOr types.source-types.git; default = null; }; timerConfig = mkOption { diff --git a/lib/types.nix b/lib/types.nix index b85794925..9ae92ea7e 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,78 @@ 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); + 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; - }; - name = mkOption { - type = pathname; # TODO relative-pathname + pass = submodule { + options = { + dir = mkOption { + type = absolute-pathname; + }; + name = mkOption { + type = pathname; # TODO relative-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 { -- cgit v1.2.3 From dd4fac0fa477c7e3da10aef705d4b1757369d11d Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 28 Feb 2018 14:15:29 +0100 Subject: populate: 2.1.0 -> 2.3.0 --- krebs/5pkgs/simple/populate/default.nix | 4 ++-- lib/types.nix | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/krebs/5pkgs/simple/populate/default.nix b/krebs/5pkgs/simple/populate/default.nix index 62e3ab216..e35423b49 100644 --- a/krebs/5pkgs/simple/populate/default.nix +++ b/krebs/5pkgs/simple/populate/default.nix @@ -16,12 +16,12 @@ in stdenv.mkDerivation rec { name = "populate"; - version = "2.1.0"; + version = "2.3.0"; src = fetchgit { url = http://cgit.ni.krebsco.de/populate; rev = "refs/tags/v${version}"; - sha256 = "0cr50y6h6nps0qgpmi01h0z9wzpv2704y5zgx2salk1grkmvcfmh"; + sha256 = "05zr132k1s3a1cc879lvhb83hax7dbfmsbrnxmh7dxjcdg3yhxd7"; }; phases = [ diff --git a/lib/types.nix b/lib/types.nix index 9ae92ea7e..1cf2d96c9 100644 --- a/lib/types.nix +++ b/lib/types.nix @@ -255,6 +255,14 @@ rec { default = null; type = nullOr source-types.pass; }; + 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; @@ -294,6 +302,13 @@ rec { }; }; }; + pipe = submodule { + options = { + command = mkOption { + type = absolute-pathname; + }; + }; + }; symlink = submodule { options = { target = mkOption { -- cgit v1.2.3 From 67969d72e137a65adba775c6219eb85ae72ccc77 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 28 Feb 2018 14:47:12 +0100 Subject: os-release: use --- jeschli/source.nix | 6 ++++++ krebs/3modules/os-release.nix | 6 +++++- krebs/5pkgs/simple/stockholm/default.nix | 2 -- krebs/source.nix | 6 ++++++ lass/source.nix | 6 ++++++ makefu/source.nix | 6 ++++++ mv/source.nix | 6 ++++++ nin/source.nix | 6 ++++++ tv/source.nix | 6 ++++++ 9 files changed, 47 insertions(+), 3 deletions(-) diff --git a/jeschli/source.nix b/jeschli/source.nix index 382dd61bc..fe1de8fd1 100644 --- a/jeschli/source.nix +++ b/jeschli/source.nix @@ -4,6 +4,11 @@ host@{ name, secure ? false, override ? {} }: let then "buildbot" else "jeschli"; _file = + "/jeschli/1systems/${name}/source.nix"; + pkgs = import { + overlays = map import [ + + ]; + }; in evalSource (toString _file) [ { @@ -17,6 +22,7 @@ in jeschli = "${getEnv "HOME"}/secrets/${name}"; }; stockholm.file = toString ; + stockholm-version.pipe = "${pkgs.stockholm}/bin/get-version"; } override ] diff --git a/krebs/3modules/os-release.nix b/krebs/3modules/os-release.nix index 0779feede..8f71a357f 100644 --- a/krebs/3modules/os-release.nix +++ b/krebs/3modules/os-release.nix @@ -5,7 +5,11 @@ let nixos-version = "${nixos-version-id} (${config.system.nixosCodeName})"; nixos-pretty-name = "NixOS ${nixos-version}"; - stockholm-version-id = maybeEnv "STOCKHOLM_VERSION" "unknown"; + stockholm-version-id = let + eval = tryEval (removeSuffix "\n" (readFile )); + in + if eval.success then eval.value else "unknown"; + stockholm-version = "${stockholm-version-id}"; stockholm-pretty-name = "stockholm ${stockholm-version}"; diff --git a/krebs/5pkgs/simple/stockholm/default.nix b/krebs/5pkgs/simple/stockholm/default.nix index 53c1ca5ba..4d15e7ac2 100644 --- a/krebs/5pkgs/simple/stockholm/default.nix +++ b/krebs/5pkgs/simple/stockholm/default.nix @@ -216,7 +216,6 @@ init.env = pkgs.writeText "init.env" /* sh */ '' export HOSTNAME="$(${pkgs.nettools}/bin/hostname)" - export STOCKHOLM_VERSION="''${STOCKHOLM_VERSION-$(${cmds.get-version})}" export quiet export system @@ -251,7 +250,6 @@ "$target_user@$target_host" -p "$target_port" \ cd "$target_path/stockholm" \; \ NIX_PATH=$(${pkgs.quote}/bin/quote "$target_path") \ - STOCKHOLM_VERSION=$(${pkgs.quote}/bin/quote "$STOCKHOLM_VERSION") \ nix-shell --run "$(${pkgs.quote}/bin/quote " ${lib.concatStringsSep " " (lib.mapAttrsToList (name: opt: /* sh */ diff --git a/krebs/source.nix b/krebs/source.nix index 73ebf135d..45507c8c3 100644 --- a/krebs/source.nix +++ b/krebs/source.nix @@ -4,6 +4,11 @@ host@{ name, secure ? false, override ? {} }: let then "buildbot" else "krebs"; _file = + "/krebs/1systems/${name}/source.nix"; + pkgs = import { + overlays = map import [ + + ]; + }; in evalSource (toString _file) [ { @@ -16,6 +21,7 @@ in }; }; stockholm.file = toString ; + stockholm-version.pipe = "${pkgs.stockholm}/bin/get-version"; nixpkgs.git = { url = https://github.com/NixOS/nixpkgs; ref = "c831224528cd6bfd49bfc2c18b9c5d9015651077"; # nixos-17.09 @ 2018-02-15 diff --git a/lass/source.nix b/lass/source.nix index e3332c5de..1d840f38f 100644 --- a/lass/source.nix +++ b/lass/source.nix @@ -4,6 +4,11 @@ host@{ name, secure ? false, override ? {} }: let then "buildbot" else "lass"; _file = + "/lass/1systems/${name}/source.nix"; + pkgs = import { + overlays = map import [ + + ]; + }; in evalSource (toString _file) [ { @@ -17,6 +22,7 @@ in }; }; stockholm.file = toString ; + stockholm-version.pipe = "${pkgs.stockholm}/bin/get-version"; } override ] diff --git a/makefu/source.nix b/makefu/source.nix index 708f0d20c..79a2c535f 100644 --- a/makefu/source.nix +++ b/makefu/source.nix @@ -13,6 +13,11 @@ let then "buildbot" else "makefu"; _file = + "/makefu/1systems/${name}/source.nix"; + pkgs = import { + overlays = map import [ + + ]; + }; # TODO: automate updating of this ref + cherry-picks ref = "51810e0"; # nixos-17.09 @ 2018-02-14 # + do_sqlite3 ruby: 55a952be5b5 @@ -42,6 +47,7 @@ in }; stockholm.file = toString ; + stockholm-version.pipe = "${pkgs.stockholm}/bin/get-version"; } (mkIf ( musnix ) { musnix.git = { diff --git a/mv/source.nix b/mv/source.nix index 5f6b2fe36..1a7b83961 100644 --- a/mv/source.nix +++ b/mv/source.nix @@ -4,6 +4,11 @@ host@{ name, override ? {} }: let then "buildbot" else "mv"; _file = + "/mv/1systems/${name}/source.nix"; + pkgs = import { + overlays = map import [ + + ]; + }; in evalSource (toString _file) [ { @@ -18,6 +23,7 @@ in mv = "/home/mv/secrets/${name}"; }; stockholm.file = toString ; + stockholm-version.pipe = "${pkgs.stockholm}/bin/get-version"; } override ] diff --git a/nin/source.nix b/nin/source.nix index ccf5e6acc..5f3bbcb33 100644 --- a/nin/source.nix +++ b/nin/source.nix @@ -4,6 +4,11 @@ host@{ name, secure ? false }: let then "buildbot" else "nin"; _file = + "/nin/1systems/${name}/source.nix"; + pkgs = import { + overlays = map import [ + + ]; + }; in evalSource (toString _file) { nixos-config.symlink = "stockholm/nin/1systems/${name}/config.nix"; @@ -12,6 +17,7 @@ in nin = "/home/nin/secrets/${name}"; }; stockholm.file = toString ; + stockholm-version.pipe = "${pkgs.stockholm}/bin/get-version"; nixpkgs.git = { url = https://github.com/nixos/nixpkgs; ref = "afe9649"; diff --git a/tv/source.nix b/tv/source.nix index b5e3f7cd7..e5e5e0413 100644 --- a/tv/source.nix +++ b/tv/source.nix @@ -6,6 +6,11 @@ with import ; }@host: let builder = if dummy_secrets then "buildbot" else "tv"; _file = + "/tv/1systems/${name}/source.nix"; + pkgs = import { + overlays = map import [ + + ]; + }; in evalSource (toString _file) [ { @@ -20,6 +25,7 @@ in tv = "/home/tv/secrets/${name}"; }; stockholm.file = toString ; + stockholm-version.pipe = "${pkgs.stockholm}/bin/get-version"; } (mkIf (builder == "tv") { secrets-common.file = "/home/tv/secrets/common"; -- cgit v1.2.3 From 877b4104370c1ea9698a449e376e2842d7c372fd Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 28 Feb 2018 15:11:43 +0100 Subject: urlwatch: 2.7 -> 2.8 --- krebs/5pkgs/simple/urlwatch/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/krebs/5pkgs/simple/urlwatch/default.nix b/krebs/5pkgs/simple/urlwatch/default.nix index ebf872568..64f3ad1ac 100644 --- a/krebs/5pkgs/simple/urlwatch/default.nix +++ b/krebs/5pkgs/simple/urlwatch/default.nix @@ -2,13 +2,13 @@ python3Packages.buildPythonApplication rec { name = "urlwatch-${version}"; - version = "2.7"; + version = "2.8"; src = fetchFromGitHub { owner = "thp"; repo = "urlwatch"; rev = version; - sha256 = "0fx964z73yv08b1lpymmjsigf6929zx9ax5bp34rcf2c5gk11l5m"; + sha256 = "1nja7n6pc45azd3l1xyvav89855lvcgwabrvf34rps81dbl8cnl4"; }; propagatedBuildInputs = with python3Packages; [ -- cgit v1.2.3 From 2934d4524bcbae13043d684a27597c8b08c0851b Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 28 Feb 2018 22:38:42 +0100 Subject: tv gitrepos: add kops --- tv/2configs/gitrepos.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tv/2configs/gitrepos.nix b/tv/2configs/gitrepos.nix index dc50be4f1..c3418e7ee 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"; -- cgit v1.2.3