From 2ef67147538d6190b935f28703e2f46ad1d0db39 Mon Sep 17 00:00:00 2001 From: cy Date: Mon, 13 Jan 2025 14:49:56 -0500 Subject: [PATCH] init flake-parts --- flake.lock | 27 ++++++++++-- flake.nix | 127 +++++++++++++++++++++++++---------------------------- 2 files changed, 83 insertions(+), 71 deletions(-) diff --git a/flake.lock b/flake.lock index cd5c828..65e3930 100644 --- a/flake.lock +++ b/flake.lock @@ -94,6 +94,26 @@ } }, "flake-parts": { + "inputs": { + "nixpkgs-lib": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1736143030, + "narHash": "sha256-+hu54pAoLDEZT9pjHlqL9DNzWz0NbUn8NEAHP7PQPzU=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "b905f6fc23a9051a6e1b741e1438dbfc0634c6de", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-parts_2": { "inputs": { "nixpkgs-lib": [ "lanzaboote", @@ -114,7 +134,7 @@ "type": "github" } }, - "flake-parts_2": { + "flake-parts_3": { "inputs": { "nixpkgs-lib": [ "nixvim", @@ -314,7 +334,7 @@ "inputs": { "crane": "crane", "flake-compat": "flake-compat", - "flake-parts": "flake-parts", + "flake-parts": "flake-parts_2", "flake-utils": "flake-utils", "nixpkgs": [ "nixpkgs" @@ -426,7 +446,7 @@ "inputs": { "devshell": "devshell", "flake-compat": "flake-compat_2", - "flake-parts": "flake-parts_2", + "flake-parts": "flake-parts_3", "git-hooks": "git-hooks", "home-manager": "home-manager_2", "nix-darwin": "nix-darwin", @@ -503,6 +523,7 @@ "root": { "inputs": { "disko": "disko", + "flake-parts": "flake-parts", "home-manager": "home-manager", "lanzaboote": "lanzaboote", "nixpkgs": "nixpkgs", diff --git a/flake.nix b/flake.nix index 66f65c4..b28d7ae 100644 --- a/flake.nix +++ b/flake.nix @@ -27,6 +27,8 @@ url = "github:nix-community/nixvim"; inputs.nixpkgs.follows = "nixpkgs"; }; + flake-parts.url = "github:hercules-ci/flake-parts"; + flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs"; nixpkgs-btrbk.url = "github:cything/nixpkgs/btrbk"; # unmerged PR nixpkgs-garage.url = "github:cything/nixpkgs/garage-module"; # unmerged PR @@ -47,38 +49,22 @@ }; outputs = - { - self, - nixpkgs, - home-manager, - treefmt, - disko, - ... - }@inputs: - let - lib = nixpkgs.lib; - inherit (self) outputs; - - systems = [ "x86_64-linux" ]; - forEachSystem = f: lib.genAttrs systems (system: f pkgsFor.${system}); - overlays = [ - # (overlayPkgsFromFlake inputs.eza [ - # ]) - ] ++ import ./overlay; - - pkgsFor = lib.genAttrs systems ( - system: - import nixpkgs { - inherit system overlays; - config = { - allowUnfree = true; - }; - } - ); - - treefmtEval = forEachSystem ( - pkgs: - treefmt.lib.evalModule pkgs { + inputs@{ flake-parts, nixpkgs, home-manager, disko, ...}: + flake-parts.lib.mkFlake { inherit inputs; } { + systems = [ + "x86_64-linux" + ]; + imports = [ + inputs.treefmt.flakeModule + ]; + perSystem = + { + self', + system, + ... + }: + { + treefmt = { projectRootFile = "flake.nix"; programs.nixfmt.enable = true; programs.stylua.enable = true; @@ -88,24 +74,29 @@ programs.deadnix.enable = true; settings.global.excludes = [ "secrets/*" ]; - } - ); - in - { - formatter = forEachSystem (pkgs: treefmtEval.${pkgs.system}.config.build.wrapper); - checks = forEachSystem (pkgs: { - formatting = treefmtEval.${pkgs.system}.config.build.check self; - }); - # lets us build overlaid packages with `nix build .#` - packages = pkgsFor; + }; + }; - nixosConfigurations = - let - pkgs = pkgsFor.x86_64-linux; - in + flake.nixosConfigurations = + let + lib = nixpkgs.lib; + + overlays = [ + # (overlayPkgsFromFlake inputs.eza [ + # ]) + ] ++ import ./overlay; + + pkgs = + import nixpkgs { + inherit overlays; + config = { + allowUnfree = true; + }; + }; + in { ytnix = lib.nixosSystem { - specialArgs = { inherit inputs outputs; }; + specialArgs = { inherit inputs; }; modules = [ { nixpkgs = { inherit pkgs; }; @@ -118,7 +109,7 @@ }; chunk = lib.nixosSystem { - specialArgs = { inherit inputs outputs; }; + specialArgs = { inherit inputs; }; modules = [ { nixpkgs = { inherit pkgs; }; @@ -134,7 +125,7 @@ }; titan = lib.nixosSystem { - specialArgs = { inherit inputs outputs; }; + specialArgs = { inherit inputs; }; modules = [ { nixpkgs = { inherit pkgs; }; @@ -147,24 +138,24 @@ }; }; - homeConfigurations = { - "yt@ytnix" = home-manager.lib.homeManagerConfiguration { - pkgs = pkgsFor.x86_64-linux; - extraSpecialArgs = { inherit inputs outputs; }; - modules = [ - ./home/yt/ytnix.nix - inputs.nixvim.homeManagerModules.nixvim - ]; - }; - - "yt@chunk" = home-manager.lib.homeManagerConfiguration { - pkgs = pkgsFor.x86_64-linux; - extraSpecialArgs = { inherit inputs outputs; }; - modules = [ - ./home/yt/chunk.nix - inputs.nixvim.homeManagerModules.nixvim - ]; - }; - }; + # homeConfigurations = { + # "yt@ytnix" = home-manager.lib.homeManagerConfiguration { + # inherit pkgs; + # extraSpecialArgs = { inherit inputs; }; + # modules = [ + # ./home/yt/ytnix.nix + # inputs.nixvim.homeManagerModules.nixvim + # ]; + # }; + # + # "yt@chunk" = home-manager.lib.homeManagerConfiguration { + # inherit pkgs; + # extraSpecialArgs = { inherit inputs; }; + # modules = [ + # ./home/yt/chunk.nix + # inputs.nixvim.homeManagerModules.nixvim + # ]; + # }; + # }; }; }