summaryrefslogtreecommitdiffstats
path: root/krebs
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2015-10-27 18:12:29 +0100
committermakefu <github@syntax-fehler.de>2015-10-27 18:12:29 +0100
commita85114c59c5102b839584f72454bca2c8abbb887 (patch)
tree18fc24394171f4afae3dee0e68e3781df75723ea /krebs
parentfe4f5b98b91f6bacb036d57b5322fb4e09c22f14 (diff)
parent20ad77468131b7c69c5b3a26ea149ae7fdc0173b (diff)
Merge branch 'master' of pnp:stockholm
Diffstat (limited to 'krebs')
-rw-r--r--krebs/3modules/build.nix2
-rw-r--r--krebs/3modules/current.nix26
-rw-r--r--krebs/3modules/default.nix8
-rw-r--r--krebs/3modules/git.nix2
-rw-r--r--krebs/3modules/github-hosts-sync.nix3
-rw-r--r--krebs/3modules/lass/default.nix62
-rw-r--r--krebs/3modules/makefu/default.nix3
-rw-r--r--krebs/3modules/shared/default.nix42
-rw-r--r--krebs/3modules/tinc_graphs.nix7
-rw-r--r--krebs/3modules/tv/default.nix5
-rw-r--r--krebs/3modules/urlwatch.nix9
-rw-r--r--krebs/4lib/default.nix2
-rw-r--r--krebs/4lib/infest/finalize.sh2
-rw-r--r--krebs/4lib/infest/prepare.sh7
-rw-r--r--krebs/5pkgs/default.nix9
-rw-r--r--krebs/5pkgs/tinc_graphs/default.nix26
-rw-r--r--krebs/Zhosts/wolf10
-rw-r--r--krebs/default.nix149
18 files changed, 284 insertions, 90 deletions
diff --git a/krebs/3modules/build.nix b/krebs/3modules/build.nix
index 57495ea69..1205e192b 100644
--- a/krebs/3modules/build.nix
+++ b/krebs/3modules/build.nix
@@ -1,6 +1,6 @@
{ config, lib, ... }:
-with import ../4lib { inherit lib; };
+with lib;
let
target = config.krebs.build // { user.name = "root"; };
diff --git a/krebs/3modules/current.nix b/krebs/3modules/current.nix
new file mode 100644
index 000000000..41941e289
--- /dev/null
+++ b/krebs/3modules/current.nix
@@ -0,0 +1,26 @@
+{ config, pkgs, lib, ... }:
+
+with lib;
+
+let
+ cfg = config.krebs.current;
+
+ out = {
+ options.krebs.current = api;
+ config = mkIf cfg.enable imp;
+ };
+
+ api = {
+ enable = mkEnableOption "krebs.current";
+ host = mkOption {
+ type = types.host;
+ };
+ user = mkOption {
+ type = types.user;
+ };
+ };
+
+ imp = {
+ };
+
+in out
diff --git a/krebs/3modules/default.nix b/krebs/3modules/default.nix
index 075db1826..fd9d56ed2 100644
--- a/krebs/3modules/default.nix
+++ b/krebs/3modules/default.nix
@@ -1,6 +1,6 @@
{ config, lib, ... }:
-with import ../4lib { inherit lib; };
+with lib;
let
cfg = config.krebs;
@@ -8,6 +8,7 @@ let
imports = [
./bepasty-server.nix
./build.nix
+ ./current.nix
./exim-retiolum.nix
./exim-smarthost.nix
./github-hosts-sync.nix
@@ -76,6 +77,7 @@ let
imp = mkMerge [
{ krebs = import ./lass { inherit lib; }; }
{ krebs = import ./makefu { inherit lib; }; }
+ { krebs = import ./shared { inherit lib; }; }
{ krebs = import ./tv { inherit lib; }; }
{
krebs.dns.providers = {
@@ -105,8 +107,8 @@ let
# Implements environment.etc."zones/<zone-name>"
environment.etc = let
- stripEmptyLines = s: concatStringsSep "\n"
- (remove "\n" (remove "" (splitString "\n" s)));
+ stripEmptyLines = s: (concatStringsSep "\n"
+ (remove "\n" (remove "" (splitString "\n" s)))) + "\n";
all-zones = foldAttrs (sum: current: sum + "\n" +current ) ""
([cfg.zone-head-config] ++ combined-hosts);
combined-hosts = (mapAttrsToList (name: value: value.extraZones) cfg.hosts );
diff --git a/krebs/3modules/git.nix b/krebs/3modules/git.nix
index 64b7820b2..234129497 100644
--- a/krebs/3modules/git.nix
+++ b/krebs/3modules/git.nix
@@ -6,7 +6,7 @@
# TODO when authorized_keys changes, then restart ssh
# (or kill already connected users somehow)
-with import ../4lib { inherit lib; };
+with lib;
let
cfg = config.krebs.git;
diff --git a/krebs/3modules/github-hosts-sync.nix b/krebs/3modules/github-hosts-sync.nix
index 2a1df9e03..5503ee8d6 100644
--- a/krebs/3modules/github-hosts-sync.nix
+++ b/krebs/3modules/github-hosts-sync.nix
@@ -1,7 +1,6 @@
{ config, lib, pkgs, ... }:
-with builtins;
-with import ../4lib { inherit lib; };
+with lib;
let
cfg = config.krebs.github-hosts-sync;
diff --git a/krebs/3modules/lass/default.nix b/krebs/3modules/lass/default.nix
index afedf95f2..498282b03 100644
--- a/krebs/3modules/lass/default.nix
+++ b/krebs/3modules/lass/default.nix
@@ -1,8 +1,36 @@
{ lib, ... }:
-with import ../../4lib { inherit lib; };
+with lib;
-{
+let
+ testHosts = lib.genAttrs [
+ "test-arch"
+ "test-centos6"
+ "test-centos7"
+ ] (name: {
+ inherit name;
+ cores = 1;
+ nets = {
+ retiolum = {
+ addrs4 = ["10.243.111.111"];
+ addrs6 = ["42:0:0:0:0:0:0:7357"];
+ aliases = [
+ "test.retiolum"
+ ];
+ tinc.pubkey = ''
+ -----BEGIN RSA PUBLIC KEY-----
+ MIIBCgKCAQEAy41YKF/wpHLnN370MSdnAo63QUW30aw+6O79cnaJyxoL6ZQkk4Nd
+ mrX2tBIfb2hhhgm4Jecy33WVymoEL7EiRZ6gshJaYwte51Jnrac6IFQyiRGMqHY5
+ TG/6IzzTOkeQrT1fw3Yfh0NRfqLBZLr0nAFoqgzIVRxvy+QO1gCU2UDKkQ/y5df1
+ K+YsMipxU08dsOkPkmLdC/+vDaZiEdYljIS3Omd+ED5JmLM3MSs/ZPQ8xjkjEAy8
+ QqD9/67bDoeXyg1ZxED2n0+aRKtU/CK/66Li//yev6yv38OQSEM4t/V0dr9sjLcY
+ VIdkxKf96F9r3vcDf/9xw2HrqVoy+D5XYQIDAQAB
+ -----END RSA PUBLIC KEY-----
+ '';
+ };
+ };
+ });
+in {
hosts = addNames {
echelon = {
cores = 4;
@@ -104,7 +132,11 @@ with import ../../4lib { inherit lib; };
uriel = {
cores = 1;
dc = "lass";
- nets = rec {
+ nets = {
+ gg23 = {
+ addrs4 = ["10.23.1.12"];
+ aliases = ["uriel.gg23"];
+ };
retiolum = {
addrs4 = ["10.243.81.176"];
addrs6 = ["42:dc25:60cf:94ef:759b:d2b6:98a9:2e56"];
@@ -131,7 +163,11 @@ with import ../../4lib { inherit lib; };
mors = {
cores = 2;
dc = "lass";
- nets = rec {
+ nets = {
+ gg23 = {
+ addrs4 = ["10.23.1.11"];
+ aliases = ["mors.gg23"];
+ };
retiolum = {
addrs4 = ["10.243.0.2"];
addrs6 = ["42:0:0:0:0:0:0:dea7"];
@@ -155,8 +191,24 @@ with import ../../4lib { inherit lib; };
ssh.privkey.path = <secrets/ssh.id_ed25519>;
ssh.pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINAMPlIG+6u75GJ3kvsPF6OoIZsU+u8ZQ+rdviv5fNMD";
};
+ schnabel-ap = {
+ nets = {
+ gg23 = {
+ addrs4 = ["10.23.1.20"];
+ aliases = ["schnabel-ap.gg23"];
+ };
+ };
+ };
+ Reichsfunk-ap = {
+ nets = {
+ gg23 = {
+ addrs4 = ["10.23.1.10"];
+ aliases = ["Reichsfunk-ap.gg23"];
+ };
+ };
+ };
- };
+ } // testHosts;
users = addNames {
lass = {
pubkey = readFile ../../Zpubkeys/lass.ssh.pub;
diff --git a/krebs/3modules/makefu/default.nix b/krebs/3modules/makefu/default.nix
index bc0d389f2..e36a083f2 100644
--- a/krebs/3modules/makefu/default.nix
+++ b/krebs/3modules/makefu/default.nix
@@ -1,6 +1,6 @@
{ lib, ... }:
-with import ../../4lib { inherit lib; };
+with lib;
{
hosts = addNames {
@@ -185,6 +185,7 @@ with import ../../4lib { inherit lib; };
addrs6 = ["42:6e1e:cc8a:7cef:827:f938:8c64:baad"];
aliases = [
"graphs.wry.retiolum"
+ "graphs.retiolum"
"paste.wry.retiolum"
"paste.retiolum"
"wry.retiolum"
diff --git a/krebs/3modules/shared/default.nix b/krebs/3modules/shared/default.nix
new file mode 100644
index 000000000..24dd7b782
--- /dev/null
+++ b/krebs/3modules/shared/default.nix
@@ -0,0 +1,42 @@
+{ lib, ... }:
+
+with lib;
+
+{
+ hosts = addNames {
+ wolf = {
+ #dc = "shack";
+ nets = {
+ #shack = {
+ # addrs4 = [ TODO ];
+ # aliases = ["wolf.shack"];
+ #};
+ retiolum = {
+ addrs4 = ["10.243.77.1"];
+ addrs6 = ["42:0:0:0:0:0:77:1"];
+ aliases = [
+ "wolf.retiolum"
+ ];
+ tinc.pubkey = ''
+ -----BEGIN RSA PUBLIC KEY-----
+ MIIBCgKCAQEAzpXyEATt8+ElxPq650/fkboEC9RvTWqN6UIAl/R4Zu+uDhAZ2ekb
+ HBjoSbRxu/0w2I37nwWUhEOemxGm4PXCgWrtO0jeRF4nVNYu3ZBppA3vuVALUWq7
+ apxRUEL9FdsWQlXGo4PVd20dGaDTi8M/Ggo755MStVTY0rRLluxyPq6VAa015sNg
+ 4NOFuWm0NDn4e+qrahTCTiSjbCU8rWixm0GktV40kdg0QAiFbEcRhuXF1s9/yojk
+ 7JT/nFg6LELjWUSSNZnioj5oSfVbThDRelIld9VaAKBAZZ5/zy6T2XSeDfoepytH
+ 8aw6itEuTCy1M1DTiTG+12SPPw+ubG+NqQIDAQAB
+ -----END RSA PUBLIC KEY-----
+ '';
+ };
+ };
+ ssh.privkey.path = <secrets/ssh.id_ed25519>;
+ ssh.pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKYMXMWZIK0jjnZDM9INiYAKcwjXs2241vew54K8veCR";
+ };
+ };
+ users = addNames {
+ shared = {
+ mail = "spam@krebsco.de";
+ pubkey = "lol"; # TODO krebs.users.shared.pubkey should be unnecessary
+ };
+ };
+}
diff --git a/krebs/3modules/tinc_graphs.nix b/krebs/3modules/tinc_graphs.nix
index a6c628353..e415d20ab 100644
--- a/krebs/3modules/tinc_graphs.nix
+++ b/krebs/3modules/tinc_graphs.nix
@@ -95,8 +95,12 @@ let
ExecStartPre = pkgs.writeScript "tinc_graphs-init" ''
#!/bin/sh
+ mkdir -p "${internal_dir}" "${external_dir}"
if ! test -e "${cfg.workingDir}/internal/index.html"; then
- cp -fr "$(${pkgs.tinc_graphs}/bin/tincstats-static-dir)/internal/" "${internal_dir}"
+ cp -fr "$(${pkgs.tinc_graphs}/bin/tincstats-static-dir)/internal/." "${internal_dir}"
+ fi
+ if ! test -e "${cfg.workingDir}/external/index.html"; then
+ cp -fr "$(${pkgs.tinc_graphs}/bin/tincstats-static-dir)/external/." "${external_dir}"
fi
'';
@@ -118,7 +122,6 @@ let
users.extraUsers.tinc_graphs = {
uid = 3925439960; #genid tinc_graphs
home = "/var/spool/tinc_graphs";
- createHome = true;
};
krebs.nginx.servers = mkIf cfg.nginx.enable {
diff --git a/krebs/3modules/tv/default.nix b/krebs/3modules/tv/default.nix
index 5d5fead8f..4c295dffe 100644
--- a/krebs/3modules/tv/default.nix
+++ b/krebs/3modules/tv/default.nix
@@ -1,6 +1,6 @@
{ lib, ... }:
-with import ../../4lib { inherit lib; };
+with lib;
{
dns.providers = {
@@ -65,7 +65,7 @@ with import ../../4lib { inherit lib; };
dc = "tv"; #dc = "cac";
nets = rec {
internet = {
- addrs4 = ["104.233.84.215"];
+ addrs4 = ["104.167.114.142"];
aliases = [
"mkdir.internet"
];
@@ -231,6 +231,7 @@ with import ../../4lib { inherit lib; };
addrs6 = ["42:0:0:0:0:0:0:1337"];
aliases = [
"wu.retiolum"
+ "cgit.wu.retiolum"
];
tinc.pubkey = ''
-----BEGIN RSA PUBLIC KEY-----
diff --git a/krebs/3modules/urlwatch.nix b/krebs/3modules/urlwatch.nix
index 80d9f5e93..206bc5697 100644
--- a/krebs/3modules/urlwatch.nix
+++ b/krebs/3modules/urlwatch.nix
@@ -56,6 +56,13 @@ let
https://nixos.org/channels/nixos-unstable/git-revision
];
};
+ verbose = mkOption {
+ type = types.bool;
+ default = false;
+ description = ''
+ verbose output of urlwatch
+ '';
+ };
};
urlsFile = toFile "urls" (concatStringsSep "\n" cfg.urls);
@@ -106,7 +113,7 @@ let
cd /tmp
- urlwatch -e --urls="$urlsFile" > changes 2>&1 || :
+ urlwatch -e ${optionalString cfg.verbose "-v"} --urls="$urlsFile" > changes || :
if test -s changes; then
date=$(date -R)
diff --git a/krebs/4lib/default.nix b/krebs/4lib/default.nix
index 0a6101314..396307c22 100644
--- a/krebs/4lib/default.nix
+++ b/krebs/4lib/default.nix
@@ -3,8 +3,6 @@
with builtins;
with lib;
-builtins //
-lib //
rec {
eq = x: y: x == y;
diff --git a/krebs/4lib/infest/finalize.sh b/krebs/4lib/infest/finalize.sh
index 0039960c5..94b13e0be 100644
--- a/krebs/4lib/infest/finalize.sh
+++ b/krebs/4lib/infest/finalize.sh
@@ -3,8 +3,8 @@ set -eux
{
umount /mnt/nix
umount /mnt/root
- umount /boot || :
umount /mnt/boot
+ umount /boot || :
umount /mnt
coreutils_path=$(set +f; for i in /nix/store/*coreutils*/bin; do :; done; echo $i)
diff --git a/krebs/4lib/infest/prepare.sh b/krebs/4lib/infest/prepare.sh
index 9fbd5be86..94c9b0fb5 100644
--- a/krebs/4lib/infest/prepare.sh
+++ b/krebs/4lib/infest/prepare.sh
@@ -18,6 +18,13 @@ prepare() {(
esac
;;
esac
+ elif test -e /etc/centos-release; then
+ case $(cat /etc/centos-release) in
+ 'CentOS release 6.5 (Final)')
+ prepare_centos "$@"
+ exit
+ ;;
+ esac
fi
echo "$0 prepare: unknown OS" >&2
exit -1
diff --git a/krebs/5pkgs/default.nix b/krebs/5pkgs/default.nix
index 84fb8725b..7df7b7d3c 100644
--- a/krebs/5pkgs/default.nix
+++ b/krebs/5pkgs/default.nix
@@ -1,7 +1,6 @@
-{ pkgs, ... }:
-
-with import ../4lib { inherit (pkgs) lib; };
+{ lib, pkgs, ... }:
+with lib;
let
subdirs = mapAttrs (_: flip pkgs.callPackage {}) (subdirsOf ./.);
pkgs' = pkgs // subdirs;
@@ -55,4 +54,8 @@ subdirs // rec {
gcc -O -Wall -o "$exe" $src
strip --strip-unneeded "$exe"
'';
+
+ writeNixFromCabal = name: path: pkgs.runCommand name {} ''
+ ${pkgs.cabal2nix}/bin/cabal2nix ${path} > $out
+ '';
}
diff --git a/krebs/5pkgs/tinc_graphs/default.nix b/krebs/5pkgs/tinc_graphs/default.nix
new file mode 100644
index 000000000..e5f1e40e8
--- /dev/null
+++ b/krebs/5pkgs/tinc_graphs/default.nix
@@ -0,0 +1,26 @@
+{stdenv,fetchurl,pkgs,python3Packages, ... }:
+
+python3Packages.buildPythonPackage rec {
+ name = "tinc_graphs-${version}";
+ version = "0.3.9";
+ propagatedBuildInputs = with pkgs;[
+ python3Packages.pygeoip
+ ## ${geolite-legacy}/share/GeoIP/GeoIPCity.dat
+ ];
+ src = fetchurl {
+ url = "https://pypi.python.org/packages/source/t/tinc_graphs/tinc_graphs-${version}.tar.gz";
+ sha256 = "0hjmkiclvyjb3707285x4b8mk5aqjcvh383hvkad1h7p1n61qrfx";
+ };
+ preFixup = with pkgs;''
+ wrapProgram $out/bin/build-graphs --prefix PATH : "$out/bin"
+ wrapProgram $out/bin/all-the-graphs --prefix PATH : "${imagemagick}/bin:${graphviz}/bin:$out/bin"
+ wrapProgram $out/bin/tinc-stats2json --prefix PATH : "${tinc}/bin"
+ '';
+
+ meta = {
+ homepage = http://krebsco.de/;
+ description = "Create Graphs from Tinc Stats";
+ license = stdenv.lib.licenses.wtfpl;
+ };
+}
+
diff --git a/krebs/Zhosts/wolf b/krebs/Zhosts/wolf
new file mode 100644
index 000000000..ded8275bd
--- /dev/null
+++ b/krebs/Zhosts/wolf
@@ -0,0 +1,10 @@
+Subnet = 10.243.77.1/32
+Subnet = 42:0:0:0:0:0:77:1/128
+-----BEGIN RSA PUBLIC KEY-----
+MIIBCgKCAQEAzpXyEATt8+ElxPq650/fkboEC9RvTWqN6UIAl/R4Zu+uDhAZ2ekb
+HBjoSbRxu/0w2I37nwWUhEOemxGm4PXCgWrtO0jeRF4nVNYu3ZBppA3vuVALUWq7
+apxRUEL9FdsWQlXGo4PVd20dGaDTi8M/Ggo755MStVTY0rRLluxyPq6VAa015sNg
+4NOFuWm0NDn4e+qrahTCTiSjbCU8rWixm0GktV40kdg0QAiFbEcRhuXF1s9/yojk
+7JT/nFg6LELjWUSSNZnioj5oSfVbThDRelIld9VaAKBAZZ5/zy6T2XSeDfoepytH
+8aw6itEuTCy1M1DTiTG+12SPPw+ubG+NqQIDAQAB
+-----END RSA PUBLIC KEY-----
diff --git a/krebs/default.nix b/krebs/default.nix
index c23cf152a..31a7f7d04 100644
--- a/krebs/default.nix
+++ b/krebs/default.nix
@@ -1,14 +1,16 @@
{ current-date
, current-host-name
, current-user-name
+, lib
, stockholm
+, StrictHostKeyChecking ? "yes"
}:
let out = {
inherit deploy;
inherit infest;
inherit init;
- inherit lib;
+ inherit nixos-install;
};
deploy =
@@ -23,7 +25,7 @@ let out = {
set -efu
(${populate args})
${rootssh target ''
- ${install args}
+ ${nix-install args}
${config.krebs.build.profile}/bin/switch-to-configuration switch
''}
echo OK
@@ -39,63 +41,14 @@ let out = {
# krebs.infest
set -efu
- # XXX type -p is non-standard
- #export RSYNC_RSH; RSYNC_RSH="$(type -p ssh) \
- # -o 'HostName $ {target.host.infest.addr}' \
- # -o 'Port $ {toString target.host.infest.port}' \
- #"
- #ssh() {
- # eval "$RSYNC_RSH \"\$@\""
- #}
-
- ${lib.rootssh target ''
+ ${rootssh target ''
${builtins.readFile ./4lib/infest/prepare.sh}
${builtins.readFile ./4lib/infest/install-nix.sh}
''}
- (${lib.populate args})
-
- ${lib.rootssh target ''
- export PATH; PATH=/root/.nix-profile/bin:$PATH
-
- src=$(type -p nixos-install)
- cat_src() {
- sed < "$src" "$(
- { 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#/:'
- )"
- }
-
- # Location to insert install
- i=$(sed -n '/^echo "building the system configuration/=' "$src")
-
- {
- cat_src | sed -n "1,$i{p}"
- cat ${lib.doc (install args)}
- cat_src | sed -n "$i,\''${$i!p}"
- } > nixos-install
- chmod +x nixos-install
-
- ## Wrap inserted install into chroot.
- #nix_env=$(cat_src | sed -n '
- # s:.*\(/nix/store/[a-z0-9]*-nix-[0-9.]\+/bin/nix-env\).*:\1:p;T;q
- #')
- #echo nix-env is $nix_env
- #sed -i '
- # s:^nix-env:chroot $mountPoint '"$nix_env"':
- #' nixos-install
-
- unset SSL_CERT_FILE
- ./nixos-install
+ (${nixos-install args})
+ ${rootssh target ''
${builtins.readFile ./4lib/infest/finalize.sh}
''}
'';
@@ -135,10 +88,74 @@ let out = {
EOF
'';
- lib = import ./4lib { lib = import <nixpkgs/lib>; } // rec {
- stockholm-path = ../.;
- nspath = ns: p: stockholm-path + "/${ns}/${p}";
- };
+ nixos-install =
+ { system ? current-host-name
+ , target ? system
+ }@args: let
+ in ''
+ #! /bin/sh
+ # ${current-date} ${current-user-name}@${current-host-name}
+ # krebs.nixos-install
+ (${populate args})
+
+ ${rootssh target ''
+ export PATH; PATH=/root/.nix-profile/bin:$PATH
+
+ src=$(type -p nixos-install)
+ cat_src() {
+ sed < "$src" "$(
+ { 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#/:'
+ )"
+ }
+
+ # Location to insert `nix-install`
+ i=$(sed -n '/^echo "building the system configuration/=' "$src")
+
+ {
+ cat_src | sed -n "1,$i{p}"
+ cat ${doc (nix-install args)}
+ cat_src | sed -n "$i,\''${$i!p}"
+ } > nixos-install
+ chmod +x nixos-install
+
+ # Wrap inserted nix-install into chroot.
+ nix_env=$(cat_src | sed -n '
+ s:.*\(/nix/store/[a-z0-9]*-nix-[0-9.]\+/bin/nix-env\).*:\1:p;T;q
+ ')
+ echo "nix-env is $nix_env" >&2
+ findpkg() {(
+ name=$1
+ path=$(find /nix/store \
+ -mindepth 1 -maxdepth 1 -type d -name '*-'"$name"'-*' \
+ | head -n 1 | sed s:^/mnt::)
+ if echo "$path" | grep .; then
+ echo "$name is $path" >&2
+ else
+ echo "Error: package not found: $name" >&2
+ exit 1
+ fi
+ )}
+ cacert=$(findpkg cacert)
+ coreutils=$(findpkg coreutils)
+ cp "$cacert"/etc/ssl/certs/ca-bundle.crt /mnt/root/SSL_CERT_FILE
+ env="$coreutils/bin/env SSL_CERT_FILE=/root/SSL_CERT_FILE"
+ sed -i '
+ s:^NIX_PATH=:chroot $mountPoint '"$env"' &:
+ s:^nix-env:'"$nix_env"':
+ ' nixos-install
+
+ ./nixos-install
+ ''}
+ '';
doc = s:
let b = "EOF${builtins.hashString "sha256" s}"; in
@@ -152,7 +169,7 @@ let out = {
stockholm.users.${current-user-name}.${system}.config
or (abort "unknown system: ${system}, user: ${current-user-name}");
- install =
+ nix-install =
{ system ? current-host-name
, target ? system
}:
@@ -203,11 +220,8 @@ let out = {
current-host = config.krebs.hosts.${current-host-name};
current-user = config.krebs.users.${current-user-name};
- target-host = config.krebs.hosts.${system};
-
methods.dir = config:
let
- can-link = config.host.name == target-host.name;
can-push = config.host.name == current-host.name;
push-method = ''
rsync \
@@ -221,11 +235,11 @@ let out = {
${config.path}/ \
root@${target}:${config.target-path}
'';
- url = "file://${config.host.name}${config.path}";
in
- #if can-link then link-method else
if can-push then push-method else
- throw "cannot source ${url}";
+ let dir = "file://${config.host.name}${config.path}"; in
+ # /!\ revise this message when using more than just push-method
+ throw "No way to push ${dir} from ${current-host.name} to ${target}";
methods.git = config:
rootssh target ''
@@ -251,7 +265,10 @@ let out = {
in out;
rootssh = target: script:
- "ssh root@${target} -T ${doc ''
+ let
+ flags = "-o StrictHostKeyChecking=${StrictHostKeyChecking}";
+ in
+ "ssh ${flags} root@${target} -T ${doc ''
set -efu
${script}
''}";