refactor(flake): refactor lib for flake-parts

This commit is contained in:
Artur Manuel 2025-02-02 16:37:47 +00:00
commit 6f79c94f11
6 changed files with 70 additions and 71 deletions

View file

@ -1,47 +1,48 @@
{
inputs,
self,
}: _: _: let
mkHost = {
host,
system,
extraModules ? [],
}:
inputs.nixpkgs.lib.nixosSystem {
inherit system;
modules =
extraModules
++ [
../hosts/${host}
inputs.self.nixosModules.default
({config, ...}: {
config = {
nix = {
settings.extra-experimental-features = [
"nix-command"
"flakes"
];
gc = {
automatic = true;
dates = "weekly";
...
}: {
flake.lib = inputs.nixpkgs.lib.extend (_: _: {
mkHost = {
host,
system,
extraModules ? [],
}:
inputs.nixpkgs.lib.nixosSystem {
inherit system;
modules =
extraModules
++ [
../hosts/${host}
inputs.self.nixosModules.default
({config, ...}: {
config = {
nix = {
settings.extra-experimental-features = [
"nix-command"
"flakes"
];
gc = {
automatic = true;
dates = "weekly";
};
};
nixpkgs.config.allowUnfree = true;
environment.shellAliases = {
rebs = "nixos-rebuild --use-remote-sudo switch --flake .#${host}";
rebt = "nixos-rebuild --use-remote-sudo test --flake .#${host}";
};
nixpkgs.overlays = [
inputs.self.overlays.default
];
networking.hostName = host;
};
nixpkgs.config.allowUnfree = true;
environment.shellAliases = {
rebs = "nixos-rebuild --use-remote-sudo switch --flake .#${host}";
rebt = "nixos-rebuild --use-remote-sudo test --flake .#${host}";
};
nixpkgs.overlays = [
inputs.self.overlays.default
];
networking.hostName = host;
};
})
];
specialArgs = {
inherit inputs self;
})
];
specialArgs = {
inherit inputs self;
};
};
};
in {
mkHosts = builtins.mapAttrs (n: v: mkHost (v // {host = n;}));
});
}