From 2d1985e42006c121eac4bd915bee3e436ebcd314 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 27 Sep 2015 15:18:54 +0200 Subject: infest: don't init contents of the NixOS channel --- krebs/3modules/build/default.nix | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/krebs/3modules/build/default.nix b/krebs/3modules/build/default.nix index d6ee5c917..19f14b486 100644 --- a/krebs/3modules/build/default.nix +++ b/krebs/3modules/build/default.nix @@ -67,12 +67,16 @@ let src=$(type -p nixos-install) cat_src() { sed < "$src" "$( - sed < "$src" -n ' - /^if ! test -e "\$mountPoint\/\$NIXOS_CONFIG/,/^fi$/= - /^nixpkgs=/= - /^NIX_PATH=/,/^$/{/./=} - ' \ - | sed 's:$:s/^/#krebs#/:' + { sed < "$src" -n ' + /^if ! test -e "\$mountPoint\/\$NIXOS_CONFIG/,/^fi$/= + /^nixpkgs=/= + /^NIX_PATH=/,/^$/{/./=} + + # Disable: Copy the NixOS/Nixpkgs sources to the target as + # the initial contents of the NixOS channel. + /^srcs=/,/^ln -sfn /= + ' + } | sed 's:$:s/^/#krebs#/:' )" } -- cgit v1.2.3 From 53f93de02f412005e33fadc50dccde1a6400abe8 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 27 Sep 2015 15:19:59 +0200 Subject: krebs: no extraHosts for hosts w/o aliases --- krebs/3modules/default.nix | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/krebs/3modules/default.nix b/krebs/3modules/default.nix index 5fb129747..78834d8d5 100644 --- a/krebs/3modules/default.nix +++ b/krebs/3modules/default.nix @@ -84,13 +84,16 @@ let mapAttrsToList (hostname: host: mapAttrsToList (netname: net: let - aliases = toString (unique (longs ++ shorts)); + aliases = longs ++ shorts; providers = dns.split-by-provider net.aliases cfg.dns.providers; longs = providers.hosts; - shorts = map (removeSuffix ".${cfg.search-domain}") longs; + shorts = + map (removeSuffix ".${cfg.search-domain}") + (filter (hasSuffix ".${cfg.search-domain}") + longs); in - map (addr: "${addr} ${aliases}") net.addrs - ) host.nets + map (addr: "${addr} ${toString aliases}") net.addrs + ) (filterAttrs (name: host: host.aliases != []) host.nets) ) cfg.hosts )); -- cgit v1.2.3 From edd973f7735e7a7e9964f0ac7d75ab4ca20b80d9 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 27 Sep 2015 15:20:55 +0200 Subject: Zhosts ire: update Address --- krebs/Zhosts/ire | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/krebs/Zhosts/ire b/krebs/Zhosts/ire index 724158cb0..db4f9808c 100644 --- a/krebs/Zhosts/ire +++ b/krebs/Zhosts/ire @@ -1,4 +1,4 @@ -Address = 198.147.23.143 +Address = 198.147.22.115 Subnet = 10.243.231.66 Subnet = 42:b912:0f42:a82d:0d27:8610:e89b:490c -- cgit v1.2.3 From dc5299a07126e73b2040213cc1610f7368604213 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 27 Sep 2015 15:24:41 +0200 Subject: krebs: add hosts with ssh.pubkey to known hosts --- krebs/3modules/default.nix | 34 ++++++++++++++++++++++++++++++++++ krebs/4lib/types.nix | 34 ++++++++++++++++++++++++++++++++-- 2 files changed, 66 insertions(+), 2 deletions(-) diff --git a/krebs/3modules/default.nix b/krebs/3modules/default.nix index 78834d8d5..1501a9d49 100644 --- a/krebs/3modules/default.nix +++ b/krebs/3modules/default.nix @@ -103,6 +103,32 @@ let ([cfg.zone-head-config] ++ combined-hosts) ; combined-hosts = (mapAttrsToList (name: value: value.extraZones) cfg.hosts ); in lib.mapAttrs' (name: value: nameValuePair (("zones/" + name)) ({ text=value; })) all-zones; + + programs.ssh.knownHosts = + mapAttrs + (name: host: { + hostNames = + concatLists + (mapAttrsToList + (net-name: net: + let + aliases = shorts ++ longs; + longs = net.aliases; + shorts = + map (removeSuffix ".${cfg.search-domain}") + (filter (hasSuffix ".${cfg.search-domain}") + longs); + add-port = a: + if net.ssh.port != null + then "[${a}]:${toString net.ssh.port}" + else a; + in + aliases ++ map add-port net.addrs) + host.nets); + + publicKey = host.ssh.pubkey; + }) + (filterAttrs (_: host: host.ssh.pubkey != null) cfg.hosts); } ]; @@ -464,6 +490,7 @@ let "cgit.cd.viljetic.de" "cd.krebsco.de" ]; + ssh.port = 11423; }; retiolum = { via = internet; @@ -490,6 +517,7 @@ let ''; }; }; + ssh.pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOd/HqZIO9Trn3eycl23GZAz21HQCISaVNfNyaLSQvJ6"; }; mkdir = rec { cores = 1; @@ -522,6 +550,8 @@ let ''; }; }; + ssh.privkey = ; + ssh.pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICuShEqU0Cdm7KCaMD5x1D6mgj+cr7qoqbzFJDKoBbbw"; }; nomic = { cores = 2; @@ -547,6 +577,7 @@ let }; }; secure = true; + ssh.pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILn7C3LxAs9kUynENdRNgQs4qjrhNDfXzlHTpVJt6e09"; }; rmdir = rec { cores = 1; @@ -579,6 +610,7 @@ let ''; }; }; + ssh.pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFGniQyABsMNSFTKAxJgxZlLrWfexUt+vhZ3p2hpBl4J"; }; wu = { cores = 4; @@ -604,6 +636,7 @@ let }; }; secure = true; + ssh.pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIcJvu8JDVzObLUtlAQg9qVugthKSfitwCljuJ5liyHa"; }; xu = { cores = 4; @@ -629,6 +662,7 @@ let }; }; secure = true; + ssh.pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAID554niVFWomJjuSuQoiCdMUYrCFPpPzQuaoXXYYDxlw"; }; }; users = addNames { diff --git a/krebs/4lib/types.nix b/krebs/4lib/types.nix index dbffdf850..a7df92084 100644 --- a/krebs/4lib/types.nix +++ b/krebs/4lib/types.nix @@ -1,11 +1,12 @@ { lib, ... }: +with builtins; with lib; with types; types // rec { - host = submodule { + host = submodule ({ config, ... }: { options = { name = mkOption { type = label; @@ -46,8 +47,25 @@ types // rec { TODO define minimum requirements for secure hosts ''; }; + + ssh.pubkey = mkOption { + type = nullOr str; + default = null; + apply = x: + if x != null + then x + else trace "The option `krebs.hosts.${config.name}.ssh.pubkey' is unused." null; + }; + ssh.privkey = mkOption { + type = either path str; + apply = x: { + path = toString x; + string = x; + }.${typeOf x}; + }; + }; - }; + }); net = submodule ({ config, ... }: { options = { @@ -71,6 +89,18 @@ types // rec { aliases = mkOption { # TODO nonEmptyListOf hostname type = listOf hostname; + default = []; + }; + ssh = mkOption { + type = submodule { + options = { + port = mkOption { + type = nullOr int; + default = null; + }; + }; + }; + default = {}; }; tinc = mkOption { type = let net-config = config; in nullOr (submodule ({ config, ... }: { -- cgit v1.2.3 From 5a0d8f45c173815d3d460453956212c2ad8df3a7 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 27 Sep 2015 15:26:04 +0200 Subject: krebs tv-imp: add ire --- krebs/3modules/default.nix | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/krebs/3modules/default.nix b/krebs/3modules/default.nix index 1501a9d49..8e79cd014 100644 --- a/krebs/3modules/default.nix +++ b/krebs/3modules/default.nix @@ -553,6 +553,33 @@ let ssh.privkey = ; ssh.pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICuShEqU0Cdm7KCaMD5x1D6mgj+cr7qoqbzFJDKoBbbw"; }; + ire = { + nets = { + internet = { + addrs4 = ["198.147.22.115"]; + ssh.port = 11423; + }; + retiolum = { + addrs4 = ["10.243.231.66"]; + addrs6 = ["42:b912:0f42:a82d:0d27:8610:e89b:490c"]; + aliases = [ + "ire.retiolum" + ]; + tinc.pubkey = '' + -----BEGIN RSA PUBLIC KEY----- + MIIBCgKCAQEAwofjmP/XBf5pwsJlWklkSzI+Bo0I0B9ONc7/j+zpbmMRkwbWk4X7 + rVLt1cWvTY15ujg2u8l0o6OgEbIkc6rslkD603fv1sEAd0KOv7iKLgRpE9qfSvAt + 6YpiSv+mxEMTpH0g36OmBfOJ10uT+iHDB/FfxmgGJx//jdJADzLjjWC6ID+iGkGU + 1Sf+yHXF7HRmQ29Yak8LYVCJpGC5bQfWIMSL5lujLq4NchY2d+NZDkuvh42Ayr0K + LPflnPBQ3XnKHKtSsnFR2vaP6q+d3Opsq/kzBnAkjL26jEuFK1v7P/HhNhJoPzwu + nKKWj/W/k448ce374k5ycjvKm0c6baAC/wIDAQAB + -----END RSA PUBLIC KEY----- + ''; + ssh.port = 11423; + }; + }; + ssh.pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBaMjBJ/BfYlHjyn5CO0xzFNaQ0LPvMP3W9UlOs1OxGY"; + }; nomic = { cores = 2; dc = "tv"; #dc = "gg23"; -- cgit v1.2.3 From 18cfca4fe8d94f11c004fe72289b10c32a89ed68 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 27 Sep 2015 16:15:53 +0200 Subject: krebs: set host key for hosts with ssh.privkey --- krebs/3modules/default.nix | 8 ++++++-- krebs/4lib/types.nix | 26 ++++++++++++++++++++------ 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/krebs/3modules/default.nix b/krebs/3modules/default.nix index 8e79cd014..4a9be8676 100644 --- a/krebs/3modules/default.nix +++ b/krebs/3modules/default.nix @@ -104,7 +104,11 @@ let combined-hosts = (mapAttrsToList (name: value: value.extraZones) cfg.hosts ); in lib.mapAttrs' (name: value: nameValuePair (("zones/" + name)) ({ text=value; })) all-zones; - programs.ssh.knownHosts = + services.openssh.hostKeys = + let inherit (config.krebs.build.host.ssh) privkey; in + mkIf (privkey != null) (mkForce [privkey]); + + services.openssh.knownHosts = mapAttrs (name: host: { hostNames = @@ -550,7 +554,7 @@ let ''; }; }; - ssh.privkey = ; + ssh.privkey.path = ; ssh.pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICuShEqU0Cdm7KCaMD5x1D6mgj+cr7qoqbzFJDKoBbbw"; }; ire = { diff --git a/krebs/4lib/types.nix b/krebs/4lib/types.nix index a7df92084..0aa594fb1 100644 --- a/krebs/4lib/types.nix +++ b/krebs/4lib/types.nix @@ -57,13 +57,27 @@ types // rec { else trace "The option `krebs.hosts.${config.name}.ssh.pubkey' is unused." null; }; ssh.privkey = mkOption { - type = either path str; - apply = x: { - path = toString x; - string = x; - }.${typeOf x}; + type = nullOr (submodule { + options = { + bits = mkOption { + type = nullOr (enum ["4096"]); + default = null; + }; + path = mkOption { + type = either path str; + apply = x: { + path = toString x; + string = x; + }.${typeOf x}; + }; + type = mkOption { + type = enum ["rsa" "ed25519"]; + default = "ed25519"; + }; + }; + }); + default = null; }; - }; }); -- cgit v1.2.3 From 48e28c49e06c903c58ac1e1d7eebfba5aab73723 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 27 Sep 2015 16:17:11 +0200 Subject: krebs tv-imp: bump mkdir's addrs4 --- krebs/3modules/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/krebs/3modules/default.nix b/krebs/3modules/default.nix index 4a9be8676..e806ee10d 100644 --- a/krebs/3modules/default.nix +++ b/krebs/3modules/default.nix @@ -529,7 +529,7 @@ let infest.addr = head nets.internet.addrs4; nets = rec { internet = { - addrs4 = ["104.233.84.102"]; + addrs4 = ["104.233.84.173"]; aliases = [ "mkdir.internet" ]; -- cgit v1.2.3 From 0e069d964e89248ee3f0df72c7e6998ae1c204ff Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 27 Sep 2015 16:30:40 +0200 Subject: add krebs.build.scripts.init --- krebs/3modules/build/default.nix | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/krebs/3modules/build/default.nix b/krebs/3modules/build/default.nix index 19f14b486..993ccb702 100644 --- a/krebs/3modules/build/default.nix +++ b/krebs/3modules/build/default.nix @@ -28,6 +28,46 @@ let type = types.user; }; + options.krebs.build.scripts.init = lib.mkOption { + type = lib.types.str; + default = + let + inherit (config.krebs.build) host; + inherit (host.ssh) privkey; + in + '' + #! /bin/sh + set -efu + + hostname=${host.name} + secrets_dir=${config.krebs.build.source.dir.secrets.path} + key_type=${privkey.type} + key_file=$secrets_dir/ssh.id_$key_type + key_comment=$hostname + + if test -e "$key_file"; then + echo "Warning: privkey already exists: $key_file" >&2 + else + ssh-keygen \ + ${optionalString (privkey.bits != null) + "-b ${toString privkey.bits}"} \ + -C "$key_comment" \ + -t "$key_type" \ + -f "$key_file" \ + -N "" + rm "$key_file.pub" + fi + + pubkey=$(ssh-keygen -y -f "$key_file") + + cat<; + ssh.pubkey = $(echo $pubkey | jq -R .); + EOF + ''; + }; + options.krebs.build.scripts.deploy = lib.mkOption { type = lib.types.str; default = '' -- cgit v1.2.3 From 4946561e0ae254df8068905286204a4da517621d Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 27 Sep 2015 16:55:17 +0200 Subject: krebs.build.scripts.init: don't try to use privkey ^_^ --- krebs/3modules/build/default.nix | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/krebs/3modules/build/default.nix b/krebs/3modules/build/default.nix index 993ccb702..23bd8c8fd 100644 --- a/krebs/3modules/build/default.nix +++ b/krebs/3modules/build/default.nix @@ -33,7 +33,6 @@ let default = let inherit (config.krebs.build) host; - inherit (host.ssh) privkey; in '' #! /bin/sh @@ -41,7 +40,7 @@ let hostname=${host.name} secrets_dir=${config.krebs.build.source.dir.secrets.path} - key_type=${privkey.type} + key_type=ed25519 key_file=$secrets_dir/ssh.id_$key_type key_comment=$hostname @@ -49,8 +48,6 @@ let echo "Warning: privkey already exists: $key_file" >&2 else ssh-keygen \ - ${optionalString (privkey.bits != null) - "-b ${toString privkey.bits}"} \ -C "$key_comment" \ -t "$key_type" \ -f "$key_file" \ @@ -62,7 +59,6 @@ let cat<; ssh.pubkey = $(echo $pubkey | jq -R .); EOF ''; -- cgit v1.2.3 From 9ff5db3fd6c2d0d54096cebe5f3a7e9a95539268 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 27 Sep 2015 16:56:14 +0200 Subject: tv: cd, rmdir: add ssh.pubkey --- krebs/3modules/default.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/krebs/3modules/default.nix b/krebs/3modules/default.nix index e806ee10d..2b4a13c42 100644 --- a/krebs/3modules/default.nix +++ b/krebs/3modules/default.nix @@ -521,6 +521,7 @@ let ''; }; }; + ssh.privkey.path = ; ssh.pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOd/HqZIO9Trn3eycl23GZAz21HQCISaVNfNyaLSQvJ6"; }; mkdir = rec { @@ -641,7 +642,8 @@ let ''; }; }; - ssh.pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFGniQyABsMNSFTKAxJgxZlLrWfexUt+vhZ3p2hpBl4J"; + ssh.privkey.path = ; + ssh.pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICLuhLRmt8M5s2Edwwl9XY0KAAivzmPCEweesH5/KhR4"; }; wu = { cores = 4; -- cgit v1.2.3 From ab696f2f04d5ff511d295584802e8a64d1f4d318 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 27 Sep 2015 17:08:56 +0200 Subject: default.nix: mk-namespace only for dirs w/1systems --- default.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/default.nix b/default.nix index 64c69a2f4..1c3341ba7 100644 --- a/default.nix +++ b/default.nix @@ -11,7 +11,8 @@ let out = (lib.mapAttrs (k: v: mk-namespace (./. + "/${k}")) (lib.filterAttrs - (k: v: !lib.hasPrefix "." k && v == "directory") + (k: v: !lib.hasPrefix "." k && v == "directory" && + builtins.pathExists (./. + "/${k}/1systems")) (builtins.readDir ./.))); eval = path: import { -- cgit v1.2.3 From 678f0a872cb7ed123529ff31bab0cf22666e242e Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 28 Sep 2015 00:02:45 +0200 Subject: irc-announce: show more stuff --- tv/4lib/git.nix | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tv/4lib/git.nix b/tv/4lib/git.nix index 2b25debdc..1d025f3cc 100644 --- a/tv/4lib/git.nix +++ b/tv/4lib/git.nix @@ -157,7 +157,6 @@ let link="$cgit_endpoint/$GIT_SSH_REPO/ ($h)" ;; fast-forward|non-fast-forward) - #git diff --stat $id..$id2 link="$cgit_endpoint/$GIT_SSH_REPO/diff/?h=$h&id=$id&id2=$id2" ;; esac @@ -165,6 +164,13 @@ let #$host $GIT_SSH_REPO $ref $link message="''${message+$message }$GIT_SSH_USER $receive_mode $link" + + message=''${message+$message + }$( + git log --format='%h %ar: %s ' $id..$id2 + git diff --stat $id..$id2 + ) + done if test -n "''${message-}"; then -- cgit v1.2.3 From f1570403382453a6e54e38ec156a4cd3ce9ebb2d Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 28 Sep 2015 00:31:19 +0200 Subject: irc-announce: show diff/log range --- tv/4lib/git.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tv/4lib/git.nix b/tv/4lib/git.nix index 1d025f3cc..75d69efe1 100644 --- a/tv/4lib/git.nix +++ b/tv/4lib/git.nix @@ -167,8 +167,8 @@ let message=''${message+$message }$( - git log --format='%h %ar: %s ' $id..$id2 - git diff --stat $id..$id2 + git log --format='%h %ar: %s ' $id2..$id + git diff --stat $id2..$id ) done -- cgit v1.2.3 From 22b430f1b4826c02c7d460dbabb3f2b77d286d2e Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 28 Sep 2015 00:39:45 +0200 Subject: irc-announce: colorize diff --stat --- tv/4lib/git.nix | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tv/4lib/git.nix b/tv/4lib/git.nix index 75d69efe1..7dbcf72b2 100644 --- a/tv/4lib/git.nix +++ b/tv/4lib/git.nix @@ -167,8 +167,18 @@ let message=''${message+$message }$( - git log --format='%h %ar: %s ' $id2..$id - git diff --stat $id2..$id + green() { printf '\x0303,99%s\x0F' "$1"; } + red() { printf '\x0304,99%s\x0F' "$1"; } + orange() { printf '\x0307,99%s\x0F' "$1"; } + gray() { printf '\x0314,99%s\x0F' "$1"; } + + git log --format="$(orange %h) %s $(gray '(%ar)')" $id2..$id + + git diff --stat $id2..$id \ + | sed ' + $!s/+/'$(green '&')'/g + $!s/-/'$(red '&')'/g + ' ) done -- cgit v1.2.3 From c88a7d3be5d9a8ee748cb8bdfac97de3277e0d5e Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 28 Sep 2015 01:02:37 +0200 Subject: irc-announce: reverse git log --- tv/4lib/git.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tv/4lib/git.nix b/tv/4lib/git.nix index 7dbcf72b2..fe6401728 100644 --- a/tv/4lib/git.nix +++ b/tv/4lib/git.nix @@ -172,7 +172,10 @@ let orange() { printf '\x0307,99%s\x0F' "$1"; } gray() { printf '\x0314,99%s\x0F' "$1"; } - git log --format="$(orange %h) %s $(gray '(%ar)')" $id2..$id + git log \ + --format="$(orange %h) %s $(gray '(%ar)')" \ + --reverse \ + $id2..$id git diff --stat $id2..$id \ | sed ' -- cgit v1.2.3