use flake-parts
2 files changed, 99 insertions(+), 48 deletions(-)
changed files
M flake.lock → flake.lock
@@ -1,5 +1,23 @@ { "nodes": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1759362264, + "narHash": "sha256-wfG0S7pltlYyZTM+qqlhJ7GMw2fTF4mLKCIVhLii/4M=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "758cf7296bee11f1706a574c77d072b8a7baa881", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1759417375,@@ -16,8 +34,24 @@ "repo": "nixpkgs", "type": "github" } }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1754788789, + "narHash": "sha256-x2rJ+Ovzq0sCMpgfgGaaqgBSwY+LST+WbZ6TytnT9Rk=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "a73b9c743612e4244d865a2fdee11865283c04e6", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, "root": { "inputs": { + "flake-parts": "flake-parts", "nixpkgs": "nixpkgs" } }
M flake.nix → flake.nix
@@ -1,56 +1,73 @@ { description = "My personal NUR repository"; + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + inputs.flake-parts.url = "github:hercules-ci/flake-parts"; + outputs = - { self, nixpkgs }: - let - systems = [ - "x86_64-linux" - "i686-linux" - "x86_64-darwin" - "aarch64-darwin" - "aarch64-linux" - "armv6l-linux" - "armv7l-linux" - ]; - forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f system); - in - { - overlays = { - default = import ./overlay.nix; - }; - legacyPackages = forAllSystems ( - system: - (import ./default.nix { - pkgs = import nixpkgs { inherit system; }; - }) - ); - nixosModules = { - laminar = ./modules/nixos/laminar.nix; - }; - darwinModules = { - caddy = ./modules/darwin/caddy; - }; - packages = forAllSystems ( - system: - let - pkgs = import nixpkgs { inherit system; }; + inputs@{ flake-parts, ... }: + flake-parts.lib.mkFlake { inherit inputs; } ( + { ... }: + { + imports = [ + inputs.flake-parts.flakeModules.modules + ]; + + systems = [ + "x86_64-linux" + "i686-linux" + "x86_64-darwin" + "aarch64-darwin" + "aarch64-linux" + "armv6l-linux" + "armv7l-linux" + ]; + perSystem = + { + self', + pkgs, + lib, + ... + }: + { + legacyPackages = (import ./default.nix { inherit pkgs; }); + + packages = ( + let + inherit pkgs; + + lpkgs = lib.filterAttrs (_: v: lib.isDerivation v) self'.legacyPackages; + + all = pkgs.symlinkJoin { + name = "all"; + paths = (import ./ci.nix { inherit pkgs; }).cachePkgs; + }; + in + ( + lpkgs + // { + inherit all; + default = all; + } + ) + ); - lpkgs = nixpkgs.lib.filterAttrs (_: v: nixpkgs.lib.isDerivation v) self.legacyPackages.${system}; + formatter = pkgs.nixfmt-tree; + }; + flake = { + overlays = { + default = import ./overlay.nix; + }; - all = pkgs.symlinkJoin { - name = "all"; - paths = (import ./ci.nix { inherit pkgs; }).cachePkgs; + modules = { + nixos = { + laminar = ./modules/nixos/laminar.nix; + }; + darwin = { + caddy = ./modules/darwin/caddy; + }; }; - in - ( - lpkgs - // { - inherit all; - default = all; - } - ) - ); - formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.nixfmt-tree); - }; + }; + } + ); }