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.

32 lines
834 B

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. # Confirm host configuration is available; If not, we should not continue.
  11. if ! grep -q "nixosConfigurations.$host " flake.nix; then
  12. host="default"
  13. fi
  14. # Update nixpkgs.
  15. if ! sudo -u grmrgecko nix flake update "$nixosDir"; then
  16. echo "Update failed"
  17. exit 1
  18. fi
  19. # Add updated lock file to git staging for rebuild below.
  20. sudo -u grmrgecko git add flake.lock
  21. # Commit update.
  22. sudo -u grmrgecko git commit -m "Flake update $(date)"
  23. # Rebuild and switch.
  24. # shellcheck disable=SC2068
  25. nixos-rebuild switch --impure --flake "path:$nixosDir/#$host" $@