1
0
Fork 0
dotfiles/home/programs/scripts/nixpkgs-switch

56 lines
1.4 KiB
Text
Raw Normal View History

2022-08-02 21:01:17 +02:00
#!/usr/bin/env fish
2023-06-23 20:08:22 +02:00
set -f nix_os (uname)
2023-06-24 20:19:50 +02:00
set -f other_hostname $argv[1]
2022-08-02 21:01:17 +02:00
2023-06-23 20:08:22 +02:00
switch $nix_os
2022-08-02 21:01:17 +02:00
case Darwin
2024-11-08 23:01:20 +01:00
set -f nix_hostname (scutil --get LocalHostName)
set -f config_dir "$HOME/.config/nixpkgs"
2022-08-02 21:01:17 +02:00
case Linux
2024-11-08 23:01:20 +01:00
set -f nix_hostname (hostname -s)
set -f config_dir /etc/nixos
2022-08-02 21:01:17 +02:00
case '*'
echo "Unsupported OS"
exit 1
end
pushd "$config_dir"
rm -rf result
if test -z "$DIRENV_DIR"
eval (direnv export fish 2>/dev/null)
end
2023-06-24 20:19:50 +02:00
if test "$other_hostname" = ""
switch $nix_os
case Darwin
git pull
nom build ".#darwinConfigurations.$nix_hostname.config.system.build.toplevel"
2023-06-28 20:16:02 +02:00
if test $status -eq 0
env TERM=xterm-256color darwin-rebuild switch --flake ".#$nix_hostname"
end
2023-06-24 20:19:50 +02:00
case Linux
sudo git pull
sudo nixos-rebuild switch --flake .
end
else
git pull
2024-07-24 09:54:07 +02:00
nom build --eval-store auto --store "ssh-ng://root@$other_hostname.ts.kempkens.network" ".#nixosConfigurations.$other_hostname.config.system.build.toplevel"
2024-07-23 22:03:30 +02:00
if test $status -eq 0
deploy --skip-checks ".#$other_hostname"
end
2022-08-02 21:01:17 +02:00
end
2023-06-25 19:16:26 +02:00
if test $status -eq 0
if test "$other_hostname" = ""
attic push nifoc-systems /run/current-system
else
ssh -t "$other_hostname" attic push nifoc-systems /run/current-system
end
end
2023-03-20 13:48:37 +01:00
rm -f result
2022-08-09 18:30:54 +02:00
2022-08-02 21:01:17 +02:00
popd