feat: flesh out nix tasks

This commit is contained in:
Truxnell 2024-03-25 17:06:14 +11:00
parent 3416303a07
commit 787fd6fee2

View file

@ -5,16 +5,14 @@ vars:
host: $HOSTNAME host: $HOSTNAME
tasks: tasks:
apply: switch:
desc: Build and apply nix configuration desc: Build and apply nix configuration
silent: true silent: true
requires: requires:
vars: vars:
- host - host
cmds: cmds:
- task: build - echo "This will switch your config."
vars:
host: "{{ .host }}"
- task: .prompt_to_continue - task: .prompt_to_continue
- sudo nixos-rebuild switch --flake "{{.ROOT_DIR}}/#{{.host}}" --impure - sudo nixos-rebuild switch --flake "{{.ROOT_DIR}}/#{{.host}}" --impure
preconditions: preconditions:
@ -23,6 +21,38 @@ tasks:
- sh: which nixos-rebuild - sh: which nixos-rebuild
msg: "nixos-rebuild not found" msg: "nixos-rebuild not found"
test:
desc: Build and apply nix configuration
silent: true
requires:
vars:
- host
cmds:
- echo "This will test your config."
- task: .prompt_to_continue
- sudo nixos-rebuild test --flake "{{.ROOT_DIR}}/#{{.host}}" --impure
preconditions:
- sh: which nix
msg: "nix not found"
- sh: which nixos-rebuild
msg: "nixos-rebuild not found"
dry-run:
desc: Build and apply nix configuration
silent: true
requires:
vars:
- host
cmds:
- echo "This will dry-run your config."
- nixos-rebuild dry-run --flake "{{.ROOT_DIR}}/#{{.host}}" --impure
preconditions:
- sh: which nix
msg: "nix not found"
- sh: which nixos-rebuild
msg: "nixos-rebuild not found"
build: build:
desc: Build nix configuration desc: Build nix configuration
silent: true silent: true
@ -31,7 +61,6 @@ tasks:
- host - host
cmds: cmds:
- nixos-rebuild build --flake "{{.ROOT_DIR}}/#{{.host}}" --impure - nixos-rebuild build --flake "{{.ROOT_DIR}}/#{{.host}}" --impure
- nvd diff /run/current-system result
preconditions: preconditions:
- sh: which nix - sh: which nix
msg: "nix not found" msg: "nix not found"