switch to flake-parts

This commit is contained in:
CherryKitten 2024-04-21 21:00:58 +02:00
parent 138fc0c4fb
commit ed3a2803c7
Signed by: sammy
GPG key ID: 98D8F75FB0658276
4 changed files with 205 additions and 96 deletions

View file

@ -1,9 +1,31 @@
{ {
"nodes": { "nodes": {
"cherrykitten-website": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1713617763,
"narHash": "sha256-788+IcjSE/bBEu+cU3s9ScG3wBSKZFWERGDtlDgwekw=",
"ref": "nix",
"rev": "eff50d0b92a0db28c350ded871b314cbb1644241",
"revCount": 33,
"type": "git",
"url": "https://git.cherrykitten.dev/sammy/cherrykitten.dev"
},
"original": {
"ref": "nix",
"type": "git",
"url": "https://git.cherrykitten.dev/sammy/cherrykitten.dev"
}
},
"colmena": { "colmena": {
"inputs": { "inputs": {
"flake-compat": "flake-compat", "flake-compat": "flake-compat",
"flake-utils": "flake-utils", "flake-utils": "flake-utils_2",
"nixpkgs": [ "nixpkgs": [
"nixpkgs" "nixpkgs"
], ],
@ -39,7 +61,43 @@
"type": "github" "type": "github"
} }
}, },
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1712014858,
"narHash": "sha256-sB4SWl2lX95bExY2gMFG5HIzvva5AVMJd4Igm+GpZNw=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "9126214d0a59633752a136528f5f3b9aa8565b7d",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"flake-utils": { "flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_2": {
"locked": { "locked": {
"lastModified": 1659877975, "lastModified": 1659877975,
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
@ -90,6 +148,24 @@
"type": "indirect" "type": "indirect"
} }
}, },
"nixpkgs-lib": {
"locked": {
"dir": "lib",
"lastModified": 1711703276,
"narHash": "sha256-iMUFArF0WCatKK6RzfUJknjem0H9m4KgorO/p3Dopkk=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "d8fe5e6c92d0d190646fb9f1056741a229980089",
"type": "github"
},
"original": {
"dir": "lib",
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-unstable": { "nixpkgs-unstable": {
"locked": { "locked": {
"lastModified": 1713562564, "lastModified": 1713562564,
@ -107,7 +183,9 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"cherrykitten-website": "cherrykitten-website",
"colmena": "colmena", "colmena": "colmena",
"flake-parts": "flake-parts",
"home-manager": "home-manager", "home-manager": "home-manager",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"nixpkgs-unstable": "nixpkgs-unstable" "nixpkgs-unstable": "nixpkgs-unstable"
@ -128,6 +206,21 @@
"repo": "nixpkgs", "repo": "nixpkgs",
"type": "github" "type": "github"
} }
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
} }
}, },
"root": "root", "root": "root",

View file

@ -17,22 +17,26 @@
url = "git+https://git.cherrykitten.dev/sammy/cherrykitten.dev?ref=nix"; url = "git+https://git.cherrykitten.dev/sammy/cherrykitten.dev?ref=nix";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
flake-parts.url = "github:hercules-ci/flake-parts";
}; };
outputs = inputs @ { self, nixpkgs, nixpkgs-unstable, home-manager, colmena, ... }: outputs = inputs @ { self, flake-parts, nixpkgs, nixpkgs-unstable, home-manager, colmena, ... }:
let flake-parts.lib.mkFlake { inherit inputs; } {
inherit (self) outputs; imports = [
systems = [ "aarch64-linux" "i686-linux" "x86_64-linux" "aarch64-darwin" "x86_64-darwin" ]; ./hive.nix
forAllSystems = lib.genAttrs systems; ];
lib = nixpkgs.lib // home-manager.lib;
in
rec {
inherit lib;
formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.nixpkgs-fmt);
devShells = forAllSystems (system: systems = [
"x86_64-linux"
"aarch64-linux"
];
perSystem = { config, pkgs, ... }: {
formatter = pkgs.nixpkgs-fmt;
devShells =
let let
pkgs = import nixpkgs { system = system; };
packages = [ pkgs.nix pkgs.colmena pkgs.just pkgs.git pkgs.home-manager pkgs.pass pkgs.nixos-rebuild ]; packages = [ pkgs.nix pkgs.colmena pkgs.just pkgs.git pkgs.home-manager pkgs.pass pkgs.nixos-rebuild ];
in in
{ {
@ -47,77 +51,25 @@
exec $SHELL exec $SHELL
''; '';
}; };
}); };
};
colmena = flake =
let
hosts = lib.genAttrs (builtins.attrNames (builtins.readDir ./hosts)) (name: { });
in
{ {
meta = {
description = "All my NixoS machines";
specialArgs = {
inherit inputs outputs;
nodes = colmenaHive.nodes;
pkgs-unstable = import nixpkgs-unstable { system = "x86_64-linux"; };
};
nixpkgs = import nixpkgs { system = "x86_64-linux"; };
};
defaults = { lib, config, name, nodes, ... }: {
imports = [ ./hosts/${name} ./profiles/base (import ./overlays) ];
options.cherrykitten = {
primaryIPv4 = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default =
if (config.networking.interfaces ? eth0) then
(builtins.elemAt config.networking.interfaces.eth0.ipv4.addresses 0).address
else null;
};
primaryIPv6 = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default =
if (config.networking.interfaces ? eth0) then
(builtins.elemAt config.networking.interfaces.eth0.ipv6.addresses 0).address
else null;
};
};
config = {
networking.hostName = name;
networking.domain = "cherrykitten.xyz";
home-manager.extraSpecialArgs = {
inherit inputs outputs;
pkgs-unstable = import nixpkgs-unstable { system = "x86_64-linux"; };
};
};
};
} // hosts;
colmenaHive = inputs.colmena.lib.makeHive colmena;
nixosConfigurations = {
iso = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [ home-manager.nixosModules.home-manager ./profiles/iso ];
};
} // colmenaHive.nodes;
packages.x86_64-linux.iso = self.nixosConfigurations.iso.config.system.build.isoImage; packages.x86_64-linux.iso = self.nixosConfigurations.iso.config.system.build.isoImage;
homeConfigurations = homeConfigurations =
let let
pkgs = import nixpkgs { system = "x86_64-linux"; }; pkgs = import nixpkgs { system = "x86_64-linux"; };
in in
lib.genAttrs (builtins.attrNames (builtins.readDir ./users)) (name: lib.homeManagerConfiguration { nixpkgs.lib.genAttrs (builtins.attrNames (builtins.readDir ./users)) (name: home-manager.lib.homeManagerConfiguration {
inherit pkgs; inherit pkgs;
modules = [ ./users/${name}/home.nix ]; modules = [ ./users/${name}/home.nix ];
extraSpecialArgs = { extraSpecialArgs = {
inherit inputs outputs; inherit inputs;
pkgs-unstable = import nixpkgs-unstable { system = "x86_64-linux"; }; pkgs-unstable = import nixpkgs-unstable { system = "x86_64-linux"; };
}; };
}); });
}; };
};
} }

64
hive.nix Normal file
View file

@ -0,0 +1,64 @@
{ inputs, self, lib, ... }:
let
inherit (inputs) nixpkgs nixpkgs-unstable;
inherit (self) outputs;
pkgs = import nixpkgs { system = "x86_64-linux"; };
pkgs-unstable = import nixpkgs-unstable { system = "x86_64-linux"; };
in
{
flake = rec {
colmena =
let
hosts = lib.genAttrs (builtins.attrNames (builtins.readDir ./hosts)) (name: { });
in
{
meta = {
description = "All my NixoS machines";
specialArgs = {
inherit inputs outputs pkgs-unstable;
nodes = colmenaHive.nodes;
};
nixpkgs = pkgs;
};
defaults = { lib, config, name, nodes, ... }: {
imports = [ ./hosts/${name} ./profiles/base (import ./overlays) ];
options.cherrykitten = {
primaryIPv4 = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default =
if (config.networking.interfaces ? eth0) then
(builtins.elemAt config.networking.interfaces.eth0.ipv4.addresses 0).address
else null;
};
primaryIPv6 = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default =
if (config.networking.interfaces ? eth0) then
(builtins.elemAt config.networking.interfaces.eth0.ipv6.addresses 0).address
else null;
};
};
config = {
networking.hostName = name;
networking.domain = "cherrykitten.xyz";
home-manager.extraSpecialArgs = {
inherit inputs outputs pkgs-unstable;
};
};
};
} // hosts;
colmenaHive = inputs.colmena.lib.makeHive colmena;
nixosConfigurations = {
iso = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [ inputs.home-manager.nixosModules.home-manager ./profiles/iso ];
};
} // colmenaHive.nodes;
};
}