diff --git a/0make/tv/nomic.makefile b/0make/tv/nomic.makefile index 4ae1ccd10..9e0b8671b 100644 --- a/0make/tv/nomic.makefile +++ b/0make/tv/nomic.makefile @@ -1,4 +1,4 @@ deploy_host := root@nomic.gg23 nixpkgs_url := https://github.com/NixOS/nixpkgs -nixpkgs_rev := 6ad8fab785695d04a6925e8b3464ca7c71a85c3f +nixpkgs_rev := 9d5508d85c33b8fb22d79dde6176792eac2c2696 secrets_dir := /home/tv/secrets/nomic diff --git a/1systems/tv/cd.nix b/1systems/tv/cd.nix index c0c41e96c..6913508b5 100644 --- a/1systems/tv/cd.nix +++ b/1systems/tv/cd.nix @@ -7,6 +7,8 @@ let in { + krebs.build.host = config.krebs.hosts.cd; + imports = [ ../../2configs/tv/CAC-Developer-2.nix ../../2configs/tv/CAC-CentOS-7-64bit.nix @@ -32,10 +34,6 @@ in tv.iptables.input-internet-accept-new-tcp = singleton config.krebs.github-hosts-sync.port; } - { - imports = [ ../../2configs/tv/identity.nix ]; - tv.identity.self = config.krebs.hosts.cd; - } { tv.iptables = { enable = true; @@ -86,7 +84,6 @@ in } ]; - networking.hostName = "cd"; networking.interfaces.enp2s1.ip4 = [ { address = "162.219.7.216"; @@ -122,8 +119,8 @@ in home = "/home/mv"; createHome = true; useDefaultShell = true; - openssh.authorizedKeys.keys = map readFile [ - ../../Zpubkeys/mv_vod.ssh.pub + openssh.authorizedKeys.keys = [ + config.krebs.users.mv.pubkey ]; }; }; diff --git a/1systems/tv/mkdir.nix b/1systems/tv/mkdir.nix index 113fc9596..7542ad0ce 100644 --- a/1systems/tv/mkdir.nix +++ b/1systems/tv/mkdir.nix @@ -3,6 +3,8 @@ with lib; { + krebs.build.host = config.krebs.hosts.mkdir; + imports = [ ../../2configs/tv/CAC-Developer-1.nix ../../2configs/tv/CAC-CentOS-7-64bit.nix @@ -10,10 +12,6 @@ with lib; ../../2configs/tv/consul-server.nix ../../2configs/tv/exim-smarthost.nix ../../2configs/tv/git.nix - { - imports = [ ../../2configs/tv/identity.nix ]; - tv.identity.self = config.krebs.hosts.mkdir; - } { tv.iptables = { enable = true; @@ -40,7 +38,6 @@ with lib; } ]; - networking.hostName = "mkdir"; networking.interfaces.enp2s1.ip4 = [ { address = "162.248.167.241"; # TODO diff --git a/1systems/tv/nomic.nix b/1systems/tv/nomic.nix index fc58c1698..cd6e02596 100644 --- a/1systems/tv/nomic.nix +++ b/1systems/tv/nomic.nix @@ -3,16 +3,14 @@ with lib; { + krebs.build.host = config.krebs.hosts.nomic; + imports = [ ../../2configs/tv/AO753.nix ../../2configs/tv/base.nix ../../2configs/tv/consul-server.nix ../../2configs/tv/exim-retiolum.nix ../../2configs/tv/git.nix - { - imports = [ ../../2configs/tv/identity.nix ]; - tv.identity.self = config.krebs.hosts.nomic; - } { tv.iptables = { enable = true; @@ -99,6 +97,4 @@ with lib; rxvt_unicode.terminfo tmux ]; - - networking.hostName = "nomic"; } diff --git a/1systems/tv/rmdir.nix b/1systems/tv/rmdir.nix index 15d624d1c..9233014ba 100644 --- a/1systems/tv/rmdir.nix +++ b/1systems/tv/rmdir.nix @@ -3,6 +3,8 @@ with lib; { + krebs.build.host = config.krebs.hosts.rmdir; + imports = [ ../../2configs/tv/CAC-Developer-1.nix ../../2configs/tv/CAC-CentOS-7-64bit.nix @@ -10,10 +12,6 @@ with lib; ../../2configs/tv/consul-server.nix ../../2configs/tv/exim-smarthost.nix ../../2configs/tv/git.nix - { - imports = [ ../../2configs/tv/identity.nix ]; - tv.identity.self = config.krebs.hosts.rmdir; - } { tv.iptables = { enable = true; @@ -41,7 +39,6 @@ with lib; } ]; - networking.hostName = "rmdir"; networking.interfaces.enp2s1.ip4 = [ { address = "167.88.44.94"; diff --git a/1systems/tv/wu.nix b/1systems/tv/wu.nix index 5ca64ce9e..192b65b9d 100644 --- a/1systems/tv/wu.nix +++ b/1systems/tv/wu.nix @@ -7,6 +7,8 @@ let in { + krebs.build.host = config.krebs.hosts.wu; + imports = [ ../../2configs/tv/w110er.nix ../../2configs/tv/base.nix @@ -16,10 +18,7 @@ in ../../2configs/tv/mail-client.nix ../../2configs/tv/xserver.nix ../../2configs/tv/synaptics.nix # TODO w110er if xserver is enabled - { - imports = [ ../../2configs/tv/identity.nix ]; - tv.identity.self = config.krebs.hosts.wu; - } + ../../2configs/tv/urlwatch.nix { environment.systemPackages = with pkgs; [ @@ -30,6 +29,25 @@ in Zpkgs.genid Zpkgs.hashPassword Zpkgs.lentil + (pkgs.writeScriptBin "ff" '' + #! ${pkgs.bash}/bin/bash + exec sudo -u ff -i < listset providername alias + splitByProvider = foldl (acc: alias: listset-insert (providerOf alias) alias acc) {}; + + # providerOf : alias -> providername + providerOf = alias: + tree-get (splitString "." alias) providers; + in + concatStringsSep "\n" (flatten ( + # TODO deepMap ["hosts" "nets"] (hostname: host: netname: net: + mapAttrsToList (hostname: host: + mapAttrsToList (netname: net: + let + aliases = toString (unique (longs ++ shorts)); + longs = (splitByProvider net.aliases).hosts; + shorts = map (removeSuffix ".${cfg.search-domain}") longs; + in + map (addr: "${addr} ${aliases}") net.addrs + ) host.nets + ) config.krebs.hosts + )); + } ]; lass-imp = { @@ -236,7 +293,12 @@ let }; }; users = addNames { + mv = { + mail = "mv@cd.retiolum"; + pubkey = readFile ../../Zpubkeys/mv_vod.ssh.pub; + }; tv = { + mail = "tv@wu.retiolum"; pubkey = readFile ../../Zpubkeys/tv_wu.ssh.pub; }; }; diff --git a/3modules/krebs/git.nix b/3modules/krebs/git.nix index 499d33095..604645189 100644 --- a/3modules/krebs/git.nix +++ b/3modules/krebs/git.nix @@ -72,6 +72,7 @@ let }; hooks = mkOption { type = types.attrsOf types.str; + default = {}; description = '' Repository-specific hooks. ''; diff --git a/3modules/tv/default.nix b/3modules/tv/default.nix index e267d0b9f..bb10d8261 100644 --- a/3modules/tv/default.nix +++ b/3modules/tv/default.nix @@ -4,7 +4,6 @@ _: imports = [ ./consul.nix ./ejabberd.nix - ./identity.nix ./iptables.nix ]; } diff --git a/3modules/tv/identity.nix b/3modules/tv/identity.nix deleted file mode 100644 index 9de432203..000000000 --- a/3modules/tv/identity.nix +++ /dev/null @@ -1,77 +0,0 @@ -{ config, lib, pkgs, ... }: - -with import ../../4lib/tv { inherit lib pkgs; }; -let - cfg = config.tv.identity; - - out = { - options.tv.identity = api; - config = mkIf cfg.enable imp; - }; - - api = { - enable = mkEnableOption "tv.identity"; - - self = mkOption { - type = types.host; - }; - - #others = mkOption { - # type = types.host; - # default = filterAttrs (name: _host: name != cfg.self.name) cfg.hosts; - #}; - - search = mkOption { - type = types.hostname; - }; - }; - - imp = { - networking.extraHosts = - concatStringsSep "\n" (flatten ( - # TODO deepMap ["hosts" "nets"] (hostname: host: netname: net: - mapAttrsToList (hostname: host: - mapAttrsToList (netname: net: - let - aliases = toString (unique (longs ++ shorts)); - longs = (splitByProvider net.aliases).hosts; - shorts = map (removeSuffix ".${cfg.search}") longs; - in - map (addr: "${addr} ${aliases}") net.addrs - ) host.nets - ) config.krebs.hosts - )); - }; - - # TODO move domain name providers to a dedicated module - # providers : tree label providername - providers = { - internet = "hosts"; - retiolum = "hosts"; - de.viljetic = "regfish"; - de.krebsco = "ovh"; - }; - - # splitByProvider : [alias] -> set providername [alias] - splitByProvider = foldl (acc: alias: insert (providerOf alias) alias acc) {}; - - # providerOf : alias -> providername - providerOf = alias: - tree-get (splitString "." alias) providers; - - # insert : k -> v -> set k [v] -> set k [v] - insert = name: value: set: - set // { ${name} = set.${name} or [] ++ [value]; }; - - # tree k v = set k (either v (tree k v)) - - # tree-get : [k] -> tree k v -> v - tree-get = path: x: - let - y = x.${last path}; - in - if typeOf y != "set" - then y - else tree-get (init path) y; -in -out diff --git a/4lib/krebs/default.nix b/4lib/krebs/default.nix index 0c59076b6..0c42a5de3 100644 --- a/4lib/krebs/default.nix +++ b/4lib/krebs/default.nix @@ -12,4 +12,22 @@ builtins // lib // rec { types = import ./types.nix { inherit lib; }; + + # listset k v = set k [v] + + # listset-insert : k -> v -> listset k v -> listset k v + listset-insert = name: value: set: + set // { ${name} = set.${name} or [] ++ [value]; }; + + # tree k v = set k (either v (tree k v)) + + # tree-get : [k] -> tree k v -> v + tree-get = path: x: + let + y = x.${last path}; + in + if typeOf y != "set" + then y + else tree-get (init path) y; + } diff --git a/4lib/krebs/types.nix b/4lib/krebs/types.nix index ca92c6900..3d3d75a65 100644 --- a/4lib/krebs/types.nix +++ b/4lib/krebs/types.nix @@ -83,6 +83,9 @@ types // rec { user = submodule { options = { + mail = mkOption { + type = str; # TODO retiolum mail address + }; name = mkOption { type = str; # TODO }; diff --git a/default.nix b/default.nix index 2deb7539a..49e889924 100644 --- a/default.nix +++ b/default.nix @@ -2,19 +2,19 @@ let - eval = import { + eval = import { system = builtins.currentSystem; - modules = [ + modules = [ (./1systems + "/${user-name}/${system-name}.nix") - (./3modules/krebs) - (./3modules + "/${user-name}") - ]; - }; + (./3modules/krebs) + (./3modules + "/${user-name}") + ]; + }; in { - inherit (eval) config options; + inherit (eval) config options; - system = eval.config.system.build.toplevel; + system = eval.config.system.build.toplevel; }