diff --git a/flake.lock b/flake.lock index 3dc7c61..0824f0b 100644 --- a/flake.lock +++ b/flake.lock @@ -50,6 +50,21 @@ "type": "github" } }, + "nixos-unified": { + "locked": { + "lastModified": 1729436561, + "narHash": "sha256-cSFLo7vAlH5lMk9FB88dy34oGgf2sLGv1dVkGgH7/dI=", + "owner": "srid", + "repo": "nixos-unified", + "rev": "4f4262884605abc62f396f3f39b29ac427be2179", + "type": "github" + }, + "original": { + "owner": "srid", + "repo": "nixos-unified", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1729265718, @@ -71,26 +86,11 @@ "flake-parts": "flake-parts", "fourmolu-nix": "fourmolu-nix", "haskell-flake": "haskell-flake", + "nixos-unified": "nixos-unified", "nixpkgs": "nixpkgs", - "systems": "systems", "treefmt-nix": "treefmt-nix" } }, - "systems": { - "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": [ diff --git a/flake.nix b/flake.nix index 7f349f1..31a32c8 100644 --- a/flake.nix +++ b/flake.nix @@ -2,9 +2,9 @@ description = "Nix template for Haskell projects"; inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; - systems.url = "github:nix-systems/default"; flake-parts.url = "github:hercules-ci/flake-parts"; flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs"; + nixos-unified.url = "github:srid/nixos-unified"; haskell-flake.url = "github:srid/haskell-flake"; treefmt-nix.url = "github:numtide/treefmt-nix"; treefmt-nix.inputs.nixpkgs.follows = "nixpkgs"; @@ -12,13 +12,7 @@ }; outputs = inputs: - inputs.flake-parts.lib.mkFlake { inherit inputs; } { - systems = import inputs.systems; - - # See ./nix/modules/*.nix for the modules that are imported here. - imports = with builtins; - map - (fn: ./nix/modules/${fn}) - (attrNames (readDir ./nix/modules)); - }; + # https://nixos-unified.org/autowiring.html#flake-parts + inputs.nixos-unified.lib.mkFlake + { inherit inputs; root = ./.; }; } diff --git a/nix/modules/devshell.nix b/nix/modules/flake-parts/devshell.nix similarity index 100% rename from nix/modules/devshell.nix rename to nix/modules/flake-parts/devshell.nix diff --git a/nix/modules/formatter.nix b/nix/modules/flake-parts/formatter.nix similarity index 100% rename from nix/modules/formatter.nix rename to nix/modules/flake-parts/formatter.nix diff --git a/nix/modules/haskell.nix b/nix/modules/flake-parts/haskell.nix similarity index 90% rename from nix/modules/haskell.nix rename to nix/modules/flake-parts/haskell.nix index 4e873a9..64fd871 100644 --- a/nix/modules/haskell.nix +++ b/nix/modules/flake-parts/haskell.nix @@ -1,4 +1,4 @@ -{ inputs, ... }: +{ root, inputs, ... }: { imports = [ inputs.haskell-flake.flakeModule @@ -11,12 +11,12 @@ # To avoid unnecessary rebuilds, we filter projectRoot: # https://community.flake.parts/haskell-flake/local#rebuild projectRoot = builtins.toString (lib.fileset.toSource { - root = ../..; + inherit root; fileset = lib.fileset.unions [ - ../../src - ../../haskell-template.cabal - ../../LICENSE - ../../README.md + (root + /src) + (root + /haskell-template.cabal) + (root + /LICENSE) + (root + /README.md) ]; }); diff --git a/nix/modules/template.nix b/nix/modules/flake-parts/template.nix similarity index 100% rename from nix/modules/template.nix rename to nix/modules/flake-parts/template.nix