diff options
Diffstat (limited to 'build.sh')
-rwxr-xr-x | build.sh | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..901d857 --- /dev/null +++ b/build.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env sh +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 + exit 1 +fi +if [ "$1" = "/" ]; then + nixos-generate-config --show-hardware-config > hardware-configuration.nix + git add -f hardware-configuration.nix + nixos-rebuild switch --flake ".#${2}" -j`nproc` --upgrade-all + 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 + nixos-install --root "${1}" --flake ".#${2}" + git rm --cached hardware-configuration.nix + cp . "${1}/Spacebar-Open-Architecture" -r + exit +fi |