nixos configurations
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
871 B

4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
  1. #!/usr/bin/env bash
  2. # Change into script dir.
  3. cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null || exit
  4. nixosDir=$(pwd)
  5. # Get short hostname to work with host specific configurations.
  6. host=$(hostname -s)
  7. if [[ -n $nixHostOverride ]]; then
  8. host=$nixHostOverride
  9. fi
  10. if (( EUID==0 )); then
  11. sudoCmd="sudo -u grmrgecko"
  12. fi
  13. # Confirm host configuration is available; If not, we should not continue.
  14. if ! grep -q "nixosConfigurations.$host " flake.nix; then
  15. host="default"
  16. fi
  17. # Update nixpkgs.
  18. if ! $sudoCmd nix flake update "$nixosDir"; then
  19. echo "Update failed"
  20. exit 1
  21. fi
  22. # Add updated lock file to git staging for rebuild below.
  23. $sudoCmd git add flake.lock
  24. # Commit update.
  25. $sudoCmd git commit -m "Flake update $(date)"
  26. # Rebuild and switch.
  27. # shellcheck disable=SC2068
  28. sudo nixos-rebuild switch --impure --flake "path:$nixosDir/#$host" $@