init flake-parts

This commit is contained in:
cy 2025-01-13 14:49:56 -05:00
parent b6c18ce5f2
commit 2ef6714753
2 changed files with 83 additions and 71 deletions

27
flake.lock generated
View file

@ -94,6 +94,26 @@
} }
}, },
"flake-parts": { "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": { "inputs": {
"nixpkgs-lib": [ "nixpkgs-lib": [
"lanzaboote", "lanzaboote",
@ -114,7 +134,7 @@
"type": "github" "type": "github"
} }
}, },
"flake-parts_2": { "flake-parts_3": {
"inputs": { "inputs": {
"nixpkgs-lib": [ "nixpkgs-lib": [
"nixvim", "nixvim",
@ -314,7 +334,7 @@
"inputs": { "inputs": {
"crane": "crane", "crane": "crane",
"flake-compat": "flake-compat", "flake-compat": "flake-compat",
"flake-parts": "flake-parts", "flake-parts": "flake-parts_2",
"flake-utils": "flake-utils", "flake-utils": "flake-utils",
"nixpkgs": [ "nixpkgs": [
"nixpkgs" "nixpkgs"
@ -426,7 +446,7 @@
"inputs": { "inputs": {
"devshell": "devshell", "devshell": "devshell",
"flake-compat": "flake-compat_2", "flake-compat": "flake-compat_2",
"flake-parts": "flake-parts_2", "flake-parts": "flake-parts_3",
"git-hooks": "git-hooks", "git-hooks": "git-hooks",
"home-manager": "home-manager_2", "home-manager": "home-manager_2",
"nix-darwin": "nix-darwin", "nix-darwin": "nix-darwin",
@ -503,6 +523,7 @@
"root": { "root": {
"inputs": { "inputs": {
"disko": "disko", "disko": "disko",
"flake-parts": "flake-parts",
"home-manager": "home-manager", "home-manager": "home-manager",
"lanzaboote": "lanzaboote", "lanzaboote": "lanzaboote",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",

127
flake.nix
View file

@ -27,6 +27,8 @@
url = "github:nix-community/nixvim"; url = "github:nix-community/nixvim";
inputs.nixpkgs.follows = "nixpkgs"; 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-btrbk.url = "github:cything/nixpkgs/btrbk"; # unmerged PR
nixpkgs-garage.url = "github:cything/nixpkgs/garage-module"; # unmerged PR nixpkgs-garage.url = "github:cything/nixpkgs/garage-module"; # unmerged PR
@ -47,38 +49,22 @@
}; };
outputs = outputs =
{ inputs@{ flake-parts, nixpkgs, home-manager, disko, ...}:
self, flake-parts.lib.mkFlake { inherit inputs; } {
nixpkgs, systems = [
home-manager, "x86_64-linux"
treefmt, ];
disko, imports = [
... inputs.treefmt.flakeModule
}@inputs: ];
let perSystem =
lib = nixpkgs.lib; {
inherit (self) outputs; self',
system,
systems = [ "x86_64-linux" ]; ...
forEachSystem = f: lib.genAttrs systems (system: f pkgsFor.${system}); }:
overlays = [ {
# (overlayPkgsFromFlake inputs.eza [ treefmt = {
# ])
] ++ import ./overlay;
pkgsFor = lib.genAttrs systems (
system:
import nixpkgs {
inherit system overlays;
config = {
allowUnfree = true;
};
}
);
treefmtEval = forEachSystem (
pkgs:
treefmt.lib.evalModule pkgs {
projectRootFile = "flake.nix"; projectRootFile = "flake.nix";
programs.nixfmt.enable = true; programs.nixfmt.enable = true;
programs.stylua.enable = true; programs.stylua.enable = true;
@ -88,24 +74,29 @@
programs.deadnix.enable = true; programs.deadnix.enable = true;
settings.global.excludes = [ "secrets/*" ]; 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 .#<package>`
packages = pkgsFor;
nixosConfigurations = flake.nixosConfigurations =
let let
pkgs = pkgsFor.x86_64-linux; lib = nixpkgs.lib;
in
overlays = [
# (overlayPkgsFromFlake inputs.eza [
# ])
] ++ import ./overlay;
pkgs =
import nixpkgs {
inherit overlays;
config = {
allowUnfree = true;
};
};
in
{ {
ytnix = lib.nixosSystem { ytnix = lib.nixosSystem {
specialArgs = { inherit inputs outputs; }; specialArgs = { inherit inputs; };
modules = [ modules = [
{ {
nixpkgs = { inherit pkgs; }; nixpkgs = { inherit pkgs; };
@ -118,7 +109,7 @@
}; };
chunk = lib.nixosSystem { chunk = lib.nixosSystem {
specialArgs = { inherit inputs outputs; }; specialArgs = { inherit inputs; };
modules = [ modules = [
{ {
nixpkgs = { inherit pkgs; }; nixpkgs = { inherit pkgs; };
@ -134,7 +125,7 @@
}; };
titan = lib.nixosSystem { titan = lib.nixosSystem {
specialArgs = { inherit inputs outputs; }; specialArgs = { inherit inputs; };
modules = [ modules = [
{ {
nixpkgs = { inherit pkgs; }; nixpkgs = { inherit pkgs; };
@ -147,24 +138,24 @@
}; };
}; };
homeConfigurations = { # homeConfigurations = {
"yt@ytnix" = home-manager.lib.homeManagerConfiguration { # "yt@ytnix" = home-manager.lib.homeManagerConfiguration {
pkgs = pkgsFor.x86_64-linux; # inherit pkgs;
extraSpecialArgs = { inherit inputs outputs; }; # extraSpecialArgs = { inherit inputs; };
modules = [ # modules = [
./home/yt/ytnix.nix # ./home/yt/ytnix.nix
inputs.nixvim.homeManagerModules.nixvim # inputs.nixvim.homeManagerModules.nixvim
]; # ];
}; # };
#
"yt@chunk" = home-manager.lib.homeManagerConfiguration { # "yt@chunk" = home-manager.lib.homeManagerConfiguration {
pkgs = pkgsFor.x86_64-linux; # inherit pkgs;
extraSpecialArgs = { inherit inputs outputs; }; # extraSpecialArgs = { inherit inputs; };
modules = [ # modules = [
./home/yt/chunk.nix # ./home/yt/chunk.nix
inputs.nixvim.homeManagerModules.nixvim # inputs.nixvim.homeManagerModules.nixvim
]; # ];
}; # };
}; # };
}; };
} }