From cf96fac1042aef5d83494a1bb693dd7e634aabdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=9C=BF=20corey=20=28they/them=29?= Date: Wed, 22 Oct 2025 10:27:53 -0700 Subject: [PATCH 01/12] Add flake-parts input --- flake.lock | 12 +++++++----- flake.nix | 5 +++++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/flake.lock b/flake.lock index 92d9e858..b47c658b 100644 --- a/flake.lock +++ b/flake.lock @@ -117,16 +117,15 @@ "flake-parts": { "inputs": { "nixpkgs-lib": [ - "zx-dev", "nixpkgs" ] }, "locked": { - "lastModified": 1749398372, - "narHash": "sha256-tYBdgS56eXYaWVW3fsnPQ/nFlgWi/Z2Ymhyu21zVM98=", + "lastModified": 1760948891, + "narHash": "sha256-TmWcdiUUaWk8J4lpjzu4gCGxWY6/Ok7mOK4fIFfBuU4=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "9305fe4e5c2a6fcf5ba6a3ff155720fbe4076569", + "rev": "864599284fc7c0ba6357ed89ed5e2cd5040f0c04", "type": "github" }, "original": { @@ -349,6 +348,7 @@ "inputs": { "agenix": "agenix", "disko": "disko", + "flake-parts": "flake-parts", "flake-utils": "flake-utils", "golink": "golink", "home-manager": "home-manager", @@ -396,7 +396,9 @@ "zx-dev": { "inputs": { "anemone": "anemone", - "flake-parts": "flake-parts", + "flake-parts": [ + "flake-parts" + ], "nixpkgs": [ "nixpkgs" ] diff --git a/flake.nix b/flake.nix index 20c34b9a..ff8ac683 100644 --- a/flake.nix +++ b/flake.nix @@ -12,6 +12,10 @@ url = "github:numtide/flake-utils"; inputs.systems.follows = "systems"; }; + flake-parts = { + url = "github:hercules-ci/flake-parts"; + inputs.nixpkgs-lib.follows = "nixpkgs"; + }; agenix = { url = "github:ryantm/agenix"; inputs.darwin.follows = "nix-darwin"; @@ -37,6 +41,7 @@ zx-dev = { url = "github:stackptr/zx.dev"; inputs.nixpkgs.follows = "nixpkgs"; + inputs.flake-parts.follows = "flake-parts"; }; # macOS From 611f00671f8e2ee4ca7e63489b4f01de5a98e8c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=9C=BF=20corey=20=28they/them=29?= Date: Wed, 22 Oct 2025 10:50:13 -0700 Subject: [PATCH 02/12] Use `flake-parts` `mkFlake` --- flake.lock | 11 +++--- flake.nix | 102 ++++++++++++++++++++++++++--------------------------- 2 files changed, 54 insertions(+), 59 deletions(-) diff --git a/flake.lock b/flake.lock index b47c658b..b09911f5 100644 --- a/flake.lock +++ b/flake.lock @@ -137,6 +137,7 @@ "flake-utils": { "inputs": { "systems": [ + "mac-app-util", "systems" ] }, @@ -149,9 +150,8 @@ "type": "github" }, "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" + "id": "flake-utils", + "type": "indirect" } }, "golink": { @@ -233,9 +233,7 @@ "inputs": { "cl-nix-lite": "cl-nix-lite", "flake-compat": "flake-compat", - "flake-utils": [ - "flake-utils" - ], + "flake-utils": "flake-utils", "nixpkgs": [ "nixpkgs" ], @@ -349,7 +347,6 @@ "agenix": "agenix", "disko": "disko", "flake-parts": "flake-parts", - "flake-utils": "flake-utils", "golink": "golink", "home-manager": "home-manager", "homebrew-cask": "homebrew-cask", diff --git a/flake.nix b/flake.nix index ff8ac683..184a02c9 100644 --- a/flake.nix +++ b/flake.nix @@ -8,10 +8,6 @@ url = "path:./flake.systems.nix"; flake = false; }; - flake-utils = { - url = "github:numtide/flake-utils"; - inputs.systems.follows = "systems"; - }; flake-parts = { url = "github:hercules-ci/flake-parts"; inputs.nixpkgs-lib.follows = "nixpkgs"; @@ -63,66 +59,68 @@ mac-app-util = { url = "github:hraban/mac-app-util"; inputs.nixpkgs.follows = "nixpkgs"; - inputs.flake-utils.follows = "flake-utils"; inputs.systems.follows = "systems"; }; }; - outputs = inputs @ { - nixpkgs, - flake-utils, - agenix, - ... - }: let - inherit (import ./lib/hosts.nix inputs) mkNixosHost mkDarwinHost; - in - { - nixosConfigurations = { - zeta = mkNixosHost { - hostname = "zeta"; - system = "aarch64-linux"; - username = "mu"; - }; - glyph = mkNixosHost { - hostname = "glyph"; - system = "x86_64-linux"; - username = "mu"; + outputs = inputs @ {flake-parts, ...}: + flake-parts.lib.mkFlake {inherit inputs;} ({ + config, + withSystem, + moduleWithSystem, + ... + }: { + flake = let + inherit (import ./lib/hosts.nix inputs) mkNixosHost mkDarwinHost; + in { + nixosConfigurations = { + zeta = mkNixosHost { + hostname = "zeta"; + system = "aarch64-linux"; + username = "mu"; + }; + glyph = mkNixosHost { + hostname = "glyph"; + system = "x86_64-linux"; + username = "mu"; + }; + spore = mkNixosHost { + hostname = "spore"; + system = "x86_64-linux"; + username = "mu"; + }; }; - spore = mkNixosHost { - hostname = "spore"; - system = "x86_64-linux"; - username = "mu"; + + darwinConfigurations = { + Rhizome = mkDarwinHost { + hostname = "Rhizome"; + username = "corey"; + }; }; - }; - darwinConfigurations = { - Rhizome = mkDarwinHost { - hostname = "Rhizome"; - username = "corey"; + nixConfig = { + experimental-features = ["nix-command" "flakes"]; + extra-substituters = [ + "https://stackptr.cachix.org" + ]; + extra-trusted-public-keys = [ + "stackptr.cachix.org-1:5e2q7OxdRdAtvRmHTeogpgJKzQhbvFqNMmCMw71opZA=" + ]; }; }; - } - // flake-utils.lib.eachDefaultSystem ( - system: let - pkgs = nixpkgs.legacyPackages.${system}; - agenixPkg = agenix.packages.${system}.default; - in { + + systems = import inputs.systems; + perSystem = { + pkgs, + inputs', + ... + }: { devShells = { default = pkgs.mkShell { - packages = [agenixPkg pkgs.cachix pkgs.just]; + packages = [inputs'.agenix.packages.default pkgs.cachix pkgs.just]; }; }; formatter = pkgs.alejandra; - } - ); - - nixConfig = { - experimental-features = ["nix-command" "flakes"]; - extra-substituters = [ - "https://stackptr.cachix.org" - ]; - extra-trusted-public-keys = [ - "stackptr.cachix.org-1:5e2q7OxdRdAtvRmHTeogpgJKzQhbvFqNMmCMw71opZA=" - ]; - }; + }; + }); } From 0d48dd4cb00762228fbef1f82ee0d8385c2b3079 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=9C=BF=20corey=20=28they/them=29?= Date: Wed, 22 Oct 2025 11:03:23 -0700 Subject: [PATCH 03/12] Add git-hooks-nix input --- flake.lock | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++- flake.nix | 4 ++++ 2 files changed, 65 insertions(+), 1 deletion(-) diff --git a/flake.lock b/flake.lock index b09911f5..636578fd 100644 --- a/flake.lock +++ b/flake.lock @@ -98,6 +98,22 @@ } }, "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1747046372, + "narHash": "sha256-CIVLLkVgvHYbgI2UpXvIIBJ12HWgX+fjA8Xf8PUmqCY=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "9100a0f413b0c601e0533d1d94ffd501ce2e7885", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_2": { "flake": false, "locked": { "lastModified": 1730663653, @@ -154,6 +170,49 @@ "type": "indirect" } }, + "git-hooks-nix": { + "inputs": { + "flake-compat": "flake-compat", + "gitignore": "gitignore", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1760663237, + "narHash": "sha256-BflA6U4AM1bzuRMR8QqzPXqh8sWVCNDzOdsxXEguJIc=", + "owner": "cachix", + "repo": "git-hooks.nix", + "rev": "ca5b894d3e3e151ffc1db040b6ce4dcc75d31c37", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "git-hooks.nix", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "git-hooks-nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, "golink": { "inputs": { "nixpkgs": [ @@ -232,7 +291,7 @@ "mac-app-util": { "inputs": { "cl-nix-lite": "cl-nix-lite", - "flake-compat": "flake-compat", + "flake-compat": "flake-compat_2", "flake-utils": "flake-utils", "nixpkgs": [ "nixpkgs" @@ -347,6 +406,7 @@ "agenix": "agenix", "disko": "disko", "flake-parts": "flake-parts", + "git-hooks-nix": "git-hooks-nix", "golink": "golink", "home-manager": "home-manager", "homebrew-cask": "homebrew-cask", diff --git a/flake.nix b/flake.nix index 184a02c9..b98273c5 100644 --- a/flake.nix +++ b/flake.nix @@ -23,6 +23,10 @@ url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; }; + git-hooks-nix = { + url = "github:cachix/git-hooks.nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; # Linux disko = { From e67a3f9457fdba998de763bb135a652ca0fe1e18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=9C=BF=20corey=20=28they/them=29?= Date: Wed, 22 Oct 2025 11:07:31 -0700 Subject: [PATCH 04/12] Enable alejandra pre-commit hook --- flake.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/flake.nix b/flake.nix index b98273c5..bc43ab6e 100644 --- a/flake.nix +++ b/flake.nix @@ -74,6 +74,10 @@ moduleWithSystem, ... }: { + imports = [ + inputs.git-hooks-nix.flakeModule + ]; + flake = let inherit (import ./lib/hosts.nix inputs) mkNixosHost mkDarwinHost; in { @@ -125,6 +129,9 @@ }; }; formatter = pkgs.alejandra; + pre-commit.settings.hooks = { + alejandra.enable = true; + }; }; }); } From d536d9b2d08a206667a85f640cd9fa5c9b31a770 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=9C=BF=20corey=20=28they/them=29?= Date: Wed, 22 Oct 2025 11:35:52 -0700 Subject: [PATCH 05/12] Add pre-commit shellHook --- .gitignore | 1 + flake.nix | 2 ++ 2 files changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 7ab4045e..44b25574 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .DS_Store .direnv +/.pre-commit-config.yaml diff --git a/flake.nix b/flake.nix index bc43ab6e..11f9c11d 100644 --- a/flake.nix +++ b/flake.nix @@ -121,11 +121,13 @@ perSystem = { pkgs, inputs', + config, ... }: { devShells = { default = pkgs.mkShell { packages = [inputs'.agenix.packages.default pkgs.cachix pkgs.just]; + shellHook = config.pre-commit.shellHook; }; }; formatter = pkgs.alejandra; From 3b15be9443a03568134916669be6450391793eeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=9C=BF=20corey=20=28they/them=29?= Date: Wed, 22 Oct 2025 11:37:13 -0700 Subject: [PATCH 06/12] Use pre-commit hook in `nix fmt` --- flake.nix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 11f9c11d..70730887 100644 --- a/flake.nix +++ b/flake.nix @@ -130,7 +130,12 @@ shellHook = config.pre-commit.shellHook; }; }; - formatter = pkgs.alejandra; + formatter = let + inherit (config.pre-commit.settings) package configFile; + in + pkgs.writeShellScriptBin "pre-commit-run" '' + ${pkgs.lib.getExe package} run --all-files --config ${configFile} + ''; pre-commit.settings.hooks = { alejandra.enable = true; }; From 3ee0eb53bf7aa6201897c76266e4026d86babebe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=9C=BF=20corey=20=28they/them=29?= Date: Wed, 22 Oct 2025 11:38:00 -0700 Subject: [PATCH 07/12] Enable nil hook --- flake.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/flake.nix b/flake.nix index 70730887..5635e5fd 100644 --- a/flake.nix +++ b/flake.nix @@ -138,6 +138,7 @@ ''; pre-commit.settings.hooks = { alejandra.enable = true; + nil.enable = true; }; }; }); From a5424c84e5fdfc5f8d49d39d1a497219ab9e0f14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=9C=BF=20corey=20=28they/them=29?= Date: Wed, 22 Oct 2025 11:41:56 -0700 Subject: [PATCH 08/12] Remove `nil` from home packages --- home/default.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/home/default.nix b/home/default.nix index fb8deae7..6fe5bb06 100644 --- a/home/default.nix +++ b/home/default.nix @@ -27,7 +27,6 @@ nixSpecific = [ comma manix - nil nix-du nix-tree nix-your-shell From 547cfd260200bf694215433ac4bf050f1679770e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=9C=BF=20corey=20=28they/them=29?= Date: Wed, 22 Oct 2025 15:41:24 -0700 Subject: [PATCH 09/12] Enable statix hook --- flake.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/flake.nix b/flake.nix index 5635e5fd..0356a592 100644 --- a/flake.nix +++ b/flake.nix @@ -139,6 +139,7 @@ pre-commit.settings.hooks = { alejandra.enable = true; nil.enable = true; + statix.enable = true; }; }; }); From 6930b5643383d434033020ed6048bcf574d04b56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=9C=BF=20corey=20=28they/them=29?= Date: Wed, 22 Oct 2025 15:44:47 -0700 Subject: [PATCH 10/12] Fix statix issue --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 0356a592..fe05f07a 100644 --- a/flake.nix +++ b/flake.nix @@ -127,7 +127,7 @@ devShells = { default = pkgs.mkShell { packages = [inputs'.agenix.packages.default pkgs.cachix pkgs.just]; - shellHook = config.pre-commit.shellHook; + inherit (config.pre-commit) shellHook; }; }; formatter = let From a068349afa8ba8e252b9730acc378eb6a03d842b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=9C=BF=20corey=20=28they/them=29?= Date: Wed, 22 Oct 2025 15:44:53 -0700 Subject: [PATCH 11/12] Remove `statix` from home packages --- home/default.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/home/default.nix b/home/default.nix index 6fe5bb06..25f5b49f 100644 --- a/home/default.nix +++ b/home/default.nix @@ -30,7 +30,6 @@ nix-du nix-tree nix-your-shell - statix ]; tuiApps = [ claude-code From 272d8f4cbad11d637d6bbf6f21fab3b210db2ae7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=9C=BF=20corey=20=28they/them=29?= Date: Wed, 22 Oct 2025 15:56:12 -0700 Subject: [PATCH 12/12] Expose pre-commit packages in dev shell --- flake.nix | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index fe05f07a..d368ecee 100644 --- a/flake.nix +++ b/flake.nix @@ -126,7 +126,13 @@ }: { devShells = { default = pkgs.mkShell { - packages = [inputs'.agenix.packages.default pkgs.cachix pkgs.just]; + packages = + [ + inputs'.agenix.packages.default + pkgs.cachix + pkgs.just + ] + ++ config.pre-commit.settings.enabledPackages; inherit (config.pre-commit) shellHook; }; };