From b238e6c86054162ed90ae8490ac93930fc29bb4d Mon Sep 17 00:00:00 2001 From: truxnell <19149206+truxnell@users.noreply.github.com> Date: Sun, 17 Mar 2024 21:44:51 +1100 Subject: [PATCH] feat: add basic taskfiles --- .taskfiles/nix/Taskfile.yaml | 45 +++++++++++++++++++++++++++++++++++ .taskfiles/sops/Taskfile.yaml | 17 +++++++++++++ Taskfile.yaml | 16 +++++++++++++ 3 files changed, 78 insertions(+) create mode 100644 .taskfiles/nix/Taskfile.yaml create mode 100644 .taskfiles/sops/Taskfile.yaml create mode 100644 Taskfile.yaml diff --git a/.taskfiles/nix/Taskfile.yaml b/.taskfiles/nix/Taskfile.yaml new file mode 100644 index 0000000..46f41c8 --- /dev/null +++ b/.taskfiles/nix/Taskfile.yaml @@ -0,0 +1,45 @@ +--- +version: "3" + +vars: + host: $HOSTNAME + +tasks: + apply: + desc: Build and apply nix configuration + silent: true + requires: + vars: + - host + cmds: + - task: build + vars: + host: "{{ .host }}" + - task: .prompt_to_continue + - sudo nixos-rebuild switch --flake "{{.ROOT_DIR}}/#{{.host}}" --impure + preconditions: + - sh: which nix + msg: "nix not found" + - sh: which nixos-rebuild + msg: "nixos-rebuild not found" + + build: + desc: Build nix configuration + silent: true + requires: + vars: + - host + cmds: + - nixos-rebuild build --flake "{{.ROOT_DIR}}/#{{.host}}" --impure + - nvd diff /run/current-system result + preconditions: + - sh: which nix + msg: "nix not found" + - sh: which nixos-rebuild + msg: "nixos-rebuild not found" + - sh: which nvd + msg: "nvd not found" + + .prompt_to_continue: + internal: true + prompt: Do you want to continue applying this configuration? \ No newline at end of file diff --git a/.taskfiles/sops/Taskfile.yaml b/.taskfiles/sops/Taskfile.yaml new file mode 100644 index 0000000..115a287 --- /dev/null +++ b/.taskfiles/sops/Taskfile.yaml @@ -0,0 +1,17 @@ +--- +version: "3" + +tasks: + re-encrypt: + desc: Decrypt and re-encrypt all sops secrets + silent: true + dir: "{{.USER_WORKING_DIR}}" + vars: + SECRET_FILES: + sh: find . -type f -name '*.sops.yaml' ! -name ".sops.yaml" + cmds: + - for: { var: SECRET_FILES } + cmd: | + echo "Re-encrypting {{ .ITEM }}" + sops --decrypt --in-place "{{ .ITEM }}" + sops --encrypt --in-place "{{ .ITEM }}" diff --git a/Taskfile.yaml b/Taskfile.yaml new file mode 100644 index 0000000..5efa983 --- /dev/null +++ b/Taskfile.yaml @@ -0,0 +1,16 @@ +--- +version: "3" + +includes: + sops: + taskfile: ".taskfiles/sops" + dir: .taskfiles/sops + nix: + taskfile: ".taskfiles/nix" + dir: "{{.ROOT_DIR}}" + +tasks: + default: + silent: true + cmds: + - task -l \ No newline at end of file