feat: improve Taskfile
This commit is contained in:
parent
44ce61ce0c
commit
7ef10b87e3
1 changed files with 80 additions and 15 deletions
|
@ -2,47 +2,112 @@
|
|||
version: "3"
|
||||
set: [errexit, pipefail, nounset]
|
||||
shopt: [globstar]
|
||||
env:
|
||||
GENERATION_IN_DAYS: 20d
|
||||
|
||||
tasks:
|
||||
check:sh:
|
||||
desc: Check SH files, will call all check:sh:* tasks
|
||||
cmds:
|
||||
- shellcheck **/*.sh
|
||||
- task: check:sh:shellcheck
|
||||
- task: check:sh:shfmt
|
||||
check:sh:shellcheck:
|
||||
cmds:
|
||||
- find . -type f -name "*.sh" -exec shellcheck {} \;
|
||||
sources:
|
||||
- "**/*.sh"
|
||||
check:sh:shfmt:
|
||||
cmds:
|
||||
- find . -type f -name "*.sh" -exec shfmt -d -ln bash -i 4 {} \;
|
||||
sources:
|
||||
- "**/*.sh"
|
||||
check:typos:
|
||||
desc: Check typos in all files
|
||||
cmds:
|
||||
- typos .
|
||||
check:flake:
|
||||
desc: Check flake
|
||||
cmds:
|
||||
- nix flake check
|
||||
sources:
|
||||
- "**/*.nix"
|
||||
|
||||
nixos:build:*:
|
||||
|
||||
nixos:*:*:
|
||||
desc: Manage NixOS build, use nixos:verb:target format
|
||||
vars:
|
||||
TARGET: "{{index .MATCH 0}}"
|
||||
VERB: "{{index .MATCH 0}}"
|
||||
TARGET: "{{index .MATCH 1}}"
|
||||
preconditions:
|
||||
- sh: '[[ {{.VERB}} = build || {{.VERB}} = test || {{.VERB}} = switch ]]'
|
||||
msg: verb must be build, test or switch
|
||||
cmds:
|
||||
- task: nixos:{{.VERB}}
|
||||
vars:
|
||||
TARGET: "{{.TARGET}}"
|
||||
|
||||
nixos:build:
|
||||
internal: true
|
||||
cmds:
|
||||
- nixos-rebuild --flake .#{{.TARGET}} build
|
||||
|
||||
nixos:switch:*:
|
||||
vars:
|
||||
TARGET: "{{index .MATCH 0}}"
|
||||
requires:
|
||||
vars: [TARGET]
|
||||
|
||||
nixos:switch:
|
||||
internal: true
|
||||
cmds:
|
||||
- doas nixos-rebuild --flake .#{{.TARGET}} switch
|
||||
requires:
|
||||
vars: [TARGET]
|
||||
|
||||
nixos:test:*:
|
||||
vars:
|
||||
TARGET: "{{index .MATCH 0}}"
|
||||
nixos:test:
|
||||
internal: true
|
||||
cmds:
|
||||
- doas nixos-rebuild --flake .#{{.TARGET}} test
|
||||
requires:
|
||||
vars: [TARGET]
|
||||
|
||||
home:*:*:
|
||||
desc: Manage Home-Manager configuration, use home:verb:target format
|
||||
vars:
|
||||
VERB: "{{index .MATCH 0}}"
|
||||
TARGET: "{{index .MATCH 1}}"
|
||||
preconditions:
|
||||
- sh: '[[ {{.VERB}} = build || {{.VERB}} = switch ]]'
|
||||
msg: verb must be build or switch
|
||||
cmds:
|
||||
- task: home:{{.VERB}}
|
||||
vars:
|
||||
TARGET: "{{.TARGET}}"
|
||||
|
||||
home:build:*:
|
||||
vars:
|
||||
TARGET: "{{index .MATCH 0}}"
|
||||
internal: true
|
||||
cmds:
|
||||
- home-manager build --flake .#{{.TARGET}}
|
||||
requires:
|
||||
vars: [TARGET]
|
||||
|
||||
home:switch:*:
|
||||
vars:
|
||||
TARGET: "{{index .MATCH 0}}"
|
||||
internal: true
|
||||
cmds:
|
||||
- home-manager switch --flake .#{{.TARGET}}
|
||||
requires:
|
||||
vars: [TARGET]
|
||||
|
||||
generation-list:nixos:
|
||||
cmds:
|
||||
- nixos-rebuild list-generations
|
||||
|
||||
generation-list:home:
|
||||
cmds:
|
||||
- home-manager generations
|
||||
|
||||
gc:nixos:
|
||||
desc: Garbage collect NixOS
|
||||
cmds:
|
||||
- doas nix-collect-garbage --delete-older-than {{.GENERATION_IN_DAYS}}
|
||||
|
||||
gc:home:
|
||||
desc: Garbage collect Home-Manager
|
||||
cmds:
|
||||
- home-manager expire-generations {{.GENERATION_IN_DAYS}}
|
||||
- nix store gc
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue