summary refs log tree commit diff
path: root/build.sh
diff options
context:
space:
mode:
Diffstat (limited to 'build.sh')
-rwxr-xr-xbuild.sh17
1 files changed, 9 insertions, 8 deletions
diff --git a/build.sh b/build.sh
index da5872f..27d0e11 100755
--- a/build.sh
+++ b/build.sh
@@ -1,26 +1,27 @@
-#!/usr/bin/env sh
+#!/usr/bin/env nix-shell
+#!nix-shell -i bash -p git nixos-install-tools nix-output-monitor
 if [ $# -ne 2 ]; then
     echo "Usage: $0 <root> <config>"
     echo "NOTE: hardware config will be generated from root!"
     echo "Defined configs:"
-    cat flake.nix | grep 'nixpkgs.lib.nixosSystem' | sed 's/ =.*//' | sed 's/^[ \t]*//;s/[ \t]*$//' | while read cfg; do echo " - $cfg"; done
+    cat flake.nix | grep '.lib.nixosSystem' | sed 's/ =.*//' | sed 's/^[ \t]*//;s/[ \t]*$//' | while read cfg; do echo " - $cfg"; done
     exit 1
 fi
 if [ "$1" = "/" ]; then
+    [ -f "host/${2}/pre-rebuild.sh" ] && host/$2/pre-rebuild.sh
     nixos-generate-config --show-hardware-config > hardware-configuration.nix
     git add -f hardware-configuration.nix
-    nixos-rebuild switch --flake ".#${2}" -j`nproc` --upgrade-all
+    nom build .#nixosConfigurations.${2}.config.system.build.toplevel && sudo nixos-rebuild switch --flake .#${HOSTNAME} || exit 1
+    nixos-rebuild switch --flake ".#${2}" -j`nproc` --upgrade-all -L || exit 1
+    [ -f "host/${2}/post-rebuild.sh" ] && host/$2/post-rebuild.sh
     git rm --cached hardware-configuration.nix
     exit
 else
     nixos-generate-config --show-hardware-config --root "${1}" > hardware-configuration.nix
     git add -f hardware-configuration.nix
-    if [ -f "flake.lock" ]; then
-        git add -f flake.lock
-    fi
+    nom build .#nixosConfigurations.${2}.config.system.build.toplevel || exit 1
     nixos-install --root "${1}" --flake ".#${2}" 
     git rm --cached hardware-configuration.nix
-    git rm --cached flake.lock
-    cp . "${1}/Spacebar-Open-Architecture" -r
+    cp . "${1}/Rory-Open-Architecture" -r
     exit
 fi