mirror of
https://codeberg.org/leana8959/.files.git
synced 2025-12-07 07:09:15 +00:00
nix: expose modular configuration combinators
This commit is contained in:
parent
61678660ff
commit
457d196041
3 changed files with 85 additions and 63 deletions
14
nix/configurations/combinators/default.nix
Normal file
14
nix/configurations/combinators/default.nix
Normal 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;
|
||||
};
|
||||
}
|
||||
82
nix/configurations/combinators/it.nix
Normal file
82
nix/configurations/combinators/it.nix
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
localFlake:
|
||||
|
||||
{ inputs, ... }:
|
||||
let
|
||||
mkNixOS =
|
||||
nixosModulesOf: homeModulesOf: name: sys: hmOpts:
|
||||
localFlake.withSystem sys (
|
||||
{ pkgs, ... }:
|
||||
let
|
||||
args = {
|
||||
inherit pkgs;
|
||||
hostname = name;
|
||||
};
|
||||
in
|
||||
inputs.nixpkgs.lib.nixosSystem {
|
||||
specialArgs = args;
|
||||
modules = nixosModulesOf name sys ++ [
|
||||
{
|
||||
home-manager = {
|
||||
useGlobalPkgs = true;
|
||||
useUserPackages = true;
|
||||
extraSpecialArgs = args;
|
||||
users.leana.imports = homeModulesOf name sys ++ [ hmOpts ];
|
||||
};
|
||||
}
|
||||
];
|
||||
}
|
||||
);
|
||||
|
||||
mkDarwin =
|
||||
darwinModulesOf: homeModulesOf: name: sys: hmOpts:
|
||||
localFlake.withSystem sys (
|
||||
{ pkgs, ... }:
|
||||
let
|
||||
args = {
|
||||
inherit pkgs;
|
||||
hostname = name;
|
||||
};
|
||||
in
|
||||
inputs.nix-darwin.lib.darwinSystem {
|
||||
specialArgs = args;
|
||||
modules = darwinModulesOf name sys ++ [
|
||||
{
|
||||
home-manager = {
|
||||
useGlobalPkgs = true;
|
||||
useUserPackages = true;
|
||||
extraSpecialArgs = args;
|
||||
users.leana.imports = homeModulesOf name sys ++ [ hmOpts ];
|
||||
};
|
||||
}
|
||||
];
|
||||
}
|
||||
);
|
||||
|
||||
mkHomeManager =
|
||||
homeModulesOf: name: sys: hmOpts:
|
||||
localFlake.withSystem sys (
|
||||
{ pkgs, ... }:
|
||||
let
|
||||
args = {
|
||||
inherit pkgs;
|
||||
hostname = name;
|
||||
};
|
||||
in
|
||||
inputs.home-manager.lib.homeManagerConfiguration {
|
||||
inherit (args) pkgs;
|
||||
extraSpecialArgs = args;
|
||||
modules = homeModulesOf name sys ++ [ hmOpts ];
|
||||
}
|
||||
);
|
||||
many = func: builtins.mapAttrs (name: hmOpts: func name hmOpts.system (hmOpts.settings or { }));
|
||||
in
|
||||
{
|
||||
_module.args = {
|
||||
inherit
|
||||
many
|
||||
mkNixOS
|
||||
mkDarwin
|
||||
mkHomeManager
|
||||
;
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue