nixos-config/justfile

52 lines
1.4 KiB
Makefile
Raw Normal View History

beleth-host := "root@88.99.90.90"
2024-07-01 16:08:13 +02:00
beleth-user-host:= "xqtc@88.99.90.90"
2024-07-01 20:36:17 +02:00
default:
@just --choose
rebuild:
2024-07-01 20:36:17 +02:00
#!/usr/bin/env bash
set -euxo pipefail
2024-07-01 20:36:17 +02:00
HOSTNAME=$(hostname)
if [ $HOSTNAME == "alastor" ]; then
nh os switch . -- -vv --impure -j 4;
exit
fi
2024-07-01 20:45:31 +02:00
nh os switch . -- -vv;
2024-07-01 20:36:17 +02:00
beleth:
2024-07-01 20:45:31 +02:00
#!/usr/bin/env bash
set -euxo pipefail
2024-07-01 20:45:31 +02:00
arch=$(nix-instantiate --eval -E 'builtins.currentSystem')
arch_sanitized=$(echo $arch | sed 's/^"//;s/"$//')
if [ $arch_sanitized == "x86_64-linux" ]; then
nixos-rebuild switch --flake '.#beleth' --build-host {{beleth-host}} --target-host {{beleth-host}};
ssh {{beleth-user-host}} "cd; cd nixos-config; git pull; cd; sh build_website.sh";
exit
fi
@echo "Host arch needs to be 'x86_64-linux'! Aborting...";
update:
nix flake update
test target="":
#!/usr/bin/env bash
set -euo pipefail
target={{target}}
configurations=$(nix flake show --json --all-systems --quiet | nix run nixpkgs#jq -- -r '.nixosConfigurations | keys[]')
if [ "$target" == "" ]; then
nix flake check;
exit
fi
for config in $configurations; do
if [ "$config" == "$target" ]; then
nix build .#nixosConfigurations.{{target}}.config.system.build.toplevel --dry-run --quiet &> /dev/null
echo "Target {{target}}'s configuration is valid!";
exit
fi
done
echo "Target '$target' does not exist in the NixOS configurations."