From 2dee9fc6fbf99a2f43251d17e9302028b90a2ec3 Mon Sep 17 00:00:00 2001 From: Yorick Barbanneau Date: Sat, 12 Oct 2024 19:09:44 +0200 Subject: [PATCH] feat(taskfile): improve targets management --- Taskfile.dist.yaml | 53 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 40 insertions(+), 13 deletions(-) diff --git a/Taskfile.dist.yaml b/Taskfile.dist.yaml index 404f325..6980847 100644 --- a/Taskfile.dist.yaml +++ b/Taskfile.dist.yaml @@ -12,11 +12,13 @@ tasks: - task: check:sh:shellcheck - task: check:sh:shfmt check:sh:shellcheck: + desc: Pass Shellcheck on all *.sh files cmds: - find . -type f -name "*.sh" -exec shellcheck {} \; sources: - "**/*.sh" check:sh:shfmt: + desc: Pass shfmt in check mode on all sh files cmds: - find . -type f -name "*.sh" -exec shfmt -d -ln bash -i 4 {} \; sources: @@ -31,7 +33,30 @@ tasks: - nix flake check sources: - "**/*.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:*:*: desc: Manage NixOS build, use nixos:verb:target format vars: @@ -66,6 +91,16 @@ tasks: requires: 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:*:*: desc: Manage Home-Manager configuration, use home:verb:target format vars: @@ -93,21 +128,13 @@ tasks: requires: vars: [TARGET] - generation-list:nixos: - cmds: - - nixos-rebuild list-generations - - generation-list:home: + home:list-gen: + desc: List Home-Manager generations 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 + home:gc: + desc: Garbage collect Home-Manager packages cmds: - home-manager expire-generations {{.GENERATION_IN_DAYS}} - nix store gc