feat(taskfile): improve targets management
This commit is contained in:
parent
a8ce26fa90
commit
2dee9fc6fb
1 changed files with 40 additions and 13 deletions
|
@ -12,11 +12,13 @@ tasks:
|
||||||
- task: check:sh:shellcheck
|
- task: check:sh:shellcheck
|
||||||
- task: check:sh:shfmt
|
- task: check:sh:shfmt
|
||||||
check:sh:shellcheck:
|
check:sh:shellcheck:
|
||||||
|
desc: Pass Shellcheck on all *.sh files
|
||||||
cmds:
|
cmds:
|
||||||
- find . -type f -name "*.sh" -exec shellcheck {} \;
|
- find . -type f -name "*.sh" -exec shellcheck {} \;
|
||||||
sources:
|
sources:
|
||||||
- "**/*.sh"
|
- "**/*.sh"
|
||||||
check:sh:shfmt:
|
check:sh:shfmt:
|
||||||
|
desc: Pass shfmt in check mode on all sh files
|
||||||
cmds:
|
cmds:
|
||||||
- find . -type f -name "*.sh" -exec shfmt -d -ln bash -i 4 {} \;
|
- find . -type f -name "*.sh" -exec shfmt -d -ln bash -i 4 {} \;
|
||||||
sources:
|
sources:
|
||||||
|
@ -32,6 +34,29 @@ tasks:
|
||||||
sources:
|
sources:
|
||||||
- "**/*.nix"
|
- "**/*.nix"
|
||||||
|
|
||||||
|
host:*:update:
|
||||||
|
desc: Update package version then build NixOS and Home-Manager
|
||||||
|
vars:
|
||||||
|
TARGET: "{{index .MATCH 0}}"
|
||||||
|
cmds:
|
||||||
|
- nix flake update
|
||||||
|
- task: nixos:build:{{.TARGET}}
|
||||||
|
- task: home:build:{{.TARGET}}
|
||||||
|
preconditions:
|
||||||
|
- sh: '[[ -d ./hosts/{{.TARGET}} ]]'
|
||||||
|
msg: host `{{.TARGET}}` not found in `hosts/` directory
|
||||||
|
|
||||||
|
host:*:switch:
|
||||||
|
desc: Switch both Home-Manager and NixOS generations
|
||||||
|
vars:
|
||||||
|
TARGET: "{{index .MATCH 0}}"
|
||||||
|
cmds:
|
||||||
|
- task: nixos:switch:{{.TARGET}}
|
||||||
|
- task: home:switch:{{.TARGET}}
|
||||||
|
preconditions:
|
||||||
|
- sh: '[[ -d ./hosts/{{.TARGET}} ]]'
|
||||||
|
msg: host `{{.TARGET}}` not found in `hosts/` directory
|
||||||
|
|
||||||
nixos:*:*:
|
nixos:*:*:
|
||||||
desc: Manage NixOS build, use nixos:verb:target format
|
desc: Manage NixOS build, use nixos:verb:target format
|
||||||
vars:
|
vars:
|
||||||
|
@ -66,6 +91,16 @@ tasks:
|
||||||
requires:
|
requires:
|
||||||
vars: [TARGET]
|
vars: [TARGET]
|
||||||
|
|
||||||
|
nixos:list-gen:
|
||||||
|
desc: List Nixos generations
|
||||||
|
cmds:
|
||||||
|
- nixos-rebuild list-generations
|
||||||
|
|
||||||
|
nixos:gc:
|
||||||
|
desc: Garbage collect NixOS
|
||||||
|
cmds:
|
||||||
|
- doas nix-collect-garbage --delete-older-than {{.GENERATION_IN_DAYS}}
|
||||||
|
|
||||||
home:*:*:
|
home:*:*:
|
||||||
desc: Manage Home-Manager configuration, use home:verb:target format
|
desc: Manage Home-Manager configuration, use home:verb:target format
|
||||||
vars:
|
vars:
|
||||||
|
@ -93,21 +128,13 @@ tasks:
|
||||||
requires:
|
requires:
|
||||||
vars: [TARGET]
|
vars: [TARGET]
|
||||||
|
|
||||||
generation-list:nixos:
|
home:list-gen:
|
||||||
cmds:
|
desc: List Home-Manager generations
|
||||||
- nixos-rebuild list-generations
|
|
||||||
|
|
||||||
generation-list:home:
|
|
||||||
cmds:
|
cmds:
|
||||||
- home-manager generations
|
- home-manager generations
|
||||||
|
|
||||||
gc:nixos:
|
home:gc:
|
||||||
desc: Garbage collect NixOS
|
desc: Garbage collect Home-Manager packages
|
||||||
cmds:
|
|
||||||
- doas nix-collect-garbage --delete-older-than {{.GENERATION_IN_DAYS}}
|
|
||||||
|
|
||||||
gc:home:
|
|
||||||
desc: Garbage collect Home-Manager
|
|
||||||
cmds:
|
cmds:
|
||||||
- home-manager expire-generations {{.GENERATION_IN_DAYS}}
|
- home-manager expire-generations {{.GENERATION_IN_DAYS}}
|
||||||
- nix store gc
|
- nix store gc
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue