1
0
Fork 0
dotfiles/home/programs/scripts/nixpkgs-switch
Daniel Kempkens 2b55805176
All checks were successful
Build / build-amd64-linux (push) Successful in 28s
Build / build-arm64-linux (push) Successful in 57s
all: switch back to deploy-rs
2024-07-23 22:03:30 +02:00

55 lines
1.3 KiB
Fish
Executable file

#!/usr/bin/env fish
set -f nix_os (uname)
set -f nix_hostname (hostname -s)
set -f other_hostname $argv[1]
switch $nix_os
case Darwin
set -f config_dir "$HOME/.config/nixpkgs"
case Linux
set -f config_dir /etc/nixos
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
if test "$other_hostname" = ""
switch $nix_os
case Darwin
git pull
nom build ".#darwinConfigurations.$nix_hostname.config.system.build.toplevel"
if test $status -eq 0
env TERM=xterm-256color darwin-rebuild switch --flake ".#$nix_hostname"
end
case Linux
sudo git pull
sudo nixos-rebuild switch --flake .
end
else
git pull
nom build --eval-store auto --store "ssh-ng://$other_hostname.ts.kempkens.network" ".#nixosConfigurations.$other_hostname.config.system.build.toplevel"
if test $status -eq 0
deploy --skip-checks ".#$other_hostname"
end
end
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
rm -f result
popd