aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbootstrap/activate/activate.sh23
-rwxr-xr-xbootstrap/install/install.sh24
-rw-r--r--bootstrap/setup/default.nix12
-rwxr-xr-xbootstrap/setup/setup.sh37
-rw-r--r--flake.nix8
5 files changed, 60 insertions, 44 deletions
diff --git a/bootstrap/activate/activate.sh b/bootstrap/activate/activate.sh
index ea914de7..5ff9af8d 100755
--- a/bootstrap/activate/activate.sh
+++ b/bootstrap/activate/activate.sh
@@ -64,28 +64,7 @@ msg "Finished mounting"
readp "Do you want to continue with nixos-install? [N/y]: " result
case $result in
[Yy])
- msg "Great, select a host-config:"
- hosts=$(mktmp);
- host="";
-
- awk -F "." '/inputs.nixpkgs.lib.nixosSystem/{print $1}' "$(tmp 'curl https://git.sils.li/ene/nixos-config/raw/branch/prime/flake/nixosConfigurations/default.nix 2> /dev/null')" | awk '{print $1}' > $hosts;
-
- while ! grep "$host" "$hosts" > /dev/null || [ "$(printf "%s" "$host" | wc -c)" -eq 0 ]; do
- i=1;
- while read -r ho ; do
- printf "%4s) %s \n" "$i" "$ho";
- i=$((i+1));
- done < "$hosts"
- printf "%4s) Exit\n" "q"
- readp "Enter a option: " host
-
- [ "$host" = "q" ] && exit 1
- host=$(awk -v i="$host" '{if (NR==i) {print $0}}' "$hosts");
- if ! grep "$host" "$hosts" > /dev/null || [ "$(printf "%s" "$host" | wc -c)" -eq 0 ]; then
- warning "No host selected. Select a host to continue.\n"
- fi
- done
- nixos-install --flake git+https://git.sils.li/ene/nixos-config#${host} --no-root-passwd
+ nix run "git+https://git.sils.li/ene/nixos-config#setup";
;;
*)
msg "Sure, do it yourself"
diff --git a/bootstrap/install/install.sh b/bootstrap/install/install.sh
index be44cde3..ce22b8cd 100755
--- a/bootstrap/install/install.sh
+++ b/bootstrap/install/install.sh
@@ -93,31 +93,11 @@ mne persistent-storage /mnt/srv
mount --mkdir --options bind /mnt/srv/nixos-config /mnt/etc/nixos
msg "Finished mounting and generating btrfs subvolumes"
+
readp "Do you want to continue with nixos-install? [N/y]: " result
case $result in
[Yy])
- msg "Great, select a host-config:"
- hosts=$(mktmp);
- host="";
-
- awk -F "." '/inputs.nixpkgs.lib.nixosSystem/{print $1}' "$(tmp 'curl https://git.sils.li/ene/nixos-config/raw/branch/prime/flake/nixosConfigurations/default.nix 2> /dev/null')" | awk '{print $1}' > $hosts;
-
- while ! grep "$host" "$hosts" > /dev/null || [ "$(printf "%s" "$host" | wc -c)" -eq 0 ]; do
- i=1;
- while read -r ho ; do
- printf "%4s) %s \n" "$i" "$ho";
- i=$((i+1));
- done < "$hosts"
- printf "%4s) Exit\n" "q"
- readp "Enter a option: " host
-
- [ "$host" = "q" ] && exit 1
- host=$(awk -v i="$host" '{if (NR==i) {print $0}}' "$hosts");
- if ! grep "$host" "$hosts" > /dev/null || [ "$(printf "%s" "$host" | wc -c)" -eq 0 ]; then
- warning "No host selected. Select a host to continue.\n"
- fi
- done
- nixos-install --flake git+https://git.sils.li/ene/nixos-config#${host} --no-root-passwd
+ nix run "git+https://git.sils.li/ene/nixos-config#setup";
;;
*)
msg "Sure, do it yourself"
diff --git a/bootstrap/setup/default.nix b/bootstrap/setup/default.nix
new file mode 100644
index 00000000..429fe5f4
--- /dev/null
+++ b/bootstrap/setup/default.nix
@@ -0,0 +1,12 @@
+# vim: ts=2
+{
+ pkgs,
+ shell-library,
+ ...
+}: let
+ dependencies = with pkgs; [dash];
+ name = "setup";
+ script = ./setup.sh;
+ lib = import ../../lib {inherit pkgs shell-library;};
+in
+ lib.makeShellScriptWithLibrary {inherit dependencies name script;}
diff --git a/bootstrap/setup/setup.sh b/bootstrap/setup/setup.sh
new file mode 100755
index 00000000..9f102f43
--- /dev/null
+++ b/bootstrap/setup/setup.sh
@@ -0,0 +1,37 @@
+#! /usr/bin/env dash
+# shellcheck disable=SC2086
+# shellcheck source=/dev/null
+. %SHELL_LIBRARY_PATH
+export LIB_TEMP_DIR_FOR_SCRIPT="$(mktemp -d)"
+
+msg "Select a host-config:"
+hosts=$(mktmp);
+host="";
+
+awk -F "." '/inputs.nixpkgs.lib.nixosSystem/{print $1}' "$(tmp 'curl https://git.sils.li/ene/nixos-config/raw/branch/prime/flake/nixosConfigurations/default.nix 2> /dev/null')" | awk '{print $1}' > $hosts;
+
+while ! grep "$host" "$hosts" > /dev/null || [ "$(printf "%s" "$host" | wc -c)" -eq 0 ]; do
+ i=1;
+ while read -r ho ; do
+ printf "%4s) %s \n" "$i" "$ho";
+ i=$((i+1));
+ done < "$hosts"
+ printf "%4s) Exit\n" "q"
+ readp "Enter a option: " host
+
+ [ "$host" = "q" ] && exit 1
+ host=$(awk -v i="$host" '{if (NR==i) {print $0}}' "$hosts");
+ if ! grep "$host" "$hosts" > /dev/null || [ "$(printf "%s" "$host" | wc -c)" -eq 0 ]; then
+ warning "No host selected. Select a host to continue.\n"
+ fi
+done
+nixos-install --flake git+https://git.sils.li/ene/nixos-config#${host} --no-root-passwd
+
+# clone the git config
+git clone https://git.sils.li/ene/nixos-config /mnt/etc/nixos
+
+# setup persistent home dir
+mkdir -p /srv/home
+chmod 777 /srv/home
+
+if [ -d "$LIB_TEMP_DIR_FOR_SCRIPT" ];then rm -r "$LIB_TEMP_DIR_FOR_SCRIPT"; fi
diff --git a/flake.nix b/flake.nix
index 4b05e87d..5fddd222 100644
--- a/flake.nix
+++ b/flake.nix
@@ -76,6 +76,10 @@
inherit pkgs;
inherit (inputs) shell-library;
};
+ setup = import ./bootstrap/setup {
+ inherit pkgs;
+ inherit (inputs) shell-library;
+ };
};
apps."${system}" = {
@@ -87,6 +91,10 @@
type = "app";
program = "${self.packages."${system}".activate}/bin/activate";
};
+ setup = {
+ type = "app";
+ program = "${self.packages."${system}".setup}/bin/setup";
+ };
default = self.apps."${system}".activate;
};
};