blob: a5abb3c1aadebe5732f22a45af85f7750c89063b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#!/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 '.lib.nixosSystem' | sed 's/ =.*//' | sed 's/^[ \t]*//;s/[ \t]*$//' | while read cfg; do echo " - $cfg"; done
exit 1
fi
ROOT=$1
CONFIG=$2
DERIVATION=".#nixosConfigurations.${CONFIG}.config.system.build.toplevel"
EXTRA_NIX_FLAGS="-L --accept-flake-config"
if [ "${ROOT}" = "/" ]; then
[ -f "host/${CONFIG}/hooks/pre-rebuild.sh" ] && host/${CONFIG}/hooks/pre-rebuild.sh
[ ! -f "hardware-configuration.nix" ] && nixos-generate-config --show-hardware-config > hardware-configuration.nix
git add -f hardware-configuration.nix
nom build $DERIVATION $EXTRA_NIX_FLAGS && sudo nixos-rebuild switch --flake .#${CONFIG} --upgrade-all $EXTRA_NIX_FLAGS || exit 1
#nixos-rebuild switch --flake ".#${CONFIG}" -j`nproc` --upgrade-all -L || exit 1
[ -f "host/${CONFIG}/hooks/post-rebuild.sh" ] && host/${CONFIG}/hooks/post-rebuild.sh
git rm --cached hardware-configuration.nix
exit
else
nixos-generate-config --show-hardware-config --root "${ROOT}" > hardware-configuration.nix
git add -f hardware-configuration.nix
nom build $DERIVATION $EXTRA_NIX_FLAGS || exit 1
nixos-install --root "${ROOT}" --flake ".#${CONFIG}" --no-channel-copy
git rm --cached hardware-configuration.nix
cp . "${ROOT}/Rory-Open-Architecture" -r
exit
fi
|