From 70dd9300e091c76dd9ee67d1c392757220a282d4 Mon Sep 17 00:00:00 2001 From: Jackson Terrill Date: Fri, 20 Sep 2024 00:49:03 -0400 Subject: [PATCH] Move Task scripts to Nix scripts --- backend/taskfile.yaml | 42 ------ flake.lock | 315 +++++++++++++++++++++++++++++++++++------ frontend/taskfile.yaml | 1 - nix_modules/devenv.nix | 49 ++++++- taskfile.yaml | 11 -- 5 files changed, 313 insertions(+), 105 deletions(-) delete mode 100644 backend/taskfile.yaml delete mode 100644 frontend/taskfile.yaml delete mode 100644 taskfile.yaml diff --git a/backend/taskfile.yaml b/backend/taskfile.yaml deleted file mode 100644 index 1c9ae094..00000000 --- a/backend/taskfile.yaml +++ /dev/null @@ -1,42 +0,0 @@ ---- -version: "3" - -tasks: - run: - deps: - - build - summary: Runs the backend server - cmds: - - ./server - watch: - summary: Watch for changes to the backend server and rebuild. (Make sure watchexec is installed) - cmds: - - watchexec -r -e go -- task run - build: - summary: Build backend executables - sources: - - ./**/*.go - generates: - - server - cmds: - - go mod download - - go build -o server ./cmd/server - clean: - summary: Delete build files - cmds: - - rm -f server - test: - summary: Run backend tests - cmds: - - go test ./... - lint: - summary: Run lint checks - cmds: - - golangci-lint run ./... - check: - summary: Run static analysis checks - cmds: - - golangci-lint run ./... - - go mod tidy - - go fmt ./... - - go vet ./... diff --git a/flake.lock b/flake.lock index f69d46d8..2188fc36 100644 --- a/flake.lock +++ b/flake.lock @@ -38,14 +38,53 @@ "devenv", "flake-compat" ], + "git-hooks": [ + "env-help", + "devenv", + "pre-commit-hooks" + ], "nixpkgs": [ "env-help", "devenv", "nixpkgs" + ] + }, + "locked": { + "lastModified": 1724232775, + "narHash": "sha256-6u2DycIEgrgNYlLxyGqdFVmBNiKIitnQKJ1pbRP5oko=", + "owner": "cachix", + "repo": "cachix", + "rev": "03b6cb3f953097bff378fb8b9ea094bd091a4ec7", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "cachix", + "type": "github" + } + }, + "cachix_3": { + "inputs": { + "devenv": "devenv_5", + "flake-compat": [ + "env-help", + "devenv", + "cachix", + "devenv", + "flake-compat" + ], + "nixpkgs": [ + "env-help", + "devenv", + "cachix", + "devenv", + "nixpkgs" ], "pre-commit-hooks": [ "env-help", "devenv", + "cachix", + "devenv", "pre-commit-hooks" ] }, @@ -122,19 +161,19 @@ "inputs": { "cachix": "cachix_2", "flake-compat": "flake-compat_4", - "nix": "nix_4", + "nix": "nix_5", "nixpkgs": [ "env-help", "nixpkgs" ], - "pre-commit-hooks": "pre-commit-hooks_2" + "pre-commit-hooks": "pre-commit-hooks_3" }, "locked": { - "lastModified": 1725287955, - "narHash": "sha256-hnibVK/T/7+nrYrcuYAFr2Cj0vKd/kpr3ePZvm3/rGE=", + "lastModified": 1726232533, + "narHash": "sha256-rhho/HLlDkJ/d3k6oQivgCSdVz4C1LLklPtO/aBhC2I=", "owner": "cachix", "repo": "devenv", - "rev": "0ceddcb8040b72943d34af364cde79294222e1af", + "rev": "199a23e3bcfbfacaec3836d1c884918e13239b50", "type": "github" }, "original": { @@ -144,11 +183,50 @@ } }, "devenv_4": { + "inputs": { + "cachix": "cachix_3", + "flake-compat": [ + "env-help", + "devenv", + "cachix", + "flake-compat" + ], + "nix": "nix_4", + "nixpkgs": [ + "env-help", + "devenv", + "cachix", + "nixpkgs" + ], + "pre-commit-hooks": [ + "env-help", + "devenv", + "cachix", + "git-hooks" + ] + }, + "locked": { + "lastModified": 1723156315, + "narHash": "sha256-0JrfahRMJ37Rf1i0iOOn+8Z4CLvbcGNwa2ChOAVrp/8=", + "owner": "cachix", + "repo": "devenv", + "rev": "ff5eb4f2accbcda963af67f1a1159e3f6c7f5f91", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "devenv", + "type": "github" + } + }, + "devenv_5": { "inputs": { "flake-compat": [ "env-help", "devenv", "cachix", + "devenv", + "cachix", "flake-compat" ], "nix": "nix_3", @@ -158,6 +236,8 @@ "env-help", "devenv", "cachix", + "devenv", + "cachix", "pre-commit-hooks" ] }, @@ -179,17 +259,17 @@ "env-help": { "inputs": { "devenv": "devenv_3", - "flake-parts": "flake-parts", + "flake-parts": "flake-parts_2", "nixpkgs": [ "nixpkgs" ] }, "locked": { - "lastModified": 1725638272, - "narHash": "sha256-5/YF6Y3V5F1ZaT0iCi1QlwB/ICi3rP/Czm+hsFI1aBg=", + "lastModified": 1726785797, + "narHash": "sha256-JQiH4HjeQZlU6as7m2AIwsjg/+IiowuZTCUe/XEJjfo=", "owner": "jtrrll", "repo": "env-help", - "rev": "7281c52c5441e5fbc36c1e40a2ed172b180da8f2", + "rev": "6e337e12c61b74651380cf5414678a5332893896", "type": "github" }, "original": { @@ -264,14 +344,19 @@ }, "flake-parts": { "inputs": { - "nixpkgs-lib": "nixpkgs-lib" + "nixpkgs-lib": [ + "env-help", + "devenv", + "nix", + "nixpkgs" + ] }, "locked": { - "lastModified": 1725234343, - "narHash": "sha256-+ebgonl3NbiKD2UD0x4BszCZQ6sTfL4xioaM49o5B3Y=", + "lastModified": 1712014858, + "narHash": "sha256-sB4SWl2lX95bExY2gMFG5HIzvva5AVMJd4Igm+GpZNw=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "567b938d64d4b4112ee253b9274472dc3a346eb6", + "rev": "9126214d0a59633752a136528f5f3b9aa8565b7d", "type": "github" }, "original": { @@ -281,6 +366,24 @@ } }, "flake-parts_2": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1726153070, + "narHash": "sha256-HO4zgY0ekfwO5bX0QH/3kJ/h4KvUDFZg8YpkNwIbg1U=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "bcef6817a8b2aa20a5a6dbb19b43e63c5bf8619a", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-parts_3": { "inputs": { "nixpkgs-lib": "nixpkgs-lib_2" }, @@ -353,15 +456,12 @@ } }, "flake-utils_4": { - "inputs": { - "systems": "systems_4" - }, "locked": { - "lastModified": 1710146030, - "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", "owner": "numtide", "repo": "flake-utils", - "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", "type": "github" }, "original": { @@ -415,6 +515,22 @@ "type": "github" } }, + "libgit2": { + "flake": false, + "locked": { + "lastModified": 1697646580, + "narHash": "sha256-oX4Z3S9WtJlwvj0uH9HlYcWv+x1hqp8mhXl7HsLu2f0=", + "owner": "libgit2", + "repo": "libgit2", + "rev": "45fd9ed7ae1a9b74b957ef4f337bc3c8b3df01b5", + "type": "github" + }, + "original": { + "owner": "libgit2", + "repo": "libgit2", + "type": "github" + } + }, "nix": { "inputs": { "flake-compat": "flake-compat", @@ -472,6 +588,8 @@ "devenv", "cachix", "devenv", + "cachix", + "devenv", "poetry2nix", "nixpkgs" ] @@ -525,6 +643,8 @@ "devenv", "cachix", "devenv", + "cachix", + "devenv", "nixpkgs" ], "nixpkgs-regression": "nixpkgs-regression_3" @@ -549,11 +669,15 @@ "flake-compat": [ "env-help", "devenv", + "cachix", + "devenv", "flake-compat" ], "nixpkgs": [ "env-help", "devenv", + "cachix", + "devenv", "nixpkgs" ], "nixpkgs-regression": "nixpkgs-regression_4" @@ -573,6 +697,35 @@ "type": "github" } }, + "nix_5": { + "inputs": { + "flake-compat": [ + "env-help", + "devenv", + "flake-compat" + ], + "flake-parts": "flake-parts", + "libgit2": "libgit2", + "nixpkgs": "nixpkgs_3", + "nixpkgs-23-11": "nixpkgs-23-11", + "nixpkgs-regression": "nixpkgs-regression_5", + "pre-commit-hooks": "pre-commit-hooks_2" + }, + "locked": { + "lastModified": 1725980365, + "narHash": "sha256-uDwWyizzlQ0HFzrhP6rVp2+2NNA+/TM5zT32dR8GUlg=", + "owner": "domenkozar", + "repo": "nix", + "rev": "1e61e9f40673f84c3b02573145492d8af581bec5", + "type": "github" + }, + "original": { + "owner": "domenkozar", + "ref": "devenv-2.24", + "repo": "nix", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1692808169, @@ -589,6 +742,22 @@ "type": "github" } }, + "nixpkgs-23-11": { + "locked": { + "lastModified": 1717159533, + "narHash": "sha256-oamiKNfr2MS6yH64rUn99mIZjc45nGJlj9eGth/3Xuw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "a62e6edd6d5e1fa0329b8653c801147986f8d446", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "a62e6edd6d5e1fa0329b8653c801147986f8d446", + "type": "github" + } + }, "nixpkgs-lib": { "locked": { "lastModified": 1725233747, @@ -677,6 +846,22 @@ "type": "github" } }, + "nixpkgs-regression_5": { + "locked": { + "lastModified": 1643052045, + "narHash": "sha256-uGJ0VXIhWKGXxkeNnq4TvV3CIOkUJ3PAoLZ3HMzNVMw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", + "type": "github" + } + }, "nixpkgs-stable": { "locked": { "lastModified": 1710695816, @@ -695,16 +880,16 @@ }, "nixpkgs-stable_2": { "locked": { - "lastModified": 1710695816, - "narHash": "sha256-3Eh7fhEID17pv9ZxrPwCLfqXnYP006RKzSs0JptsN84=", + "lastModified": 1720386169, + "narHash": "sha256-NGKVY4PjzwAa4upkGtAMz1npHGoRzWotlSnVlqI40mo=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "614b4613980a522ba49f0d194531beddbb7220d3", + "rev": "194846768975b7ad2c4988bdb82572c00222c0d7", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-23.11", + "ref": "nixos-24.05", "repo": "nixpkgs", "type": "github" } @@ -726,6 +911,22 @@ } }, "nixpkgs_3": { + "locked": { + "lastModified": 1717432640, + "narHash": "sha256-+f9c4/ZX5MWDOuB1rKoWj+lBNm0z0rs4CK47HBLxy1o=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "88269ab3044128b7c2f4c7d68448b2fb50456870", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "release-24.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_4": { "locked": { "lastModified": 1725910328, "narHash": "sha256-n9pCtzGZ0httmTwMuEbi5E78UQ4ZbQMr1pzi5N0LAG8=", @@ -775,6 +976,8 @@ "devenv", "cachix", "devenv", + "cachix", + "devenv", "nixpkgs" ] }, @@ -825,9 +1028,48 @@ "flake-compat": [ "env-help", "devenv", - "flake-compat" + "nix" ], "flake-utils": "flake-utils_4", + "gitignore": [ + "env-help", + "devenv", + "nix" + ], + "nixpkgs": [ + "env-help", + "devenv", + "nix", + "nixpkgs" + ], + "nixpkgs-stable": [ + "env-help", + "devenv", + "nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1712897695, + "narHash": "sha256-nMirxrGteNAl9sWiOhoN5tIHyjBbVi5e2tgZUgZlK3Y=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "40e6053ecb65fcbf12863338a6dcefb3f55f1bf8", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, + "pre-commit-hooks_3": { + "inputs": { + "flake-compat": [ + "env-help", + "devenv", + "flake-compat" + ], "gitignore": "gitignore_2", "nixpkgs": [ "env-help", @@ -837,11 +1079,11 @@ "nixpkgs-stable": "nixpkgs-stable_2" }, "locked": { - "lastModified": 1713775815, - "narHash": "sha256-Wu9cdYTnGQQwtT20QQMg7jzkANKQjwBD9iccfGKkfls=", + "lastModified": 1725513492, + "narHash": "sha256-tyMUA6NgJSvvQuzB7A1Sf8+0XCHyfSPRx/b00o6K0uo=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "2ac4dcbf55ed43f3be0bae15e181f08a57af24a4", + "rev": "7570de7b9b504cfe92025dd1be797bf546f66528", "type": "github" }, "original": { @@ -854,8 +1096,8 @@ "inputs": { "devenv": "devenv", "env-help": "env-help", - "flake-parts": "flake-parts_2", - "nixpkgs": "nixpkgs_3" + "flake-parts": "flake-parts_3", + "nixpkgs": "nixpkgs_4" } }, "systems": { @@ -902,21 +1144,6 @@ "repo": "default", "type": "github" } - }, - "systems_4": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } } }, "root": "root", diff --git a/frontend/taskfile.yaml b/frontend/taskfile.yaml deleted file mode 100644 index 5db6fe96..00000000 --- a/frontend/taskfile.yaml +++ /dev/null @@ -1 +0,0 @@ -version: "3" diff --git a/nix_modules/devenv.nix b/nix_modules/devenv.nix index 460fa541..23d0cd94 100644 --- a/nix_modules/devenv.nix +++ b/nix_modules/devenv.nix @@ -11,7 +11,7 @@ enterShell = '' printf "Welcome to PLATNM\n" | ${pkgs.lolcat}/bin/lolcat printf "\033[0;1;36mDEVSHELL ACTIVATED\033[0m\n" - list-tasks + env-help ''; env-help.enable = true; @@ -26,18 +26,53 @@ }; packages = with pkgs; [ - go-task - golangci-lint nodePackages.eslint nodePackages.prettier supabase-cli - watchexec ]; scripts = { - "list-tasks".exec = '' - ${pkgs.go-task}/bin/task --list-all - ''; + "backend-lint" = { + description = "Lints backend code."; + exec = '' + cd "$DEVENV_ROOT"/backend + ${pkgs.gum}/bin/gum spin --spinner dot --title "go mod tidy" -- go mod tidy + ${pkgs.gum}/bin/gum spin --spinner dot --title "go fmt" -- go fmt ./... + ${pkgs.gum}/bin/gum spin --spinner dot --title "go vet" -- go vet ./... + ${pkgs.gum}/bin/gum spin --spinner dot --title "golangci-lint" -- ${pkgs.golangci-lint}/bin/golangci-lint run ./... + ''; + }; + "backend-run" = { + description = "Runs the backend server in development mode."; + exec = '' + cd "$DEVENV_ROOT"/backend + ${pkgs.gum}/bin/gum spin --spinner dot --title "go mod tidy" -- go mod tidy + ${pkgs.rubyPackages.dotenv}/bin/dotenv -i -f ""$DEVENV_ROOT"/.env" -- \ + ${pkgs.watchexec}/bin/watchexec -r -e go -- \ + go run cmd/server/main.go + ''; + }; + "backend-test" = { + description = "Tests backend code."; + exec = '' + cd "$DEVENV_ROOT"/backend + ${pkgs.gum}/bin/gum spin --spinner dot --title "go test" -- go test ./... + ''; + }; + "frontend-lint" = { + description = "Lints frontend code."; + exec = '' + cd "$DEVENV_ROOT"/frontend + echo "TODO" + ''; + }; + "frontend-run" = { + description = "Runs the frontend server in development mode."; + exec = '' + cd "$DEVENV_ROOT"/frontend + echo "TODO" + ''; + }; }; }; }; diff --git a/taskfile.yaml b/taskfile.yaml deleted file mode 100644 index 311b5258..00000000 --- a/taskfile.yaml +++ /dev/null @@ -1,11 +0,0 @@ -version: "3" - -dotenv: [".env"] - -includes: - backend: - taskfile: ./backend/taskfile.yaml - dir: ./backend - frontend: - taskfile: ./frontend/taskfile.yaml - dir: ./frontend