nix: move combinators to top level as a flake module

This commit is contained in:
Primrose 2024-07-13 14:15:38 +02:00
parent 173e1440c1
commit 952c13b446
Signed by: primrose
GPG key ID: 4E887A4CA9714ADA
5 changed files with 2 additions and 2 deletions

View file

@ -0,0 +1,14 @@
{ withSystem, flake-parts-lib, ... }:
let
inherit (flake-parts-lib) importApply;
flakeModules.combinators = importApply ./it.nix { inherit withSystem; };
in
{
imports = [ flakeModules.combinators ];
flake = {
inherit flakeModules;
};
}

View file

@ -0,0 +1,105 @@
localFlake:
{ inputs, ... }:
let
mkNixOS =
nixosModulesOf: homeModulesOf:
{
hostname,
system,
extraNixOSConfig ? { },
extraHomeConfig ? { },
...
}@args:
localFlake.withSystem system (
{ pkgs, ... }:
let
specialArgs = {
inherit pkgs;
inherit hostname;
};
in
inputs.nixpkgs.lib.nixosSystem {
inherit specialArgs;
modules = nixosModulesOf args ++ [
extraNixOSConfig
{
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
extraSpecialArgs = specialArgs;
users.leana.imports = homeModulesOf args ++ [ extraHomeConfig ];
};
}
];
}
);
mkDarwin =
darwinModulesOf: homeModulesOf:
args@{
hostname,
system,
extraDarwinConfig ? { },
extraHomeConfig ? { },
...
}:
localFlake.withSystem system (
{ pkgs, ... }:
let
specialArgs = {
inherit pkgs;
inherit hostname;
};
in
inputs.nix-darwin.lib.darwinSystem {
inherit specialArgs;
modules = darwinModulesOf args ++ [
extraDarwinConfig
{
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
extraSpecialArgs = specialArgs;
users.leana.imports = homeModulesOf args ++ [ extraHomeConfig ];
};
}
];
}
);
mkHomeManager =
homeModulesOf:
args@{
hostname,
system,
extraHomeConfig ? { },
...
}:
localFlake.withSystem system (
{ pkgs, ... }:
let
specialArgs = {
inherit pkgs;
inherit hostname;
};
in
inputs.home-manager.lib.homeManagerConfiguration {
inherit (specialArgs) pkgs;
extraSpecialArgs = specialArgs;
modules = homeModulesOf args ++ [ extraHomeConfig ];
}
);
many = func: builtins.mapAttrs (hostname: cfgs: func (cfgs // { inherit hostname; }));
in
{
_module.args = {
inherit
many
mkNixOS
mkDarwin
mkHomeManager
;
};
}

View file

@ -0,0 +1 @@
{ imports = [ ./combinators ]; }