From a37ef9f5ac51ecfd7cd5a30f220aa07783da3ed6 Mon Sep 17 00:00:00 2001 From: tsandrini Date: Fri, 29 Mar 2024 12:03:10 +0100 Subject: [PATCH 1/5] feat(.envrc): update nix-direnv to version 3 --- .envrc | 6 +++--- templates/home/.envrc | 4 ++-- templates/isolated-minimal/.envrc | 4 ++-- templates/isolated/.envrc | 4 ++-- templates/main/.envrc | 4 ++-- templates/minimal/.envrc | 4 ++-- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.envrc b/.envrc index 7f1efa4..1fedf30 100644 --- a/.envrc +++ b/.envrc @@ -1,10 +1,10 @@ -if ! has nix_direnv_version || ! nix_direnv_version 2.2.1; then - source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.2.1/direnvrc" "sha256-zelF0vLbEl5uaqrfIzbgNzJWGmLzCmYAkInj/LNxvKs=" +if ! has nix_direnv_version || ! nix_direnv_version 3.0.4; then + source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.4/direnvrc" "sha256-DzlYZ33mWF/Gs8DDeyjr8mnVmQGx7ASYqA5WlxwvBG4=" fi watch_file flake.nix -if ! use flake .#dev --impure --accept-flake-config +if ! use flake .#dev --accept-flake-config then echo "devenv could not be built. The devenv environment was not loaded. Make the necessary changes to devenv.nix and hit enter to try again." >&2 fi diff --git a/templates/home/.envrc b/templates/home/.envrc index 9d7be5b..666703b 100644 --- a/templates/home/.envrc +++ b/templates/home/.envrc @@ -1,5 +1,5 @@ -if ! has nix_direnv_version || ! nix_direnv_version 2.2.1; then - source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.2.1/direnvrc" "sha256-zelF0vLbEl5uaqrfIzbgNzJWGmLzCmYAkInj/LNxvKs=" +if ! has nix_direnv_version || ! nix_direnv_version 3.0.4; then + source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.4/direnvrc" "sha256-DzlYZ33mWF/Gs8DDeyjr8mnVmQGx7ASYqA5WlxwvBG4=" fi watch_file parts/shells/dev.nix diff --git a/templates/isolated-minimal/.envrc b/templates/isolated-minimal/.envrc index c0ecc49..ace74fc 100644 --- a/templates/isolated-minimal/.envrc +++ b/templates/isolated-minimal/.envrc @@ -1,5 +1,5 @@ -if ! has nix_direnv_version || ! nix_direnv_version 2.2.1; then - source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.2.1/direnvrc" "sha256-zelF0vLbEl5uaqrfIzbgNzJWGmLzCmYAkInj/LNxvKs=" +if ! has nix_direnv_version || ! nix_direnv_version 3.0.4; then + source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.4/direnvrc" "sha256-DzlYZ33mWF/Gs8DDeyjr8mnVmQGx7ASYqA5WlxwvBG4=" fi watch_file nix/parts/shells/dev.nix diff --git a/templates/isolated/.envrc b/templates/isolated/.envrc index c0ecc49..ace74fc 100644 --- a/templates/isolated/.envrc +++ b/templates/isolated/.envrc @@ -1,5 +1,5 @@ -if ! has nix_direnv_version || ! nix_direnv_version 2.2.1; then - source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.2.1/direnvrc" "sha256-zelF0vLbEl5uaqrfIzbgNzJWGmLzCmYAkInj/LNxvKs=" +if ! has nix_direnv_version || ! nix_direnv_version 3.0.4; then + source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.4/direnvrc" "sha256-DzlYZ33mWF/Gs8DDeyjr8mnVmQGx7ASYqA5WlxwvBG4=" fi watch_file nix/parts/shells/dev.nix diff --git a/templates/main/.envrc b/templates/main/.envrc index 9d7be5b..666703b 100644 --- a/templates/main/.envrc +++ b/templates/main/.envrc @@ -1,5 +1,5 @@ -if ! has nix_direnv_version || ! nix_direnv_version 2.2.1; then - source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.2.1/direnvrc" "sha256-zelF0vLbEl5uaqrfIzbgNzJWGmLzCmYAkInj/LNxvKs=" +if ! has nix_direnv_version || ! nix_direnv_version 3.0.4; then + source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.4/direnvrc" "sha256-DzlYZ33mWF/Gs8DDeyjr8mnVmQGx7ASYqA5WlxwvBG4=" fi watch_file parts/shells/dev.nix diff --git a/templates/minimal/.envrc b/templates/minimal/.envrc index 9d7be5b..666703b 100644 --- a/templates/minimal/.envrc +++ b/templates/minimal/.envrc @@ -1,5 +1,5 @@ -if ! has nix_direnv_version || ! nix_direnv_version 2.2.1; then - source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.2.1/direnvrc" "sha256-zelF0vLbEl5uaqrfIzbgNzJWGmLzCmYAkInj/LNxvKs=" +if ! has nix_direnv_version || ! nix_direnv_version 3.0.4; then + source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.4/direnvrc" "sha256-DzlYZ33mWF/Gs8DDeyjr8mnVmQGx7ASYqA5WlxwvBG4=" fi watch_file parts/shells/dev.nix From 2f77dd1ded9abbe0aa02f141ea7d2c5e05744498 Mon Sep 17 00:00:00 2001 From: tsandrini Date: Fri, 29 Mar 2024 12:04:22 +0100 Subject: [PATCH 2/5] feat(flake): update flake inputs --- flake.lock | 440 +++++++++++++++++++++++++++++++++++++++++++++++------ flake.nix | 4 + 2 files changed, 395 insertions(+), 49 deletions(-) diff --git a/flake.lock b/flake.lock index d2247ca..358e9b6 100644 --- a/flake.lock +++ b/flake.lock @@ -1,22 +1,78 @@ { "nodes": { + "cachix": { + "inputs": { + "devenv": "devenv_2", + "flake-compat": "flake-compat_2", + "nixpkgs": [ + "devenv", + "nixpkgs" + ], + "pre-commit-hooks": "pre-commit-hooks" + }, + "locked": { + "lastModified": 1710475558, + "narHash": "sha256-egKrPCKjy/cE+NqCj4hg2fNX/NwLCf0bRDInraYXDgs=", + "owner": "cachix", + "repo": "cachix", + "rev": "661bbb7f8b55722a0406456b15267b5426a3bda6", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "cachix", + "type": "github" + } + }, "devenv": { "inputs": { - "flake-compat": "flake-compat", + "cachix": "cachix", + "flake-compat": "flake-compat_4", + "nix": "nix_2", + "nixpkgs": "nixpkgs_2", + "pre-commit-hooks": "pre-commit-hooks_2" + }, + "locked": { + "lastModified": 1711535042, + "narHash": "sha256-Jr0LQ+bvFekPJvWxost2oymNNUzdym/Hu+HzQ6Fp630=", + "owner": "cachix", + "repo": "devenv", + "rev": "ad5a82f493f016bf4e82fae481b374d943be9560", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "devenv", + "type": "github" + } + }, + "devenv_2": { + "inputs": { + "flake-compat": [ + "devenv", + "cachix", + "flake-compat" + ], "nix": "nix", "nixpkgs": "nixpkgs", - "pre-commit-hooks": "pre-commit-hooks" + "poetry2nix": "poetry2nix", + "pre-commit-hooks": [ + "devenv", + "cachix", + "pre-commit-hooks" + ] }, "locked": { - "lastModified": 1710144971, - "narHash": "sha256-CjTOdoBvT/4AQncTL20SDHyJNgsXZjtGbz62yDIUYnM=", + "lastModified": 1708704632, + "narHash": "sha256-w+dOIW60FKMaHI1q5714CSibk99JfYxm0CzTinYWr+Q=", "owner": "cachix", "repo": "devenv", - "rev": "6c0bad0045f1e1802f769f7890f6a59504825f4d", + "rev": "2ee4450b0f4b95a1b90f2eb5ffea98b90e48c196", "type": "github" }, "original": { "owner": "cachix", + "ref": "python-rewrite", "repo": "devenv", "type": "github" } @@ -37,6 +93,70 @@ "type": "github" } }, + "flake-compat_2": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_3": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_4": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_5": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, "flake-parts": { "inputs": { "nixpkgs-lib": "nixpkgs-lib" @@ -60,11 +180,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1685518550, - "narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=", + "lastModified": 1689068808, + "narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=", "owner": "numtide", "repo": "flake-utils", - "rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef", + "rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4", "type": "github" }, "original": { @@ -77,6 +197,42 @@ "inputs": { "systems": "systems_2" }, + "locked": { + "lastModified": 1701680307, + "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_3": { + "inputs": { + "systems": "systems_3" + }, + "locked": { + "lastModified": 1701680307, + "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_4": { + "inputs": { + "systems": "systems_4" + }, "locked": { "lastModified": 1694529238, "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", @@ -95,16 +251,17 @@ "inputs": { "nixpkgs": [ "devenv", + "cachix", "pre-commit-hooks", "nixpkgs" ] }, "locked": { - "lastModified": 1660459072, - "narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=", + "lastModified": 1703887061, + "narHash": "sha256-gGPa9qWNc6eCXT/+Z5/zMkyYOuRZqeFZBDbopNZQkuY=", "owner": "hercules-ci", "repo": "gitignore.nix", - "rev": "a20de23b925fd8264fd7fad6454652e142fd7f73", + "rev": "43e1aa1308018f37118e34d3a9cb4f5e75dc11d5", "type": "github" }, "original": { @@ -113,19 +270,25 @@ "type": "github" } }, - "lowdown-src": { - "flake": false, + "gitignore_2": { + "inputs": { + "nixpkgs": [ + "devenv", + "pre-commit-hooks", + "nixpkgs" + ] + }, "locked": { - "lastModified": 1633514407, - "narHash": "sha256-Dw32tiMjdK9t3ETl5fzGrutQTzh2rufgZV4A/BbxuD4=", - "owner": "kristapsdz", - "repo": "lowdown", - "rev": "d2c2b44ff6c27b936ec27358a2653caaef8f73b8", + "lastModified": 1703887061, + "narHash": "sha256-gGPa9qWNc6eCXT/+Z5/zMkyYOuRZqeFZBDbopNZQkuY=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "43e1aa1308018f37118e34d3a9cb4f5e75dc11d5", "type": "github" }, "original": { - "owner": "kristapsdz", - "repo": "lowdown", + "owner": "hercules-ci", + "repo": "gitignore.nix", "type": "github" } }, @@ -146,31 +309,57 @@ }, "nix": { "inputs": { - "lowdown-src": "lowdown-src", + "flake-compat": "flake-compat", "nixpkgs": [ + "devenv", + "cachix", "devenv", "nixpkgs" ], "nixpkgs-regression": "nixpkgs-regression" }, "locked": { - "lastModified": 1676545802, - "narHash": "sha256-EK4rZ+Hd5hsvXnzSzk2ikhStJnD63odF7SzsQ8CuSPU=", + "lastModified": 1708577783, + "narHash": "sha256-92xq7eXlxIT5zFNccLpjiP7sdQqQI30Gyui2p/PfKZM=", "owner": "domenkozar", "repo": "nix", - "rev": "7c91803598ffbcfe4a55c44ac6d49b2cf07a527f", + "rev": "ecd0af0c1f56de32cbad14daa1d82a132bf298f8", "type": "github" }, "original": { "owner": "domenkozar", - "ref": "relaxed-flakes", + "ref": "devenv-2.21", "repo": "nix", "type": "github" } }, + "nix-github-actions": { + "inputs": { + "nixpkgs": [ + "devenv", + "cachix", + "devenv", + "poetry2nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1688870561, + "narHash": "sha256-4UYkifnPEw1nAzqqPOTL2MvWtm3sNGw1UTYTalkTcGY=", + "owner": "nix-community", + "repo": "nix-github-actions", + "rev": "165b1650b753316aa7f1787f3005a8d2da0f5301", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nix-github-actions", + "type": "github" + } + }, "nix2container": { "inputs": { - "flake-utils": "flake-utils_2", + "flake-utils": "flake-utils_4", "nixpkgs": [ "nixpkgs" ] @@ -189,13 +378,37 @@ "type": "github" } }, + "nix_2": { + "inputs": { + "flake-compat": "flake-compat_5", + "nixpkgs": [ + "devenv", + "nixpkgs" + ], + "nixpkgs-regression": "nixpkgs-regression_2" + }, + "locked": { + "lastModified": 1710500156, + "narHash": "sha256-zvCqeUO2GLOm7jnU23G4EzTZR7eylcJN+HJ5svjmubI=", + "owner": "domenkozar", + "repo": "nix", + "rev": "c5bbf14ecbd692eeabf4184cc8d50f79c2446549", + "type": "github" + }, + "original": { + "owner": "domenkozar", + "ref": "devenv-2.21", + "repo": "nix", + "type": "github" + } + }, "nixpkgs": { "locked": { - "lastModified": 1678875422, - "narHash": "sha256-T3o6NcQPwXjxJMn2shz86Chch4ljXgZn746c2caGxd8=", + "lastModified": 1692808169, + "narHash": "sha256-x9Opq06rIiwdwGeK2Ykj69dNc2IvUH1fY55Wm7atwrE=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "126f49a01de5b7e35a43fd43f891ecf6d3a51459", + "rev": "9201b5ff357e781bf014d0330d18555695df7ba8", "type": "github" }, "original": { @@ -239,29 +452,77 @@ "type": "github" } }, + "nixpkgs-regression_2": { + "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": 1685801374, - "narHash": "sha256-otaSUoFEMM+LjBI1XL/xGB5ao6IwnZOXc47qhIgJe8U=", + "lastModified": 1704874635, + "narHash": "sha256-YWuCrtsty5vVZvu+7BchAxmcYzTMfolSPP5io8+WYCg=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "c37ca420157f4abc31e26f436c1145f8951ff373", + "rev": "3dc440faeee9e889fe2d1b4d25ad0f430d449356", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-23.05", + "ref": "nixos-23.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-stable_2": { + "locked": { + "lastModified": 1704874635, + "narHash": "sha256-YWuCrtsty5vVZvu+7BchAxmcYzTMfolSPP5io8+WYCg=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "3dc440faeee9e889fe2d1b4d25ad0f430d449356", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.11", "repo": "nixpkgs", "type": "github" } }, "nixpkgs_2": { "locked": { - "lastModified": 1710451336, - "narHash": "sha256-pP86Pcfu3BrAvRO7R64x7hs+GaQrjFes+mEPowCfkxY=", + "lastModified": 1710236354, + "narHash": "sha256-vWrciFdq49vve43g4pbi7NjmL4cwG1ifXnQx+dU3T5E=", + "owner": "cachix", + "repo": "devenv-nixpkgs", + "rev": "829e73affeadfb4198a7105cbe3a03153d13edc9", + "type": "github" + }, + "original": { + "owner": "cachix", + "ref": "rolling", + "repo": "devenv-nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1711523803, + "narHash": "sha256-UKcYiHWHQynzj6CN/vTcix4yd1eCu1uFdsuarupdCQQ=", "owner": "nixos", "repo": "nixpkgs", - "rev": "d691274a972b3165335d261cc4671335f5c67de9", + "rev": "2726f127c15a4cc9810843b96cad73c7eb39e443", "type": "github" }, "original": { @@ -271,7 +532,7 @@ "type": "github" } }, - "nixpkgs_3": { + "nixpkgs_4": { "locked": { "lastModified": 1708475490, "narHash": "sha256-g1v0TsWBQPX97ziznfJdWhgMyMGtoBFs102xSYO4syU=", @@ -287,26 +548,77 @@ "type": "github" } }, + "poetry2nix": { + "inputs": { + "flake-utils": "flake-utils", + "nix-github-actions": "nix-github-actions", + "nixpkgs": [ + "devenv", + "cachix", + "devenv", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1692876271, + "narHash": "sha256-IXfZEkI0Mal5y1jr6IRWMqK8GW2/f28xJenZIPQqkY0=", + "owner": "nix-community", + "repo": "poetry2nix", + "rev": "d5006be9c2c2417dafb2e2e5034d83fabd207ee3", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "poetry2nix", + "type": "github" + } + }, "pre-commit-hooks": { + "inputs": { + "flake-compat": "flake-compat_3", + "flake-utils": "flake-utils_2", + "gitignore": "gitignore", + "nixpkgs": [ + "devenv", + "cachix", + "nixpkgs" + ], + "nixpkgs-stable": "nixpkgs-stable" + }, + "locked": { + "lastModified": 1708018599, + "narHash": "sha256-M+Ng6+SePmA8g06CmUZWi1AjG2tFBX9WCXElBHEKnyM=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "5df5a70ad7575f6601d91f0efec95dd9bc619431", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, + "pre-commit-hooks_2": { "inputs": { "flake-compat": [ "devenv", "flake-compat" ], - "flake-utils": "flake-utils", - "gitignore": "gitignore", + "flake-utils": "flake-utils_3", + "gitignore": "gitignore_2", "nixpkgs": [ "devenv", "nixpkgs" ], - "nixpkgs-stable": "nixpkgs-stable" + "nixpkgs-stable": "nixpkgs-stable_2" }, "locked": { - "lastModified": 1704725188, - "narHash": "sha256-qq8NbkhRZF1vVYQFt1s8Mbgo8knj+83+QlL5LBnYGpI=", + "lastModified": 1708018599, + "narHash": "sha256-M+Ng6+SePmA8g06CmUZWi1AjG2tFBX9WCXElBHEKnyM=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "ea96f0c05924341c551a797aaba8126334c505d2", + "rev": "5df5a70ad7575f6601d91f0efec95dd9bc619431", "type": "github" }, "original": { @@ -321,8 +633,8 @@ "flake-parts": "flake-parts", "mk-shell-bin": "mk-shell-bin", "nix2container": "nix2container", - "nixpkgs": "nixpkgs_2", - "systems": "systems_3", + "nixpkgs": "nixpkgs_3", + "systems": "systems_5", "treefmt-nix": "treefmt-nix" } }, @@ -371,16 +683,46 @@ "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" + } + }, + "systems_5": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, "treefmt-nix": { "inputs": { - "nixpkgs": "nixpkgs_3" + "nixpkgs": "nixpkgs_4" }, "locked": { - "lastModified": 1710278050, - "narHash": "sha256-Oc6BP7soXqb8itlHI8UKkdf3V9GeJpa1S39SR5+HJys=", + "lastModified": 1711531821, + "narHash": "sha256-5n4hq7PsH8g9czJ5HvXpVrJ4AiJdzrutHK01oKIaCXE=", "owner": "numtide", "repo": "treefmt-nix", - "rev": "35791f76524086ab4b785a33e4abbedfda64bd22", + "rev": "c2172ef83d6904cdff3118e0c08e89171db6028a", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 33fa723..98107ac 100644 --- a/flake.nix +++ b/flake.nix @@ -109,6 +109,10 @@ }; devenv.shells.dev = { + + # Needed for devenv to run in pure mode + devenv.root = builtins.toString ./.; + packages = with pkgs; [ # -- NIX UTILS -- nil # Yet another language server for Nix From c6c06e7892af241b62dbf160a17e3f91661c626d Mon Sep 17 00:00:00 2001 From: tsandrini Date: Fri, 29 Mar 2024 15:48:38 +0100 Subject: [PATCH 3/5] feat(devenv): update to v1 & add examples & remove impurities --- .envrc | 5 +- flake.lock | 13 ++ flake.nix | 95 ++++++++++--- templates/home/.envrc | 5 +- templates/home/flake.nix | 27 ++-- templates/home/parts/shells/default.nix | 2 + templates/home/parts/shells/dev.nix | 126 +++++++++++++---- templates/home/parts/treefmt/treefmt.nix | 8 ++ templates/isolated-minimal/.envrc | 5 +- templates/isolated-minimal/flake.nix | 27 ++-- .../nix/parts/shells/default.nix | 2 + .../isolated-minimal/nix/parts/shells/dev.nix | 102 ++++++++++---- .../nix/parts/treefmt/treefmt.nix | 8 ++ templates/isolated/.envrc | 5 +- templates/isolated/flake.nix | 21 ++- .../isolated/nix/parts/shells/default.nix | 1 + templates/isolated/nix/parts/shells/dev.nix | 128 ++++++++++++++---- .../isolated/nix/parts/treefmt/treefmt.nix | 8 ++ templates/main/.envrc | 5 +- templates/main/flake.nix | 27 ++-- templates/main/parts/shells/default.nix | 1 + templates/main/parts/shells/dev.nix | 125 +++++++++++++---- templates/main/parts/treefmt/treefmt.nix | 8 ++ templates/minimal/.envrc | 5 +- templates/minimal/flake.nix | 27 ++-- templates/minimal/parts/shells/default.nix | 1 + templates/minimal/parts/shells/dev.nix | 103 ++++++++++---- templates/minimal/parts/treefmt/treefmt.nix | 8 ++ 28 files changed, 685 insertions(+), 213 deletions(-) diff --git a/.envrc b/.envrc index 1fedf30..57c0efe 100644 --- a/.envrc +++ b/.envrc @@ -2,9 +2,10 @@ if ! has nix_direnv_version || ! nix_direnv_version 3.0.4; then source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.4/direnvrc" "sha256-DzlYZ33mWF/Gs8DDeyjr8mnVmQGx7ASYqA5WlxwvBG4=" fi - watch_file flake.nix -if ! use flake .#dev --accept-flake-config +watch_file flake.lock + +if ! use flake .#dev --accept-flake-config --override-input devenv-root "file+file://"<(printf %s "$PWD") then echo "devenv could not be built. The devenv environment was not loaded. Make the necessary changes to devenv.nix and hit enter to try again." >&2 fi diff --git a/flake.lock b/flake.lock index 358e9b6..0b23406 100644 --- a/flake.lock +++ b/flake.lock @@ -46,6 +46,18 @@ "type": "github" } }, + "devenv-root": { + "flake": false, + "locked": { + "narHash": "sha256-d6xi4mKdjkX2JFicDIv5niSzpyI0m/Hnm8GGAIU04kY=", + "type": "file", + "url": "file:///dev/null" + }, + "original": { + "type": "file", + "url": "file:///dev/null" + } + }, "devenv_2": { "inputs": { "flake-compat": [ @@ -630,6 +642,7 @@ "root": { "inputs": { "devenv": "devenv", + "devenv-root": "devenv-root", "flake-parts": "flake-parts", "mk-shell-bin": "mk-shell-bin", "nix2container": "nix2container", diff --git a/flake.nix b/flake.nix index 98107ac..b46ae7f 100644 --- a/flake.nix +++ b/flake.nix @@ -2,31 +2,42 @@ description = "PracticalFlakesTemplate - Highly opinionated nix flakes starter template that focuses on modularity."; inputs = { - # Base dependencies + # --- BASE DEPENDENCIES --- nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; flake-parts.url = "github:hercules-ci/flake-parts"; systems.url = "github:nix-systems/default"; - # Development - treefmt-nix.url = "github:numtide/treefmt-nix"; + # --- DEV DEPENDENCIES --- devenv.url = "github:cachix/devenv"; + devenv-root = { + url = "file+file:///dev/null"; + flake = false; + }; mk-shell-bin.url = "github:rrbutani/nix-mk-shell-bin"; nix2container = { url = "github:nlewo/nix2container"; inputs.nixpkgs.follows = "nixpkgs"; }; + treefmt-nix.url = "github:numtide/treefmt-nix"; + + # --- (YOUR) EXTRA DEPENDENCIES --- }; + # NOTE Here you can add additional binary cache substituers that you trust. + # There are also some sensible default caches commented out that you + # might consider using. nixConfig = { extra-substituters = [ "https://cache.nixos.org" "https://nix-community.cachix.org/" "https://devenv.cachix.org" + "https://tsandrini.cachix.org" ]; extra-trusted-public-keys = [ "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" "devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw=" + "tsandrini.cachix.org-1:t0AzIUglIqwiY+vz/WRWXrOkDZN8TwY3gk+n+UDt4gw=" ]; }; @@ -110,19 +121,17 @@ devenv.shells.dev = { - # Needed for devenv to run in pure mode - devenv.root = builtins.toString ./.; - + # -------------------------- + # --- ENV & SHELL & PKGS --- + # -------------------------- packages = with pkgs; [ # -- NIX UTILS -- - nil # Yet another language server for Nix - statix # Lints and suggestions for the nix programming language - deadnix # Find and remove unused code in .nix source files nix-output-monitor # Processes output of Nix commands to show helpful and pretty information nixfmt-rfc-style # An opinionated formatter for Nix # NOTE Choose a different formatter if you'd like to # nixfmt # An opinionated formatter for Nix # alejandra # The Uncompromising Nix Code Formatter + nh # Yet another nix cli helper # -- GIT RELATED UTILS -- commitizen # Tool to create committing rules for projects, auto bump versions, and generate changelogs @@ -132,29 +141,83 @@ # -- LANGUAGE RELATED UTILS -- markdownlint-cli # Command line interface for MarkdownLint - nodePackages.prettier # Prettier is an opinionated code formatter typos # Source code spell checker config.treefmt.build.wrapper # one CLI to format the code tree + + # -- (YOUR) EXTRA PKGS -- + nodePackages.prettier # Prettier is an opinionated code formatter ]; + enterShell = '' + # Welcome splash text + echo ""; echo -e "\e[1;37;42mWelcome to the practicalFlakes devshell!\e[0m"; echo "" + ''; + + # --------------- + # --- SCRIPTS --- + # --------------- + scripts = { + "rename-project".exec = '' + find $1 \( -type d -name .git -prune \) -o -type f -print0 | xargs -0 sed -i "s/practicalFlakes/$2/g" + ''; + }; + + # ----------------- + # --- LANGUAGES --- + # ----------------- languages.nix.enable = true; - difftastic.enable = true; + + # ---------------------------- + # --- PROCESSES & SERVICES --- + # ---------------------------- + + # ------------------ + # --- CONTAINERS --- + # ------------------ devcontainer.enable = true; - devenv.flakesIntegration = true; + # ---------------------- + # --- BINARY CACHING --- + # ---------------------- + # NOTE All available hooks options are listed at + # https://devenv.sh/reference/options/#pre-commithooks pre-commit = { hooks = { treefmt.enable = true; - commitizen.enable = true; - markdownlint.enable = true; - typos.enable = true; - actionlint.enable = true; + nil.enable = true; # Nix Language server, an incremental analysis assistant for writing in Nix. + markdownlint.enable = true; # Markdown lint tool + typos.enable = true; # Source code spell checker + editorconfig-checker.enable = true; # A tool to verify that your files are in harmony with your .editorconfig + + actionlint.enable = true; # GitHub workflows linting + commitizen.enable = true; # Commitizen is release management tool designed for teams. }; settings = { + # We pass our custom treefmt build from parts/treefmt/treefmt.nix for + # devenv to use. treefmt.package = config.treefmt.build.wrapper; }; }; + + # -------------- + # --- FLAKES --- + # -------------- + devenv.flakesIntegration = true; + + # This is currently needed for devenv to properly run in pure hermetic + # mode while still being able to run processes & services and modify + # (some parts) of the active shell. + devenv.root = + let + devenvRootFileContent = builtins.readFile inputs.devenv-root.outPath; + in + pkgs.lib.mkIf (devenvRootFileContent != "") devenvRootFileContent; + + # --------------------- + # --- MISCELLANEOUS --- + # --------------------- + difftastic.enable = true; }; }; }; diff --git a/templates/home/.envrc b/templates/home/.envrc index 666703b..6611954 100644 --- a/templates/home/.envrc +++ b/templates/home/.envrc @@ -2,8 +2,11 @@ if ! has nix_direnv_version || ! nix_direnv_version 3.0.4; then source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.4/direnvrc" "sha256-DzlYZ33mWF/Gs8DDeyjr8mnVmQGx7ASYqA5WlxwvBG4=" fi +watch_file flake.nix +watch_file flake.lock watch_file parts/shells/dev.nix -if ! use flake .#dev --impure --accept-flake-config + +if ! use flake .#dev --accept-flake-config --override-input devenv-root "file+file://"<(printf %s "$PWD") then echo "devenv could not be built. The devenv environment was not loaded. Make the necessary changes to devenv.nix and hit enter to try again." >&2 fi diff --git a/templates/home/flake.nix b/templates/home/flake.nix index 02a2ecc..36ad4cc 100644 --- a/templates/home/flake.nix +++ b/templates/home/flake.nix @@ -2,28 +2,32 @@ description = "practicalFlakes - TODO Add a description of your new project"; inputs = { - # Base dependencies + # --- BASE DEPENDENCIES --- nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; flake-parts.url = "github:hercules-ci/flake-parts"; systems.url = "github:nix-systems/default"; - # Development (devenv and treefmt dependencies) - treefmt-nix.url = "github:numtide/treefmt-nix"; + # --- DEV DEPENDENCIES --- devenv.url = "github:cachix/devenv"; + devenv-root = { + url = "file+file:///dev/null"; + flake = false; + }; mk-shell-bin.url = "github:rrbutani/nix-mk-shell-bin"; nix2container = { url = "github:nlewo/nix2container"; inputs.nixpkgs.follows = "nixpkgs"; }; + treefmt-nix.url = "github:numtide/treefmt-nix"; - # Project specific dependencies + # --- (NOTE, YOUR) EXTRA DEPENDENCIES --- home-manager = { url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; }; }; - # Here you can add additional binary cache substituers that you trust. + # NOTE Here you can add additional binary cache substituers that you trust. # There are also some sensible default caches commented out that you # might consider using. nixConfig = { @@ -90,22 +94,21 @@ # - mySimpleModule.nix imports = flatten (mapModules ./parts (x: x)); - # We use the default `systems` defined by the `nix-systems` flake, if you - # need any additional systems, simply add them in the following manner + # NOTE We use the default `systems` defined by the `nix-systems` flake, if + # you need any additional systems, simply add them in the following manner # # `systems = (import inputs.systems) ++ [ "armv7l-linux" ];` systems = import inputs.systems; flake.lib = lib.practicalFlakes; - # Since the official flakes output schema is unfortunately very limited - # you can enable the debug mode if you need to inspect certain outputs - # of your flake. Simply - # + # NOTE Since the official flakes output schema is unfortunately very + # limited you can enable the debug mode if you need to inspect certain + # outputs of your flake. Simply # 1. uncomment the following line # 2. hop into a repl from the project root - `nix repl` # 3. load the flake - `:lf .` - # # After that you can inspect the flake from the root attribute `debug.flake` + # # debug = true; }; } diff --git a/templates/home/parts/shells/default.nix b/templates/home/parts/shells/default.nix index 43caa87..2cbee09 100644 --- a/templates/home/parts/shells/default.nix +++ b/templates/home/parts/shells/default.nix @@ -2,11 +2,13 @@ { inputs, projectPath, ... }: { imports = with inputs; [ devenv.flakeModule ]; + perSystem = { config, pkgs, ... }: { devenv.shells.dev = import ./dev.nix { inherit pkgs projectPath; + inherit (inputs) devenv-root; treefmt = config.treefmt.build.wrapper; }; }; diff --git a/templates/home/parts/shells/dev.nix b/templates/home/parts/shells/dev.nix index 0e546c0..6bf111a 100644 --- a/templates/home/parts/shells/dev.nix +++ b/templates/home/parts/shells/dev.nix @@ -1,19 +1,29 @@ # --- parts/shells/dev.nix -{ pkgs, treefmt, ... }: + +{ + pkgs, + treefmt, + devenv-root, + ... +}: { - # Some sensible defaults for a seamless initial experience have been set, - # however, feel free to modify anything you'd like. + # DEVENV: Fast, Declarative, Reproducible, and Composable Developer + # Environments using Nix developed by Cachix. For more information refer to + # + # - https://devenv.sh/ + # - https://github.com/cachix/devenv + # -------------------------- + # --- ENV & SHELL & PKGS --- + # -------------------------- packages = with pkgs; [ # -- NIX UTILS -- - nil # Yet another language server for Nix - statix # Lints and suggestions for the nix programming language - deadnix # Find and remove unused code in .nix source files nix-output-monitor # Processes output of Nix commands to show helpful and pretty information nixfmt-rfc-style # An opinionated formatter for Nix # NOTE Choose a different formatter if you'd like to # nixfmt # An opinionated formatter for Nix # alejandra # The Uncompromising Nix Code Formatter + nh # Yet another nix cli helper # -- GIT RELATED UTILS -- # commitizen # Tool to create committing rules for projects, auto bump versions, and generate changelogs @@ -21,45 +31,109 @@ # fh # The official FlakeHub CLI # gh # GitHub CLI tool - # -- LANGUAGE RELATED UTILS -- + # -- BASE LANG UTILS -- markdownlint-cli # Command line interface for MarkdownLint - nodePackages.prettier # Prettier is an opinionated code formatter typos # Source code spell checker treefmt # one CLI to format the code tree - # -- NIXOS UTILS -- - nh # Yet another nix cli helper + # -- (YOUR) EXTRA PKGS -- ]; + # env = { + # MYUSER = "user"; + # # ... + # }; + + # NOTE If you'd like to automatically load a .env file you can use these + # following expressions + # + # dotenv.enable = true; + # dotenv.filename = ".env.development"; + + enterShell = '' + # Welcome splash text + echo ""; echo -e "\e[1;37;42mWelcome to the practicalFlakes devshell!\e[0m"; echo "" + ''; + + # --------------- + # --- SCRIPTS --- + # --------------- + scripts = { + "rename-project".exec = '' + find $1 \( -type d -name .git -prune \) -o -type f -print0 | xargs -0 sed -i "s/practicalFlakes/$2/g" + ''; + }; + + # ----------------- + # --- LANGUAGES --- + # ----------------- languages.nix.enable = true; - difftastic.enable = true; + + # NOTE You can enable additional language support in the following manner + # languages.python.enable = true; + # languages.python.version = "3.11.3"; + + # languages.rust.enable = true; + # languages.rust.channel = "stable"; + + # ---------------------------- + # --- PROCESSES & SERVICES --- + # ---------------------------- + + # ------------------ + # --- CONTAINERS --- + # ------------------ devcontainer.enable = true; - devenv.flakesIntegration = true; + # ---------------------- + # --- BINARY CACHING --- + # ---------------------- + # NOTE Here you can configure automatic cachix binary cache pulling & pushing + # to/from a cache named "mycache" + # + # cachix.pull = [ "pre-commit-hooks" ]; + # cachix.push = "mycache"; + + # ------------------------ + # --- PRE-COMMIT HOOKS --- + # ------------------------ + # NOTE All available hooks options are listed at + # https://devenv.sh/reference/options/#pre-commithooks pre-commit = { hooks = { treefmt.enable = true; - # Everything below is stuff that is missing from treefmt - nil.enable = true; - markdownlint.enable = true; - typos.enable = true; + nil.enable = true; # Nix Language server, an incremental analysis assistant for writing in Nix. + markdownlint.enable = true; # Markdown lint tool + typos.enable = true; # Source code spell checker + editorconfig-checker.enable = true; # A tool to verify that your files are in harmony with your .editorconfig + # actionlint.enable = true; # GitHub workflows linting - # commitizen.enable = true; # Enable if using commitizen + # commitizen.enable = true; # Commitizen is release management tool designed for teams. }; settings = { + # We pass our custom treefmt build from parts/treefmt/treefmt.nix for + # devenv to use. treefmt.package = treefmt; }; }; - scripts = { - "rename-project".exec = '' - find $1 \( -type d -name .git -prune \) -o -type f -print0 | xargs -0 sed -i "s/practicalFlakes/$2/g" - ''; - }; + # -------------- + # --- FLAKES --- + # -------------- + devenv.flakesIntegration = true; - enterShell = '' - # Greeting upon devshell activation - echo ""; echo -e "\e[1;37;42mWelcome to the practicalFlakes devshell!\e[0m"; echo "" - ''; + # This is currently needed for devenv to properly run in pure hermetic + # mode while still being able to run processes & services and modify + # (some parts) of the active shell. + devenv.root = + let + devenvRootFileContent = builtins.readFile devenv-root.outPath; + in + pkgs.lib.mkIf (devenvRootFileContent != "") devenvRootFileContent; + + # --------------------- + # --- MISCELLANEOUS --- + # --------------------- + difftastic.enable = true; } diff --git a/templates/home/parts/treefmt/treefmt.nix b/templates/home/parts/treefmt/treefmt.nix index 4c712b4..d9578ec 100644 --- a/templates/home/parts/treefmt/treefmt.nix +++ b/templates/home/parts/treefmt/treefmt.nix @@ -1,6 +1,14 @@ # --- parts/treefmt/treefmt.nix { pkgs, projectPath, ... }: { + # treefmt is a formatting tool that saves you time: it provides + # developers with a universal way to trigger all formatters needed for the + # project in one place. + # For more information refer to + # + # - https://numtide.github.io/treefmt/ + # - https://github.com/numtide/treefmt-nix + package = pkgs.treefmt; flakeCheck = true; flakeFormatter = true; diff --git a/templates/isolated-minimal/.envrc b/templates/isolated-minimal/.envrc index ace74fc..6c4b45d 100644 --- a/templates/isolated-minimal/.envrc +++ b/templates/isolated-minimal/.envrc @@ -2,8 +2,11 @@ if ! has nix_direnv_version || ! nix_direnv_version 3.0.4; then source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.4/direnvrc" "sha256-DzlYZ33mWF/Gs8DDeyjr8mnVmQGx7ASYqA5WlxwvBG4=" fi +watch_file flake.nix +watch_file flake.lock watch_file nix/parts/shells/dev.nix -if ! use flake .#dev --impure --accept-flake-config + +if ! use flake .#dev --accept-flake-config --override-input devenv-root "file+file://"<(printf %s "$PWD") then echo "devenv could not be built. The devenv environment was not loaded. Make the necessary changes to devenv.nix and hit enter to try again." >&2 fi diff --git a/templates/isolated-minimal/flake.nix b/templates/isolated-minimal/flake.nix index b32c70e..4664f67 100644 --- a/templates/isolated-minimal/flake.nix +++ b/templates/isolated-minimal/flake.nix @@ -2,24 +2,28 @@ description = "practicalFlakes - TODO Add a description of your new project"; inputs = { - # Base dependencies + # --- BASE DEPENDENCIES --- nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; flake-parts.url = "github:hercules-ci/flake-parts"; systems.url = "github:nix-systems/default"; - # Development (devenv and treefmt dependencies) - treefmt-nix.url = "github:numtide/treefmt-nix"; + # --- DEV DEPENDENCIES --- devenv.url = "github:cachix/devenv"; + devenv-root = { + url = "file+file:///dev/null"; + flake = false; + }; mk-shell-bin.url = "github:rrbutani/nix-mk-shell-bin"; nix2container = { url = "github:nlewo/nix2container"; inputs.nixpkgs.follows = "nixpkgs"; }; + treefmt-nix.url = "github:numtide/treefmt-nix"; - # Project specific dependencies + # --- (NOTE, YOUR) EXTRA DEPENDENCIES --- }; - # Here you can add additional binary cache substituers that you trust. + # NOTE Here you can add additional binary cache substituers that you trust. # There are also some sensible default caches commented out that you # might consider using. nixConfig = { @@ -86,22 +90,21 @@ # - mySimpleModule.nix imports = flatten (mapModules ./nix/parts (x: x)); - # We use the default `systems` defined by the `nix-systems` flake, if you - # need any additional systems, simply add them in the following manner + # NOTE We use the default `systems` defined by the `nix-systems` flake, if + # you need any additional systems, simply add them in the following manner # # `systems = (import inputs.systems) ++ [ "armv7l-linux" ];` systems = import inputs.systems; flake.lib = lib.practicalFlakes; - # Since the official flakes output schema is unfortunately very limited - # you can enable the debug mode if you need to inspect certain outputs - # of your flake. Simply - # + # NOTE Since the official flakes output schema is unfortunately very + # limited you can enable the debug mode if you need to inspect certain + # outputs of your flake. Simply # 1. uncomment the following line # 2. hop into a repl from the project root - `nix repl` # 3. load the flake - `:lf .` - # # After that you can inspect the flake from the root attribute `debug.flake` + # # debug = true; }; } diff --git a/templates/isolated-minimal/nix/parts/shells/default.nix b/templates/isolated-minimal/nix/parts/shells/default.nix index 109044a..5cd214f 100644 --- a/templates/isolated-minimal/nix/parts/shells/default.nix +++ b/templates/isolated-minimal/nix/parts/shells/default.nix @@ -2,11 +2,13 @@ { inputs, projectPath, ... }: { imports = with inputs; [ devenv.flakeModule ]; + perSystem = { config, pkgs, ... }: { devenv.shells.dev = import ./dev.nix { inherit pkgs projectPath; + inherit (inputs) devenv-root; treefmt = config.treefmt.build.wrapper; }; }; diff --git a/templates/isolated-minimal/nix/parts/shells/dev.nix b/templates/isolated-minimal/nix/parts/shells/dev.nix index 4249bd8..8466070 100644 --- a/templates/isolated-minimal/nix/parts/shells/dev.nix +++ b/templates/isolated-minimal/nix/parts/shells/dev.nix @@ -1,19 +1,28 @@ # --- nix/parts/shells/dev.nix -{ pkgs, treefmt, ... }: { - # Some sensible defaults for a seamless initial experience have been set, - # however, feel free to modify anything you'd like. + pkgs, + treefmt, + devenv-root, + ... +}: +{ + # DEVENV: Fast, Declarative, Reproducible, and Composable Developer + # Environments using Nix developed by Cachix. For more information refer to + # + # - https://devenv.sh/ + # - https://github.com/cachix/devenv + # -------------------------- + # --- ENV & SHELL & PKGS --- + # -------------------------- packages = with pkgs; [ # -- NIX UTILS -- - nil # Yet another language server for Nix - statix # Lints and suggestions for the nix programming language - deadnix # Find and remove unused code in .nix source files nix-output-monitor # Processes output of Nix commands to show helpful and pretty information nixfmt-rfc-style # An opinionated formatter for Nix # NOTE Choose a different formatter if you'd like to # nixfmt # An opinionated formatter for Nix # alejandra # The Uncompromising Nix Code Formatter + nh # Yet another nix cli helper # -- GIT RELATED UTILS -- # commitizen # Tool to create committing rules for projects, auto bump versions, and generate changelogs @@ -21,45 +30,86 @@ # fh # The official FlakeHub CLI # gh # GitHub CLI tool - # -- LANGUAGE RELATED UTILS -- + # -- BASE LANG UTILS -- markdownlint-cli # Command line interface for MarkdownLint - nodePackages.prettier # Prettier is an opinionated code formatter typos # Source code spell checker treefmt # one CLI to format the code tree - # -- NIXOS UTILS -- - nh # Yet another nix cli helper + # -- (YOUR) EXTRA PKGS -- ]; + enterShell = '' + # Welcome splash text + echo ""; echo -e "\e[1;37;42mWelcome to the practicalFlakes devshell!\e[0m"; echo "" + ''; + + # --------------- + # --- SCRIPTS --- + # --------------- + scripts = { + "rename-project".exec = '' + find $1 \( -type d -name .git -prune \) -o -type f -print0 | xargs -0 sed -i "s/practicalFlakes/$2/g" + ''; + }; + + # ----------------- + # --- LANGUAGES --- + # ----------------- languages.nix.enable = true; - difftastic.enable = true; + + # ---------------------------- + # --- PROCESSES & SERVICES --- + # ---------------------------- + + # ------------------ + # --- CONTAINERS --- + # ------------------ devcontainer.enable = true; - devenv.flakesIntegration = true; + # ---------------------- + # --- BINARY CACHING --- + # ---------------------- + + # ------------------------ + # --- PRE-COMMIT HOOKS --- + # ------------------------ + # NOTE All available hooks options are listed at + # https://devenv.sh/reference/options/#pre-commithooks pre-commit = { hooks = { treefmt.enable = true; - # Everything below is stuff that is missing from treefmt - nil.enable = true; - markdownlint.enable = true; - typos.enable = true; + nil.enable = true; # Nix Language server, an incremental analysis assistant for writing in Nix. + markdownlint.enable = true; # Markdown lint tool + typos.enable = true; # Source code spell checker + editorconfig-checker.enable = true; # A tool to verify that your files are in harmony with your .editorconfig + # actionlint.enable = true; # GitHub workflows linting - # commitizen.enable = true; # Enable if using commitizen + # commitizen.enable = true; # Commitizen is release management tool designed for teams. }; settings = { + # We pass our custom treefmt build from parts/treefmt/treefmt.nix for + # devenv to use. treefmt.package = treefmt; }; }; - scripts = { - "rename-project".exec = '' - find $1 \( -type d -name .git -prune \) -o -type f -print0 | xargs -0 sed -i "s/practicalFlakes/$2/g" - ''; - }; + # -------------- + # --- FLAKES --- + # -------------- + devenv.flakesIntegration = true; - enterShell = '' - # Greeting upon devshell activation - echo ""; echo -e "\e[1;37;42mWelcome to the practicalFlakes devshell!\e[0m"; echo "" - ''; + # This is currently needed for devenv to properly run in pure hermetic + # mode while still being able to run processes & services and modify + # (some parts) of the active shell. + devenv.root = + let + devenvRootFileContent = builtins.readFile devenv-root.outPath; + in + pkgs.lib.mkIf (devenvRootFileContent != "") devenvRootFileContent; + + # --------------------- + # --- MISCELLANEOUS --- + # --------------------- + difftastic.enable = true; } diff --git a/templates/isolated-minimal/nix/parts/treefmt/treefmt.nix b/templates/isolated-minimal/nix/parts/treefmt/treefmt.nix index 9d2bba2..33578a7 100644 --- a/templates/isolated-minimal/nix/parts/treefmt/treefmt.nix +++ b/templates/isolated-minimal/nix/parts/treefmt/treefmt.nix @@ -1,6 +1,14 @@ # --- nix/parts/treefmt/treefmt.nix { pkgs, projectPath, ... }: { + # treefmt is a formatting tool that saves you time: it provides + # developers with a universal way to trigger all formatters needed for the + # project in one place. + # For more information refer to + # + # - https://numtide.github.io/treefmt/ + # - https://github.com/numtide/treefmt-nix + package = pkgs.treefmt; flakeCheck = true; flakeFormatter = true; diff --git a/templates/isolated/.envrc b/templates/isolated/.envrc index ace74fc..6c4b45d 100644 --- a/templates/isolated/.envrc +++ b/templates/isolated/.envrc @@ -2,8 +2,11 @@ if ! has nix_direnv_version || ! nix_direnv_version 3.0.4; then source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.4/direnvrc" "sha256-DzlYZ33mWF/Gs8DDeyjr8mnVmQGx7ASYqA5WlxwvBG4=" fi +watch_file flake.nix +watch_file flake.lock watch_file nix/parts/shells/dev.nix -if ! use flake .#dev --impure --accept-flake-config + +if ! use flake .#dev --accept-flake-config --override-input devenv-root "file+file://"<(printf %s "$PWD") then echo "devenv could not be built. The devenv environment was not loaded. Make the necessary changes to devenv.nix and hit enter to try again." >&2 fi diff --git a/templates/isolated/flake.nix b/templates/isolated/flake.nix index b32c70e..3926eb0 100644 --- a/templates/isolated/flake.nix +++ b/templates/isolated/flake.nix @@ -2,12 +2,12 @@ description = "practicalFlakes - TODO Add a description of your new project"; inputs = { - # Base dependencies + # --- BASE DEPENDENCIES --- nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; flake-parts.url = "github:hercules-ci/flake-parts"; systems.url = "github:nix-systems/default"; - # Development (devenv and treefmt dependencies) + # --- DEV DEPENDENCIES --- treefmt-nix.url = "github:numtide/treefmt-nix"; devenv.url = "github:cachix/devenv"; mk-shell-bin.url = "github:rrbutani/nix-mk-shell-bin"; @@ -16,10 +16,10 @@ inputs.nixpkgs.follows = "nixpkgs"; }; - # Project specific dependencies + # --- (NOTE, YOUR) EXTRA DEPENDENCIES --- }; - # Here you can add additional binary cache substituers that you trust. + # NOTE Here you can add additional binary cache substituers that you trust. # There are also some sensible default caches commented out that you # might consider using. nixConfig = { @@ -86,22 +86,21 @@ # - mySimpleModule.nix imports = flatten (mapModules ./nix/parts (x: x)); - # We use the default `systems` defined by the `nix-systems` flake, if you - # need any additional systems, simply add them in the following manner + # NOTE We use the default `systems` defined by the `nix-systems` flake, if + # you need any additional systems, simply add them in the following manner # # `systems = (import inputs.systems) ++ [ "armv7l-linux" ];` systems = import inputs.systems; flake.lib = lib.practicalFlakes; - # Since the official flakes output schema is unfortunately very limited - # you can enable the debug mode if you need to inspect certain outputs - # of your flake. Simply - # + # NOTE Since the official flakes output schema is unfortunately very + # limited you can enable the debug mode if you need to inspect certain + # outputs of your flake. Simply # 1. uncomment the following line # 2. hop into a repl from the project root - `nix repl` # 3. load the flake - `:lf .` - # # After that you can inspect the flake from the root attribute `debug.flake` + # # debug = true; }; } diff --git a/templates/isolated/nix/parts/shells/default.nix b/templates/isolated/nix/parts/shells/default.nix index 109044a..3227ca3 100644 --- a/templates/isolated/nix/parts/shells/default.nix +++ b/templates/isolated/nix/parts/shells/default.nix @@ -7,6 +7,7 @@ { devenv.shells.dev = import ./dev.nix { inherit pkgs projectPath; + inherit (inputs) devenv-root; treefmt = config.treefmt.build.wrapper; }; }; diff --git a/templates/isolated/nix/parts/shells/dev.nix b/templates/isolated/nix/parts/shells/dev.nix index 42d7a1a..37a4cdc 100644 --- a/templates/isolated/nix/parts/shells/dev.nix +++ b/templates/isolated/nix/parts/shells/dev.nix @@ -1,19 +1,29 @@ # --- nix/parts/shells/dev.nix -{ pkgs, treefmt, ... }: + +{ + pkgs, + treefmt, + devenv-root, + ... +}: { - # Some sensible defaults for a seamless initial experience have been set, - # however, feel free to modify anything you'd like. + # DEVENV: Fast, Declarative, Reproducible, and Composable Developer + # Environments using Nix developed by Cachix. For more information refer to + # + # - https://devenv.sh/ + # - https://github.com/cachix/devenv + # -------------------------- + # --- ENV & SHELL & PKGS --- + # -------------------------- packages = with pkgs; [ - # -- UTILS -- - nil # Yet another language server for Nix - statix # Lints and suggestions for the nix programming language - deadnix # Find and remove unused code in .nix source files + # -- NIX UTILS -- nix-output-monitor # Processes output of Nix commands to show helpful and pretty information nixfmt-rfc-style # An opinionated formatter for Nix # NOTE Choose a different formatter if you'd like to # nixfmt # An opinionated formatter for Nix # alejandra # The Uncompromising Nix Code Formatter + nh # Yet another nix cli helper # -- GIT RELATED UTILS -- # commitizen # Tool to create committing rules for projects, auto bump versions, and generate changelogs @@ -21,45 +31,109 @@ # fh # The official FlakeHub CLI # gh # GitHub CLI tool - # -- LANGUAGE RELATED UTILS -- + # -- BASE LANG UTILS -- markdownlint-cli # Command line interface for MarkdownLint - nodePackages.prettier # Prettier is an opinionated code formatter typos # Source code spell checker treefmt # one CLI to format the code tree - # -- NIXOS UTILS -- - nh # Yet another nix cli helper + # -- (YOUR) EXTRA PKGS -- ]; + # env = { + # MYUSER = "user"; + # # ... + # }; + + # NOTE If you'd like to automatically load a .env file you can use these + # following expressions + # + # dotenv.enable = true; + # dotenv.filename = ".env.development"; + + enterShell = '' + # Welcome splash text + echo ""; echo -e "\e[1;37;42mWelcome to the practicalFlakes devshell!\e[0m"; echo "" + ''; + + # --------------- + # --- SCRIPTS --- + # --------------- + scripts = { + "rename-project".exec = '' + find $1 \( -type d -name .git -prune \) -o -type f -print0 | xargs -0 sed -i "s/practicalFlakes/$2/g" + ''; + }; + + # ----------------- + # --- LANGUAGES --- + # ----------------- languages.nix.enable = true; - difftastic.enable = true; + + # NOTE You can enable additional language support in the following manner + # languages.python.enable = true; + # languages.python.version = "3.11.3"; + + # languages.rust.enable = true; + # languages.rust.channel = "stable"; + + # ---------------------------- + # --- PROCESSES & SERVICES --- + # ---------------------------- + + # ------------------ + # --- CONTAINERS --- + # ------------------ devcontainer.enable = true; - devenv.flakesIntegration = true; + # ---------------------- + # --- BINARY CACHING --- + # ---------------------- + # NOTE Here you can configure automatic cachix binary cache pulling & pushing + # to/from a cache named "mycache" + # + # cachix.pull = [ "pre-commit-hooks" ]; + # cachix.push = "mycache"; + + # ------------------------ + # --- PRE-COMMIT HOOKS --- + # ------------------------ + # NOTE All available hooks options are listed at + # https://devenv.sh/reference/options/#pre-commithooks pre-commit = { hooks = { treefmt.enable = true; - # Everything below is stuff that is missing from treefmt - nil.enable = true; - markdownlint.enable = true; - typos.enable = true; + nil.enable = true; # Nix Language server, an incremental analysis assistant for writing in Nix. + markdownlint.enable = true; # Markdown lint tool + typos.enable = true; # Source code spell checker + editorconfig-checker.enable = true; # A tool to verify that your files are in harmony with your .editorconfig + # actionlint.enable = true; # GitHub workflows linting - # commitizen.enable = true; # Enable if using commitizen + # commitizen.enable = true; # Commitizen is release management tool designed for teams. }; settings = { + # We pass our custom treefmt build from parts/treefmt/treefmt.nix for + # devenv to use. treefmt.package = treefmt; }; }; - scripts = { - "rename-project".exec = '' - find $1 \( -type d -name .git -prune \) -o -type f -print0 | xargs -0 sed -i "s/practicalFlakes/$2/g" - ''; - }; + # -------------- + # --- FLAKES --- + # -------------- + devenv.flakesIntegration = true; - enterShell = '' - # Greeting upon devshell activation - echo ""; echo -e "\e[1;37;42mWelcome to the practicalFlakes devshell!\e[0m"; echo "" - ''; + # This is currently needed for devenv to properly run in pure hermetic + # mode while still being able to run processes & services and modify + # (some parts) of the active shell. + devenv.root = + let + devenvRootFileContent = builtins.readFile devenv-root.outPath; + in + pkgs.lib.mkIf (devenvRootFileContent != "") devenvRootFileContent; + + # --------------------- + # --- MISCELLANEOUS --- + # --------------------- + difftastic.enable = true; } diff --git a/templates/isolated/nix/parts/treefmt/treefmt.nix b/templates/isolated/nix/parts/treefmt/treefmt.nix index 9d2bba2..33578a7 100644 --- a/templates/isolated/nix/parts/treefmt/treefmt.nix +++ b/templates/isolated/nix/parts/treefmt/treefmt.nix @@ -1,6 +1,14 @@ # --- nix/parts/treefmt/treefmt.nix { pkgs, projectPath, ... }: { + # treefmt is a formatting tool that saves you time: it provides + # developers with a universal way to trigger all formatters needed for the + # project in one place. + # For more information refer to + # + # - https://numtide.github.io/treefmt/ + # - https://github.com/numtide/treefmt-nix + package = pkgs.treefmt; flakeCheck = true; flakeFormatter = true; diff --git a/templates/main/.envrc b/templates/main/.envrc index 666703b..6611954 100644 --- a/templates/main/.envrc +++ b/templates/main/.envrc @@ -2,8 +2,11 @@ if ! has nix_direnv_version || ! nix_direnv_version 3.0.4; then source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.4/direnvrc" "sha256-DzlYZ33mWF/Gs8DDeyjr8mnVmQGx7ASYqA5WlxwvBG4=" fi +watch_file flake.nix +watch_file flake.lock watch_file parts/shells/dev.nix -if ! use flake .#dev --impure --accept-flake-config + +if ! use flake .#dev --accept-flake-config --override-input devenv-root "file+file://"<(printf %s "$PWD") then echo "devenv could not be built. The devenv environment was not loaded. Make the necessary changes to devenv.nix and hit enter to try again." >&2 fi diff --git a/templates/main/flake.nix b/templates/main/flake.nix index e9cabc2..2897069 100644 --- a/templates/main/flake.nix +++ b/templates/main/flake.nix @@ -2,24 +2,28 @@ description = "practicalFlakes - TODO Add a description of your new project"; inputs = { - # Base dependencies + # --- BASE DEPENDENCIES --- nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; flake-parts.url = "github:hercules-ci/flake-parts"; systems.url = "github:nix-systems/default"; - # Development (devenv and treefmt dependencies) - treefmt-nix.url = "github:numtide/treefmt-nix"; + # --- DEV DEPENDENCIES --- devenv.url = "github:cachix/devenv"; + devenv-root = { + url = "file+file:///dev/null"; + flake = false; + }; mk-shell-bin.url = "github:rrbutani/nix-mk-shell-bin"; nix2container = { url = "github:nlewo/nix2container"; inputs.nixpkgs.follows = "nixpkgs"; }; + treefmt-nix.url = "github:numtide/treefmt-nix"; - # Project specific dependencies + # --- (NOTE, YOUR) EXTRA DEPENDENCIES --- }; - # Here you can add additional binary cache substituers that you trust. + # NOTE Here you can add additional binary cache substituers that you trust. # There are also some sensible default caches commented out that you # might consider using. nixConfig = { @@ -86,22 +90,21 @@ # - mySimpleModule.nix imports = flatten (mapModules ./parts (x: x)); - # We use the default `systems` defined by the `nix-systems` flake, if you - # need any additional systems, simply add them in the following manner + # NOTE We use the default `systems` defined by the `nix-systems` flake, if + # you need any additional systems, simply add them in the following manner # # `systems = (import inputs.systems) ++ [ "armv7l-linux" ];` systems = import inputs.systems; flake.lib = lib.practicalFlakes; - # Since the official flakes output schema is unfortunately very limited - # you can enable the debug mode if you need to inspect certain outputs - # of your flake. Simply - # + # NOTE Since the official flakes output schema is unfortunately very + # limited you can enable the debug mode if you need to inspect certain + # outputs of your flake. Simply # 1. uncomment the following line # 2. hop into a repl from the project root - `nix repl` # 3. load the flake - `:lf .` - # # After that you can inspect the flake from the root attribute `debug.flake` + # # debug = true; }; } diff --git a/templates/main/parts/shells/default.nix b/templates/main/parts/shells/default.nix index 43caa87..3667714 100644 --- a/templates/main/parts/shells/default.nix +++ b/templates/main/parts/shells/default.nix @@ -7,6 +7,7 @@ { devenv.shells.dev = import ./dev.nix { inherit pkgs projectPath; + inherit (inputs) devenv-root; treefmt = config.treefmt.build.wrapper; }; }; diff --git a/templates/main/parts/shells/dev.nix b/templates/main/parts/shells/dev.nix index 0e546c0..5509586 100644 --- a/templates/main/parts/shells/dev.nix +++ b/templates/main/parts/shells/dev.nix @@ -1,19 +1,28 @@ # --- parts/shells/dev.nix -{ pkgs, treefmt, ... }: { - # Some sensible defaults for a seamless initial experience have been set, - # however, feel free to modify anything you'd like. + pkgs, + treefmt, + devenv-root, + ... +}: +{ + # DEVENV: Fast, Declarative, Reproducible, and Composable Developer + # Environments using Nix developed by Cachix. For more information refer to + # + # - https://devenv.sh/ + # - https://github.com/cachix/devenv + # -------------------------- + # --- ENV & SHELL & PKGS --- + # -------------------------- packages = with pkgs; [ # -- NIX UTILS -- - nil # Yet another language server for Nix - statix # Lints and suggestions for the nix programming language - deadnix # Find and remove unused code in .nix source files nix-output-monitor # Processes output of Nix commands to show helpful and pretty information nixfmt-rfc-style # An opinionated formatter for Nix # NOTE Choose a different formatter if you'd like to # nixfmt # An opinionated formatter for Nix # alejandra # The Uncompromising Nix Code Formatter + nh # Yet another nix cli helper # -- GIT RELATED UTILS -- # commitizen # Tool to create committing rules for projects, auto bump versions, and generate changelogs @@ -21,45 +30,109 @@ # fh # The official FlakeHub CLI # gh # GitHub CLI tool - # -- LANGUAGE RELATED UTILS -- + # -- BASE LANG UTILS -- markdownlint-cli # Command line interface for MarkdownLint - nodePackages.prettier # Prettier is an opinionated code formatter typos # Source code spell checker treefmt # one CLI to format the code tree - # -- NIXOS UTILS -- - nh # Yet another nix cli helper + # -- (YOUR) EXTRA PKGS -- ]; + # env = { + # MYUSER = "user"; + # # ... + # }; + + # NOTE If you'd like to automatically load a .env file you can use these + # following expressions + # + # dotenv.enable = true; + # dotenv.filename = ".env.development"; + + enterShell = '' + # Welcome splash text + echo ""; echo -e "\e[1;37;42mWelcome to the practicalFlakes devshell!\e[0m"; echo "" + ''; + + # --------------- + # --- SCRIPTS --- + # --------------- + scripts = { + "rename-project".exec = '' + find $1 \( -type d -name .git -prune \) -o -type f -print0 | xargs -0 sed -i "s/practicalFlakes/$2/g" + ''; + }; + + # ----------------- + # --- LANGUAGES --- + # ----------------- languages.nix.enable = true; - difftastic.enable = true; + + # NOTE You can enable additional language support in the following manner + # languages.python.enable = true; + # languages.python.version = "3.11.3"; + + # languages.rust.enable = true; + # languages.rust.channel = "stable"; + + # ---------------------------- + # --- PROCESSES & SERVICES --- + # ---------------------------- + + # ------------------ + # --- CONTAINERS --- + # ------------------ devcontainer.enable = true; - devenv.flakesIntegration = true; + # ---------------------- + # --- BINARY CACHING --- + # ---------------------- + # NOTE Here you can configure automatic cachix binary cache pulling & pushing + # to/from a cache named "mycache" + # + # cachix.pull = [ "pre-commit-hooks" ]; + # cachix.push = "mycache"; + + # ------------------------ + # --- PRE-COMMIT HOOKS --- + # ------------------------ + # NOTE All available hooks options are listed at + # https://devenv.sh/reference/options/#pre-commithooks pre-commit = { hooks = { treefmt.enable = true; - # Everything below is stuff that is missing from treefmt - nil.enable = true; - markdownlint.enable = true; - typos.enable = true; + nil.enable = true; # Nix Language server, an incremental analysis assistant for writing in Nix. + markdownlint.enable = true; # Markdown lint tool + typos.enable = true; # Source code spell checker + editorconfig-checker.enable = true; # A tool to verify that your files are in harmony with your .editorconfig + # actionlint.enable = true; # GitHub workflows linting - # commitizen.enable = true; # Enable if using commitizen + # commitizen.enable = true; # Commitizen is release management tool designed for teams. }; settings = { + # We pass our custom treefmt build from parts/treefmt/treefmt.nix for + # devenv to use. treefmt.package = treefmt; }; }; - scripts = { - "rename-project".exec = '' - find $1 \( -type d -name .git -prune \) -o -type f -print0 | xargs -0 sed -i "s/practicalFlakes/$2/g" - ''; - }; + # -------------- + # --- FLAKES --- + # -------------- + devenv.flakesIntegration = true; - enterShell = '' - # Greeting upon devshell activation - echo ""; echo -e "\e[1;37;42mWelcome to the practicalFlakes devshell!\e[0m"; echo "" - ''; + # This is currently needed for devenv to properly run in pure hermetic + # mode while still being able to run processes & services and modify + # (some parts) of the active shell. + devenv.root = + let + devenvRootFileContent = builtins.readFile devenv-root.outPath; + in + pkgs.lib.mkIf (devenvRootFileContent != "") devenvRootFileContent; + + # --------------------- + # --- MISCELLANEOUS --- + # --------------------- + difftastic.enable = true; } diff --git a/templates/main/parts/treefmt/treefmt.nix b/templates/main/parts/treefmt/treefmt.nix index 4c712b4..d9578ec 100644 --- a/templates/main/parts/treefmt/treefmt.nix +++ b/templates/main/parts/treefmt/treefmt.nix @@ -1,6 +1,14 @@ # --- parts/treefmt/treefmt.nix { pkgs, projectPath, ... }: { + # treefmt is a formatting tool that saves you time: it provides + # developers with a universal way to trigger all formatters needed for the + # project in one place. + # For more information refer to + # + # - https://numtide.github.io/treefmt/ + # - https://github.com/numtide/treefmt-nix + package = pkgs.treefmt; flakeCheck = true; flakeFormatter = true; diff --git a/templates/minimal/.envrc b/templates/minimal/.envrc index 666703b..6611954 100644 --- a/templates/minimal/.envrc +++ b/templates/minimal/.envrc @@ -2,8 +2,11 @@ if ! has nix_direnv_version || ! nix_direnv_version 3.0.4; then source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.4/direnvrc" "sha256-DzlYZ33mWF/Gs8DDeyjr8mnVmQGx7ASYqA5WlxwvBG4=" fi +watch_file flake.nix +watch_file flake.lock watch_file parts/shells/dev.nix -if ! use flake .#dev --impure --accept-flake-config + +if ! use flake .#dev --accept-flake-config --override-input devenv-root "file+file://"<(printf %s "$PWD") then echo "devenv could not be built. The devenv environment was not loaded. Make the necessary changes to devenv.nix and hit enter to try again." >&2 fi diff --git a/templates/minimal/flake.nix b/templates/minimal/flake.nix index e9cabc2..2897069 100644 --- a/templates/minimal/flake.nix +++ b/templates/minimal/flake.nix @@ -2,24 +2,28 @@ description = "practicalFlakes - TODO Add a description of your new project"; inputs = { - # Base dependencies + # --- BASE DEPENDENCIES --- nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; flake-parts.url = "github:hercules-ci/flake-parts"; systems.url = "github:nix-systems/default"; - # Development (devenv and treefmt dependencies) - treefmt-nix.url = "github:numtide/treefmt-nix"; + # --- DEV DEPENDENCIES --- devenv.url = "github:cachix/devenv"; + devenv-root = { + url = "file+file:///dev/null"; + flake = false; + }; mk-shell-bin.url = "github:rrbutani/nix-mk-shell-bin"; nix2container = { url = "github:nlewo/nix2container"; inputs.nixpkgs.follows = "nixpkgs"; }; + treefmt-nix.url = "github:numtide/treefmt-nix"; - # Project specific dependencies + # --- (NOTE, YOUR) EXTRA DEPENDENCIES --- }; - # Here you can add additional binary cache substituers that you trust. + # NOTE Here you can add additional binary cache substituers that you trust. # There are also some sensible default caches commented out that you # might consider using. nixConfig = { @@ -86,22 +90,21 @@ # - mySimpleModule.nix imports = flatten (mapModules ./parts (x: x)); - # We use the default `systems` defined by the `nix-systems` flake, if you - # need any additional systems, simply add them in the following manner + # NOTE We use the default `systems` defined by the `nix-systems` flake, if + # you need any additional systems, simply add them in the following manner # # `systems = (import inputs.systems) ++ [ "armv7l-linux" ];` systems = import inputs.systems; flake.lib = lib.practicalFlakes; - # Since the official flakes output schema is unfortunately very limited - # you can enable the debug mode if you need to inspect certain outputs - # of your flake. Simply - # + # NOTE Since the official flakes output schema is unfortunately very + # limited you can enable the debug mode if you need to inspect certain + # outputs of your flake. Simply # 1. uncomment the following line # 2. hop into a repl from the project root - `nix repl` # 3. load the flake - `:lf .` - # # After that you can inspect the flake from the root attribute `debug.flake` + # # debug = true; }; } diff --git a/templates/minimal/parts/shells/default.nix b/templates/minimal/parts/shells/default.nix index 43caa87..3667714 100644 --- a/templates/minimal/parts/shells/default.nix +++ b/templates/minimal/parts/shells/default.nix @@ -7,6 +7,7 @@ { devenv.shells.dev = import ./dev.nix { inherit pkgs projectPath; + inherit (inputs) devenv-root; treefmt = config.treefmt.build.wrapper; }; }; diff --git a/templates/minimal/parts/shells/dev.nix b/templates/minimal/parts/shells/dev.nix index 0e546c0..53b231b 100644 --- a/templates/minimal/parts/shells/dev.nix +++ b/templates/minimal/parts/shells/dev.nix @@ -1,19 +1,29 @@ # --- parts/shells/dev.nix -{ pkgs, treefmt, ... }: + +{ + pkgs, + treefmt, + devenv-root, + ... +}: { - # Some sensible defaults for a seamless initial experience have been set, - # however, feel free to modify anything you'd like. + # DEVENV: Fast, Declarative, Reproducible, and Composable Developer + # Environments using Nix developed by Cachix. For more information refer to + # + # - https://devenv.sh/ + # - https://github.com/cachix/devenv + # -------------------------- + # --- ENV & SHELL & PKGS --- + # -------------------------- packages = with pkgs; [ # -- NIX UTILS -- - nil # Yet another language server for Nix - statix # Lints and suggestions for the nix programming language - deadnix # Find and remove unused code in .nix source files nix-output-monitor # Processes output of Nix commands to show helpful and pretty information nixfmt-rfc-style # An opinionated formatter for Nix # NOTE Choose a different formatter if you'd like to # nixfmt # An opinionated formatter for Nix # alejandra # The Uncompromising Nix Code Formatter + nh # Yet another nix cli helper # -- GIT RELATED UTILS -- # commitizen # Tool to create committing rules for projects, auto bump versions, and generate changelogs @@ -21,45 +31,86 @@ # fh # The official FlakeHub CLI # gh # GitHub CLI tool - # -- LANGUAGE RELATED UTILS -- + # -- BASE LANG UTILS -- markdownlint-cli # Command line interface for MarkdownLint - nodePackages.prettier # Prettier is an opinionated code formatter typos # Source code spell checker treefmt # one CLI to format the code tree - # -- NIXOS UTILS -- - nh # Yet another nix cli helper + # -- (YOUR) EXTRA PKGS -- ]; + enterShell = '' + # Welcome splash text + echo ""; echo -e "\e[1;37;42mWelcome to the practicalFlakes devshell!\e[0m"; echo "" + ''; + + # --------------- + # --- SCRIPTS --- + # --------------- + scripts = { + "rename-project".exec = '' + find $1 \( -type d -name .git -prune \) -o -type f -print0 | xargs -0 sed -i "s/practicalFlakes/$2/g" + ''; + }; + + # ----------------- + # --- LANGUAGES --- + # ----------------- languages.nix.enable = true; - difftastic.enable = true; + + # ---------------------------- + # --- PROCESSES & SERVICES --- + # ---------------------------- + + # ------------------ + # --- CONTAINERS --- + # ------------------ devcontainer.enable = true; - devenv.flakesIntegration = true; + # ---------------------- + # --- BINARY CACHING --- + # ---------------------- + + # ------------------------ + # --- PRE-COMMIT HOOKS --- + # ------------------------ + # NOTE All available hooks options are listed at + # https://devenv.sh/reference/options/#pre-commithooks pre-commit = { hooks = { treefmt.enable = true; - # Everything below is stuff that is missing from treefmt - nil.enable = true; - markdownlint.enable = true; - typos.enable = true; + nil.enable = true; # Nix Language server, an incremental analysis assistant for writing in Nix. + markdownlint.enable = true; # Markdown lint tool + typos.enable = true; # Source code spell checker + editorconfig-checker.enable = true; # A tool to verify that your files are in harmony with your .editorconfig + # actionlint.enable = true; # GitHub workflows linting - # commitizen.enable = true; # Enable if using commitizen + # commitizen.enable = true; # Commitizen is release management tool designed for teams. }; settings = { + # We pass our custom treefmt build from parts/treefmt/treefmt.nix for + # devenv to use. treefmt.package = treefmt; }; }; - scripts = { - "rename-project".exec = '' - find $1 \( -type d -name .git -prune \) -o -type f -print0 | xargs -0 sed -i "s/practicalFlakes/$2/g" - ''; - }; + # -------------- + # --- FLAKES --- + # -------------- + devenv.flakesIntegration = true; - enterShell = '' - # Greeting upon devshell activation - echo ""; echo -e "\e[1;37;42mWelcome to the practicalFlakes devshell!\e[0m"; echo "" - ''; + # This is currently needed for devenv to properly run in pure hermetic + # mode while still being able to run processes & services and modify + # (some parts) of the active shell. + devenv.root = + let + devenvRootFileContent = builtins.readFile devenv-root.outPath; + in + pkgs.lib.mkIf (devenvRootFileContent != "") devenvRootFileContent; + + # --------------------- + # --- MISCELLANEOUS --- + # --------------------- + difftastic.enable = true; } diff --git a/templates/minimal/parts/treefmt/treefmt.nix b/templates/minimal/parts/treefmt/treefmt.nix index 4c712b4..40c34e4 100644 --- a/templates/minimal/parts/treefmt/treefmt.nix +++ b/templates/minimal/parts/treefmt/treefmt.nix @@ -1,6 +1,14 @@ # --- parts/treefmt/treefmt.nix { pkgs, projectPath, ... }: { + # treefmt is a formatting tool that saves you time: it provides + # developers with a universal way to trigger all formatters needed for the + # project in one place. + # For more information refer to + # + # - https://numtide.github.io/treefmt/ + # - https://github.com/numtide/treefmt-nix + # package = pkgs.treefmt; flakeCheck = true; flakeFormatter = true; From 79832ae115a0b9acc29d5e3fc1d2681687907476 Mon Sep 17 00:00:00 2001 From: tsandrini Date: Fri, 29 Mar 2024 16:49:53 +0100 Subject: [PATCH 4/5] docs(README): update templates with new information --- .github/pull_request_template.md | 16 +++++++++------- .github/workflows/check-on-merge.yml | 6 +----- README.md | 15 +++++++-------- flake.nix | 10 ++++++++-- templates/home/.github/pull_request_template.md | 16 +++++++++------- .../home/.github/workflows/check-on-merge.yml | 6 +----- templates/home/.gitlab-ci.yml | 5 +---- templates/home/README.md | 5 +++-- .../.github/pull_request_template.md | 16 +++++++++------- .../.github/workflows/check-on-merge.yml | 6 +----- templates/isolated-minimal/.gitlab-ci.yml | 5 +---- templates/isolated-minimal/README.md | 5 +++-- .../isolated/.github/pull_request_template.md | 16 +++++++++------- .../.github/workflows/check-on-merge.yml | 6 +----- templates/isolated/.gitlab-ci.yml | 5 +---- templates/isolated/README.md | 5 +++-- templates/main/.github/pull_request_template.md | 16 +++++++++------- .../main/.github/workflows/check-on-merge.yml | 6 +----- templates/main/.gitlab-ci.yml | 5 +---- templates/main/README.md | 5 +++-- .../minimal/.github/pull_request_template.md | 16 +++++++++------- .../minimal/.github/workflows/check-on-merge.yml | 6 +----- templates/minimal/.gitlab-ci.yml | 5 +---- templates/minimal/README.md | 5 +++-- 24 files changed, 95 insertions(+), 112 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 293e857..b85deb4 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -27,13 +27,15 @@ updates (if applicable). --> -- [ ] I have tested the relevant changes locally. -- [ ] I have checked that `nix flake check --impure` passes. -- [ ] I have ensured my commits follow the project's conventional commits guidelines. -- [ ] I have checked that the changes follow a linear history. -- [ ] (If applicable) I have commented any relevant parts of my code. -- [ ] (If applicable) I have added appropriate unit/feature tests. -- [ ] (If applicable) I have updated the documentation accordingly (in English). +- \[ \] I have tested the relevant changes locally. +- \[ \] I have checked that + `nix flake check --override-input devenv-root "file+file://"<(printf %s "$PWD")` + passes. +- \[ \] I have ensured my commits follow the project's conventional commits guidelines. +- \[ \] I have checked that the changes follow a linear history. +- \[ \] (If applicable) I have commented any relevant parts of my code. +- \[ \] (If applicable) I have added appropriate unit/feature tests. +- \[ \] (If applicable) I have updated the documentation accordingly (in English). ## Additional Notes diff --git a/.github/workflows/check-on-merge.yml b/.github/workflows/check-on-merge.yml index 8b49525..abfe3a8 100644 --- a/.github/workflows/check-on-merge.yml +++ b/.github/workflows/check-on-merge.yml @@ -1,9 +1,7 @@ name: "flake check" - on: pull_request: types: [opened, reopened, synchronize] - jobs: check: # if: false # NOTE: Uncomment this line to disable the workflow @@ -12,8 +10,6 @@ jobs: - uses: actions/checkout@v4 - uses: DeterminateSystems/nix-installer-action@main - uses: DeterminateSystems/magic-nix-cache-action@main - - - run: nix flake check --impure --show-trace --accept-flake-config - + - run: nix flake check --override-input devenv-root "file+file://"<(printf %s "$PWD") --show-trace --accept-flake-config - name: Check Nix flake Nixpkgs inputs uses: DeterminateSystems/flake-checker-action@main diff --git a/README.md b/README.md index 34cf24a..6f49995 100644 --- a/README.md +++ b/README.md @@ -27,28 +27,27 @@ And you're good to go! 👍 [NixOS modules](https://nixos.wiki/wiki/NixOS_Modules), [home-manager](https://github.com/nix-community/home-manager) userspace, you can always use the same underlying structure -2. [devenv.sh](https://github.com/cachix/devenv) is awesome! 🔥 +1. [devenv.sh](https://github.com/cachix/devenv) is awesome! 🔥 - includes a devenv shell already preconfigured to format and lint nix -3. [treefmt](https://github.com/numtide/treefmt) is the one and only formatter +1. [treefmt](https://github.com/numtide/treefmt) is the one and only formatter to rule them all 🙏 -4. Already preconfigured [github actions](https://docs.github.com/en/actions) +1. Already preconfigured [github actions](https://docs.github.com/en/actions) and [gitlab CI](https://docs.gitlab.com/ee/ci/) 💪 - automatic `nix flake check` on pull/merge requests - automatic nixpkgs flake inputs checker (github only) - automatic cron based flake inputs updates (github only) - (optional) push to [FlakeHub](https://flakehub.com/) -5. Prepared for custom `lib` overrides 🤓 +1. Prepared for custom `lib` overrides 🤓 - depending on what you're currently aiming to write, you might need some custom helpers or library functions, this template already set ups all the necessary boilerplate to get it all going -6. And finally, examples included 🖌️ +1. And finally, examples included 🖌️ ## Usage After a proper installation process you can enter the development environment - -1. either using [direnv](https://github.com/direnv/direnv) `direnv allow` -2. or directly `nix develop .#dev --impure` +with `direnv allow` (or alternatively +`nix develop .#dev --override-input devenv-root "file+file://"<(printf %s "$PWD")`) While not many, the code has some required references to the `practicalFlakes` identifier. This can be renamed in the whole project using the script diff --git a/flake.nix b/flake.nix index b46ae7f..125d8c2 100644 --- a/flake.nix +++ b/flake.nix @@ -57,7 +57,6 @@ Hi! You've just created a fresh new flakes project using the practical-flakes-template. You can start by looking around or running the development environment either via direnv (`direnv allow`) - or `nix develop .#dev --impure`. Furthermore don't forget to rename your project using `rename-project . myAwesomeNewProject` @@ -111,11 +110,18 @@ programs = { deadnix.enable = true; statix.enable = true; - prettier.enable = true; nixfmt-rfc-style.enable = true; # NOTE Choose a different formatter if you'd like to # nixfmt.enable = true; # alejandra.enable = true; + + prettier.enable = true; + mdformat.enable = true; + yamlfmt.enable = true; + jsonfmt.enable = true; + + shellcheck.enable = true; + shfmt.enable = true; }; }; diff --git a/templates/home/.github/pull_request_template.md b/templates/home/.github/pull_request_template.md index c49451d..c3811fd 100644 --- a/templates/home/.github/pull_request_template.md +++ b/templates/home/.github/pull_request_template.md @@ -27,13 +27,15 @@ updates (if applicable). --> -- [ ] I have tested the relevant changes locally. -- [ ] I have checked that `nix flake check --impure` passes. -- [ ] I have ensured my commits follow the project's commits guidelines. -- [ ] I have checked that the changes follow a linear history. -- [ ] (If applicable) I have commented any relevant parts of my code. -- [ ] (If applicable) I have added appropriate unit/feature tests. -- [ ] (If applicable) I have updated the documentation accordingly (in English). +- \[ \] I have tested the relevant changes locally. +- \[ \] I have checked that + `nix flake check --override-input devenv-root "file+file://"<(printf %s "$PWD")` + passes. +- \[ \] I have ensured my commits follow the project's commits guidelines. +- \[ \] I have checked that the changes follow a linear history. +- \[ \] (If applicable) I have commented any relevant parts of my code. +- \[ \] (If applicable) I have added appropriate unit/feature tests. +- \[ \] (If applicable) I have updated the documentation accordingly (in English). ## Additional Notes diff --git a/templates/home/.github/workflows/check-on-merge.yml b/templates/home/.github/workflows/check-on-merge.yml index 8b49525..abfe3a8 100644 --- a/templates/home/.github/workflows/check-on-merge.yml +++ b/templates/home/.github/workflows/check-on-merge.yml @@ -1,9 +1,7 @@ name: "flake check" - on: pull_request: types: [opened, reopened, synchronize] - jobs: check: # if: false # NOTE: Uncomment this line to disable the workflow @@ -12,8 +10,6 @@ jobs: - uses: actions/checkout@v4 - uses: DeterminateSystems/nix-installer-action@main - uses: DeterminateSystems/magic-nix-cache-action@main - - - run: nix flake check --impure --show-trace --accept-flake-config - + - run: nix flake check --override-input devenv-root "file+file://"<(printf %s "$PWD") --show-trace --accept-flake-config - name: Check Nix flake Nixpkgs inputs uses: DeterminateSystems/flake-checker-action@main diff --git a/templates/home/.gitlab-ci.yml b/templates/home/.gitlab-ci.yml index 60a79fa..2d3fabf 100644 --- a/templates/home/.gitlab-ci.yml +++ b/templates/home/.gitlab-ci.yml @@ -1,13 +1,10 @@ image: nixos/nix:latest - variables: NIX_CONF_DIR: "/etc/nix" - before_script: - echo 'experimental-features = nix-command flakes' > $NIX_CONF_DIR/nix.conf - check: script: - - nix flake check --impure --show-trace --accept-flake-config + - nix flake check --override-input devenv-root "file+file://"<(printf %s "$PWD") --show-trace --accept-flake-config rules: - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' diff --git a/templates/home/README.md b/templates/home/README.md index 2c45761..23a85fe 100644 --- a/templates/home/README.md +++ b/templates/home/README.md @@ -8,8 +8,9 @@ project. The next steps for your development are 1. **development environment** - either use [direnv](https://github.com/direnv/direnv) and `direnv allow` - - or explicitly enter the shell via `nix develop .#dev --impure` -2. **rename the project** + - or explicitly enter the shell via + `nix develop .#dev --override-input devenv-root "file+file://"<(printf %s "$PWD")` +1. **rename the project** - while not many, there are some places in the code that have a `practicalFlakes` identifier, you can use the `rename-project` (available in the dev environment) script to change these diff --git a/templates/isolated-minimal/.github/pull_request_template.md b/templates/isolated-minimal/.github/pull_request_template.md index c49451d..c3811fd 100644 --- a/templates/isolated-minimal/.github/pull_request_template.md +++ b/templates/isolated-minimal/.github/pull_request_template.md @@ -27,13 +27,15 @@ updates (if applicable). --> -- [ ] I have tested the relevant changes locally. -- [ ] I have checked that `nix flake check --impure` passes. -- [ ] I have ensured my commits follow the project's commits guidelines. -- [ ] I have checked that the changes follow a linear history. -- [ ] (If applicable) I have commented any relevant parts of my code. -- [ ] (If applicable) I have added appropriate unit/feature tests. -- [ ] (If applicable) I have updated the documentation accordingly (in English). +- \[ \] I have tested the relevant changes locally. +- \[ \] I have checked that + `nix flake check --override-input devenv-root "file+file://"<(printf %s "$PWD")` + passes. +- \[ \] I have ensured my commits follow the project's commits guidelines. +- \[ \] I have checked that the changes follow a linear history. +- \[ \] (If applicable) I have commented any relevant parts of my code. +- \[ \] (If applicable) I have added appropriate unit/feature tests. +- \[ \] (If applicable) I have updated the documentation accordingly (in English). ## Additional Notes diff --git a/templates/isolated-minimal/.github/workflows/check-on-merge.yml b/templates/isolated-minimal/.github/workflows/check-on-merge.yml index 8b49525..abfe3a8 100644 --- a/templates/isolated-minimal/.github/workflows/check-on-merge.yml +++ b/templates/isolated-minimal/.github/workflows/check-on-merge.yml @@ -1,9 +1,7 @@ name: "flake check" - on: pull_request: types: [opened, reopened, synchronize] - jobs: check: # if: false # NOTE: Uncomment this line to disable the workflow @@ -12,8 +10,6 @@ jobs: - uses: actions/checkout@v4 - uses: DeterminateSystems/nix-installer-action@main - uses: DeterminateSystems/magic-nix-cache-action@main - - - run: nix flake check --impure --show-trace --accept-flake-config - + - run: nix flake check --override-input devenv-root "file+file://"<(printf %s "$PWD") --show-trace --accept-flake-config - name: Check Nix flake Nixpkgs inputs uses: DeterminateSystems/flake-checker-action@main diff --git a/templates/isolated-minimal/.gitlab-ci.yml b/templates/isolated-minimal/.gitlab-ci.yml index 60a79fa..2d3fabf 100644 --- a/templates/isolated-minimal/.gitlab-ci.yml +++ b/templates/isolated-minimal/.gitlab-ci.yml @@ -1,13 +1,10 @@ image: nixos/nix:latest - variables: NIX_CONF_DIR: "/etc/nix" - before_script: - echo 'experimental-features = nix-command flakes' > $NIX_CONF_DIR/nix.conf - check: script: - - nix flake check --impure --show-trace --accept-flake-config + - nix flake check --override-input devenv-root "file+file://"<(printf %s "$PWD") --show-trace --accept-flake-config rules: - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' diff --git a/templates/isolated-minimal/README.md b/templates/isolated-minimal/README.md index 2c45761..23a85fe 100644 --- a/templates/isolated-minimal/README.md +++ b/templates/isolated-minimal/README.md @@ -8,8 +8,9 @@ project. The next steps for your development are 1. **development environment** - either use [direnv](https://github.com/direnv/direnv) and `direnv allow` - - or explicitly enter the shell via `nix develop .#dev --impure` -2. **rename the project** + - or explicitly enter the shell via + `nix develop .#dev --override-input devenv-root "file+file://"<(printf %s "$PWD")` +1. **rename the project** - while not many, there are some places in the code that have a `practicalFlakes` identifier, you can use the `rename-project` (available in the dev environment) script to change these diff --git a/templates/isolated/.github/pull_request_template.md b/templates/isolated/.github/pull_request_template.md index c49451d..c3811fd 100644 --- a/templates/isolated/.github/pull_request_template.md +++ b/templates/isolated/.github/pull_request_template.md @@ -27,13 +27,15 @@ updates (if applicable). --> -- [ ] I have tested the relevant changes locally. -- [ ] I have checked that `nix flake check --impure` passes. -- [ ] I have ensured my commits follow the project's commits guidelines. -- [ ] I have checked that the changes follow a linear history. -- [ ] (If applicable) I have commented any relevant parts of my code. -- [ ] (If applicable) I have added appropriate unit/feature tests. -- [ ] (If applicable) I have updated the documentation accordingly (in English). +- \[ \] I have tested the relevant changes locally. +- \[ \] I have checked that + `nix flake check --override-input devenv-root "file+file://"<(printf %s "$PWD")` + passes. +- \[ \] I have ensured my commits follow the project's commits guidelines. +- \[ \] I have checked that the changes follow a linear history. +- \[ \] (If applicable) I have commented any relevant parts of my code. +- \[ \] (If applicable) I have added appropriate unit/feature tests. +- \[ \] (If applicable) I have updated the documentation accordingly (in English). ## Additional Notes diff --git a/templates/isolated/.github/workflows/check-on-merge.yml b/templates/isolated/.github/workflows/check-on-merge.yml index 8b49525..abfe3a8 100644 --- a/templates/isolated/.github/workflows/check-on-merge.yml +++ b/templates/isolated/.github/workflows/check-on-merge.yml @@ -1,9 +1,7 @@ name: "flake check" - on: pull_request: types: [opened, reopened, synchronize] - jobs: check: # if: false # NOTE: Uncomment this line to disable the workflow @@ -12,8 +10,6 @@ jobs: - uses: actions/checkout@v4 - uses: DeterminateSystems/nix-installer-action@main - uses: DeterminateSystems/magic-nix-cache-action@main - - - run: nix flake check --impure --show-trace --accept-flake-config - + - run: nix flake check --override-input devenv-root "file+file://"<(printf %s "$PWD") --show-trace --accept-flake-config - name: Check Nix flake Nixpkgs inputs uses: DeterminateSystems/flake-checker-action@main diff --git a/templates/isolated/.gitlab-ci.yml b/templates/isolated/.gitlab-ci.yml index 60a79fa..2d3fabf 100644 --- a/templates/isolated/.gitlab-ci.yml +++ b/templates/isolated/.gitlab-ci.yml @@ -1,13 +1,10 @@ image: nixos/nix:latest - variables: NIX_CONF_DIR: "/etc/nix" - before_script: - echo 'experimental-features = nix-command flakes' > $NIX_CONF_DIR/nix.conf - check: script: - - nix flake check --impure --show-trace --accept-flake-config + - nix flake check --override-input devenv-root "file+file://"<(printf %s "$PWD") --show-trace --accept-flake-config rules: - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' diff --git a/templates/isolated/README.md b/templates/isolated/README.md index 2c45761..23a85fe 100644 --- a/templates/isolated/README.md +++ b/templates/isolated/README.md @@ -8,8 +8,9 @@ project. The next steps for your development are 1. **development environment** - either use [direnv](https://github.com/direnv/direnv) and `direnv allow` - - or explicitly enter the shell via `nix develop .#dev --impure` -2. **rename the project** + - or explicitly enter the shell via + `nix develop .#dev --override-input devenv-root "file+file://"<(printf %s "$PWD")` +1. **rename the project** - while not many, there are some places in the code that have a `practicalFlakes` identifier, you can use the `rename-project` (available in the dev environment) script to change these diff --git a/templates/main/.github/pull_request_template.md b/templates/main/.github/pull_request_template.md index c49451d..c3811fd 100644 --- a/templates/main/.github/pull_request_template.md +++ b/templates/main/.github/pull_request_template.md @@ -27,13 +27,15 @@ updates (if applicable). --> -- [ ] I have tested the relevant changes locally. -- [ ] I have checked that `nix flake check --impure` passes. -- [ ] I have ensured my commits follow the project's commits guidelines. -- [ ] I have checked that the changes follow a linear history. -- [ ] (If applicable) I have commented any relevant parts of my code. -- [ ] (If applicable) I have added appropriate unit/feature tests. -- [ ] (If applicable) I have updated the documentation accordingly (in English). +- \[ \] I have tested the relevant changes locally. +- \[ \] I have checked that + `nix flake check --override-input devenv-root "file+file://"<(printf %s "$PWD")` + passes. +- \[ \] I have ensured my commits follow the project's commits guidelines. +- \[ \] I have checked that the changes follow a linear history. +- \[ \] (If applicable) I have commented any relevant parts of my code. +- \[ \] (If applicable) I have added appropriate unit/feature tests. +- \[ \] (If applicable) I have updated the documentation accordingly (in English). ## Additional Notes diff --git a/templates/main/.github/workflows/check-on-merge.yml b/templates/main/.github/workflows/check-on-merge.yml index 8b49525..abfe3a8 100644 --- a/templates/main/.github/workflows/check-on-merge.yml +++ b/templates/main/.github/workflows/check-on-merge.yml @@ -1,9 +1,7 @@ name: "flake check" - on: pull_request: types: [opened, reopened, synchronize] - jobs: check: # if: false # NOTE: Uncomment this line to disable the workflow @@ -12,8 +10,6 @@ jobs: - uses: actions/checkout@v4 - uses: DeterminateSystems/nix-installer-action@main - uses: DeterminateSystems/magic-nix-cache-action@main - - - run: nix flake check --impure --show-trace --accept-flake-config - + - run: nix flake check --override-input devenv-root "file+file://"<(printf %s "$PWD") --show-trace --accept-flake-config - name: Check Nix flake Nixpkgs inputs uses: DeterminateSystems/flake-checker-action@main diff --git a/templates/main/.gitlab-ci.yml b/templates/main/.gitlab-ci.yml index 60a79fa..2d3fabf 100644 --- a/templates/main/.gitlab-ci.yml +++ b/templates/main/.gitlab-ci.yml @@ -1,13 +1,10 @@ image: nixos/nix:latest - variables: NIX_CONF_DIR: "/etc/nix" - before_script: - echo 'experimental-features = nix-command flakes' > $NIX_CONF_DIR/nix.conf - check: script: - - nix flake check --impure --show-trace --accept-flake-config + - nix flake check --override-input devenv-root "file+file://"<(printf %s "$PWD") --show-trace --accept-flake-config rules: - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' diff --git a/templates/main/README.md b/templates/main/README.md index 2c45761..23a85fe 100644 --- a/templates/main/README.md +++ b/templates/main/README.md @@ -8,8 +8,9 @@ project. The next steps for your development are 1. **development environment** - either use [direnv](https://github.com/direnv/direnv) and `direnv allow` - - or explicitly enter the shell via `nix develop .#dev --impure` -2. **rename the project** + - or explicitly enter the shell via + `nix develop .#dev --override-input devenv-root "file+file://"<(printf %s "$PWD")` +1. **rename the project** - while not many, there are some places in the code that have a `practicalFlakes` identifier, you can use the `rename-project` (available in the dev environment) script to change these diff --git a/templates/minimal/.github/pull_request_template.md b/templates/minimal/.github/pull_request_template.md index c49451d..c3811fd 100644 --- a/templates/minimal/.github/pull_request_template.md +++ b/templates/minimal/.github/pull_request_template.md @@ -27,13 +27,15 @@ updates (if applicable). --> -- [ ] I have tested the relevant changes locally. -- [ ] I have checked that `nix flake check --impure` passes. -- [ ] I have ensured my commits follow the project's commits guidelines. -- [ ] I have checked that the changes follow a linear history. -- [ ] (If applicable) I have commented any relevant parts of my code. -- [ ] (If applicable) I have added appropriate unit/feature tests. -- [ ] (If applicable) I have updated the documentation accordingly (in English). +- \[ \] I have tested the relevant changes locally. +- \[ \] I have checked that + `nix flake check --override-input devenv-root "file+file://"<(printf %s "$PWD")` + passes. +- \[ \] I have ensured my commits follow the project's commits guidelines. +- \[ \] I have checked that the changes follow a linear history. +- \[ \] (If applicable) I have commented any relevant parts of my code. +- \[ \] (If applicable) I have added appropriate unit/feature tests. +- \[ \] (If applicable) I have updated the documentation accordingly (in English). ## Additional Notes diff --git a/templates/minimal/.github/workflows/check-on-merge.yml b/templates/minimal/.github/workflows/check-on-merge.yml index 8b49525..abfe3a8 100644 --- a/templates/minimal/.github/workflows/check-on-merge.yml +++ b/templates/minimal/.github/workflows/check-on-merge.yml @@ -1,9 +1,7 @@ name: "flake check" - on: pull_request: types: [opened, reopened, synchronize] - jobs: check: # if: false # NOTE: Uncomment this line to disable the workflow @@ -12,8 +10,6 @@ jobs: - uses: actions/checkout@v4 - uses: DeterminateSystems/nix-installer-action@main - uses: DeterminateSystems/magic-nix-cache-action@main - - - run: nix flake check --impure --show-trace --accept-flake-config - + - run: nix flake check --override-input devenv-root "file+file://"<(printf %s "$PWD") --show-trace --accept-flake-config - name: Check Nix flake Nixpkgs inputs uses: DeterminateSystems/flake-checker-action@main diff --git a/templates/minimal/.gitlab-ci.yml b/templates/minimal/.gitlab-ci.yml index 60a79fa..2d3fabf 100644 --- a/templates/minimal/.gitlab-ci.yml +++ b/templates/minimal/.gitlab-ci.yml @@ -1,13 +1,10 @@ image: nixos/nix:latest - variables: NIX_CONF_DIR: "/etc/nix" - before_script: - echo 'experimental-features = nix-command flakes' > $NIX_CONF_DIR/nix.conf - check: script: - - nix flake check --impure --show-trace --accept-flake-config + - nix flake check --override-input devenv-root "file+file://"<(printf %s "$PWD") --show-trace --accept-flake-config rules: - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' diff --git a/templates/minimal/README.md b/templates/minimal/README.md index 2c45761..23a85fe 100644 --- a/templates/minimal/README.md +++ b/templates/minimal/README.md @@ -8,8 +8,9 @@ project. The next steps for your development are 1. **development environment** - either use [direnv](https://github.com/direnv/direnv) and `direnv allow` - - or explicitly enter the shell via `nix develop .#dev --impure` -2. **rename the project** + - or explicitly enter the shell via + `nix develop .#dev --override-input devenv-root "file+file://"<(printf %s "$PWD")` +1. **rename the project** - while not many, there are some places in the code that have a `practicalFlakes` identifier, you can use the `rename-project` (available in the dev environment) script to change these From b2e5ae72cdd758416d0214ec6f9d1913789752d4 Mon Sep 17 00:00:00 2001 From: tsandrini Date: Fri, 29 Mar 2024 17:03:48 +0100 Subject: [PATCH 5/5] feat(treefmt): update defaults --- templates/home/parts/treefmt/treefmt.nix | 16 ++++++++++------ .../nix/parts/treefmt/treefmt.nix | 16 ++++++++++------ templates/isolated/nix/parts/shells/dev.nix | 1 - templates/isolated/nix/parts/treefmt/treefmt.nix | 16 ++++++++++------ templates/main/parts/treefmt/treefmt.nix | 16 ++++++++++------ templates/minimal/parts/shells/dev.nix | 1 - templates/minimal/parts/treefmt/treefmt.nix | 16 ++++++++++------ 7 files changed, 50 insertions(+), 32 deletions(-) diff --git a/templates/home/parts/treefmt/treefmt.nix b/templates/home/parts/treefmt/treefmt.nix index d9578ec..13025fb 100644 --- a/templates/home/parts/treefmt/treefmt.nix +++ b/templates/home/parts/treefmt/treefmt.nix @@ -15,12 +15,16 @@ projectRootFile = projectPath + "/flake.nix"; programs = { - deadnix.enable = true; - statix.enable = true; - prettier.enable = true; - nixfmt-rfc-style.enable = true; + deadnix.enable = true; # Find and remove unused code in .nix source files + statix.enable = true; # Lints and suggestions for the nix programming language + nixfmt-rfc-style.enable = true; # An opinionated formatter for Nix # NOTE Choose a different formatter if you'd like to - # nixfmt.enable = true; - # alejandra.enable = true; + # nixfmt.enable = true; # An opinionated formatter for Nix + # alejandra.enable = true; # The Uncompromising Nix Code Formatter + + prettier.enable = true; # Prettier is an opinionated code formatter + mdformat.enable = true; # CommonMark compliant Markdown formatter + yamlfmt.enable = true; # An extensible command line tool or library to format yaml files. + jsonfmt.enable = true; # Formatter for JSON files }; } diff --git a/templates/isolated-minimal/nix/parts/treefmt/treefmt.nix b/templates/isolated-minimal/nix/parts/treefmt/treefmt.nix index 33578a7..dfd3bde 100644 --- a/templates/isolated-minimal/nix/parts/treefmt/treefmt.nix +++ b/templates/isolated-minimal/nix/parts/treefmt/treefmt.nix @@ -15,12 +15,16 @@ projectRootFile = projectPath + "/flake.nix"; programs = { - deadnix.enable = true; - statix.enable = true; - prettier.enable = true; - nixfmt-rfc-style.enable = true; + deadnix.enable = true; # Find and remove unused code in .nix source files + statix.enable = true; # Lints and suggestions for the nix programming language + nixfmt-rfc-style.enable = true; # An opinionated formatter for Nix # NOTE Choose a different formatter if you'd like to - # nixfmt.enable = true; - # alejandra.enable = true; + # nixfmt.enable = true; # An opinionated formatter for Nix + # alejandra.enable = true; # The Uncompromising Nix Code Formatter + + prettier.enable = true; # Prettier is an opinionated code formatter + mdformat.enable = true; # CommonMark compliant Markdown formatter + yamlfmt.enable = true; # An extensible command line tool or library to format yaml files. + jsonfmt.enable = true; # Formatter for JSON files }; } diff --git a/templates/isolated/nix/parts/shells/dev.nix b/templates/isolated/nix/parts/shells/dev.nix index 37a4cdc..8d75424 100644 --- a/templates/isolated/nix/parts/shells/dev.nix +++ b/templates/isolated/nix/parts/shells/dev.nix @@ -1,5 +1,4 @@ # --- nix/parts/shells/dev.nix - { pkgs, treefmt, diff --git a/templates/isolated/nix/parts/treefmt/treefmt.nix b/templates/isolated/nix/parts/treefmt/treefmt.nix index 33578a7..dfd3bde 100644 --- a/templates/isolated/nix/parts/treefmt/treefmt.nix +++ b/templates/isolated/nix/parts/treefmt/treefmt.nix @@ -15,12 +15,16 @@ projectRootFile = projectPath + "/flake.nix"; programs = { - deadnix.enable = true; - statix.enable = true; - prettier.enable = true; - nixfmt-rfc-style.enable = true; + deadnix.enable = true; # Find and remove unused code in .nix source files + statix.enable = true; # Lints and suggestions for the nix programming language + nixfmt-rfc-style.enable = true; # An opinionated formatter for Nix # NOTE Choose a different formatter if you'd like to - # nixfmt.enable = true; - # alejandra.enable = true; + # nixfmt.enable = true; # An opinionated formatter for Nix + # alejandra.enable = true; # The Uncompromising Nix Code Formatter + + prettier.enable = true; # Prettier is an opinionated code formatter + mdformat.enable = true; # CommonMark compliant Markdown formatter + yamlfmt.enable = true; # An extensible command line tool or library to format yaml files. + jsonfmt.enable = true; # Formatter for JSON files }; } diff --git a/templates/main/parts/treefmt/treefmt.nix b/templates/main/parts/treefmt/treefmt.nix index d9578ec..13025fb 100644 --- a/templates/main/parts/treefmt/treefmt.nix +++ b/templates/main/parts/treefmt/treefmt.nix @@ -15,12 +15,16 @@ projectRootFile = projectPath + "/flake.nix"; programs = { - deadnix.enable = true; - statix.enable = true; - prettier.enable = true; - nixfmt-rfc-style.enable = true; + deadnix.enable = true; # Find and remove unused code in .nix source files + statix.enable = true; # Lints and suggestions for the nix programming language + nixfmt-rfc-style.enable = true; # An opinionated formatter for Nix # NOTE Choose a different formatter if you'd like to - # nixfmt.enable = true; - # alejandra.enable = true; + # nixfmt.enable = true; # An opinionated formatter for Nix + # alejandra.enable = true; # The Uncompromising Nix Code Formatter + + prettier.enable = true; # Prettier is an opinionated code formatter + mdformat.enable = true; # CommonMark compliant Markdown formatter + yamlfmt.enable = true; # An extensible command line tool or library to format yaml files. + jsonfmt.enable = true; # Formatter for JSON files }; } diff --git a/templates/minimal/parts/shells/dev.nix b/templates/minimal/parts/shells/dev.nix index 53b231b..1815334 100644 --- a/templates/minimal/parts/shells/dev.nix +++ b/templates/minimal/parts/shells/dev.nix @@ -1,5 +1,4 @@ # --- parts/shells/dev.nix - { pkgs, treefmt, diff --git a/templates/minimal/parts/treefmt/treefmt.nix b/templates/minimal/parts/treefmt/treefmt.nix index 40c34e4..749fb30 100644 --- a/templates/minimal/parts/treefmt/treefmt.nix +++ b/templates/minimal/parts/treefmt/treefmt.nix @@ -15,12 +15,16 @@ projectRootFile = projectPath + "/flake.nix"; programs = { - deadnix.enable = true; - statix.enable = true; - prettier.enable = true; - nixfmt-rfc-style.enable = true; + deadnix.enable = true; # Find and remove unused code in .nix source files + statix.enable = true; # Lints and suggestions for the nix programming language + nixfmt-rfc-style.enable = true; # An opinionated formatter for Nix # NOTE Choose a different formatter if you'd like to - # nixfmt.enable = true; - # alejandra.enable = true; + # nixfmt.enable = true; # An opinionated formatter for Nix + # alejandra.enable = true; # The Uncompromising Nix Code Formatter + + prettier.enable = true; # Prettier is an opinionated code formatter + mdformat.enable = true; # CommonMark compliant Markdown formatter + yamlfmt.enable = true; # An extensible command line tool or library to format yaml files. + jsonfmt.enable = true; # Formatter for JSON files }; }