This repository has no description
1.5 kB
35 lines
1{ pkgs }:
2pkgs.writers.writeDashBin "install-system" ''
3 set -efux
4 SYSTEM=$1
5 TARGET=$2
6 # format
7 if ! (sshn "$TARGET" -- mountpoint /mnt); then
8 if ! (sshn "$TARGET" -- type -p nix); then
9 nix run github:numtide/nixos-remote -- --stop-after-disko --store-paths "$(nix-build --no-out-link -I stockholm="$HOME"/sync/stockholm -I nixos-config="$HOME"/sync/stockholm/lass/1systems/"$SYSTEM"/physical.nix '<nixpkgs/nixos>' -A config.system.build.diskoNoDeps)" /dev/null "$TARGET"
10 else
11 disko=$(nix-build -I stockholm=$HOME/sync/stockholm -I secrets=$HOME/sync/stockholm/lass/2configs/tests/dummy-secrets -I nixos-config=$HOME/sync/stockholm/lass/1systems/$SYSTEM/physical.nix '<nixpkgs/nixos>' -A config.system.build.disko)
12 NIX_SSHOPTS='-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' nix-copy-closure --to "$TARGET" "$disko"
13 sshn -t "$TARGET" -- "$disko"
14 fi
15 fi
16
17 # install dependencies
18 sshn "$TARGET" << SSH
19 if ! type -p git; then
20 nix-channel --update
21 nix-env -iA nixos.git
22 fi
23 SSH
24
25 # populate
26 $(nix-build --no-out-link "$HOME"/sync/stockholm/lass/krops.nix -A populate --argstr name "$SYSTEM" --argstr target "$TARGET"/mnt/var/src --arg force true)
27
28 # install
29 sshn "$TARGET" << SSH
30 NIXOS_CONFIG=/var/src/nixos-config nixos-install --no-root-password -I /mnt/var/src
31 nixos-enter -- nixos-rebuild -I /var/src switch --install-bootloader
32 umount -R /mnt
33 zpool export -fa
34 SSH
35''