mirror of
https://codeberg.org/leana8959/.files.git
synced 2026-02-02 15:09:40 +00:00
Refactor using flake-parts (#4)
Reviewed-on: https://git.earth2077.fr/leana/.files/pulls/4 Co-authored-by: Léana 江 <leana.jiang@icloud.com> Co-committed-by: Léana 江 <leana.jiang@icloud.com>
This commit is contained in:
parent
06f76e0a37
commit
db5aaa5811
17 changed files with 343 additions and 294 deletions
112
nix/lib/combinators.nix
Normal file
112
nix/lib/combinators.nix
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
{
|
||||
withSystem,
|
||||
inputs,
|
||||
defaultOptions,
|
||||
self,
|
||||
...
|
||||
}:
|
||||
let
|
||||
mkNixOS =
|
||||
name: sys: opts:
|
||||
withSystem sys (
|
||||
{ pkgs, ... }:
|
||||
let
|
||||
args = {
|
||||
inherit pkgs;
|
||||
hostname = name;
|
||||
};
|
||||
in
|
||||
inputs.nixpkgs.lib.nixosSystem {
|
||||
specialArgs = args;
|
||||
modules = [
|
||||
"${self}/nix/hosts/_"
|
||||
"${self}/nix/hosts/${name}"
|
||||
"${self}/nix/layouts"
|
||||
inputs.agenix.nixosModules.default
|
||||
defaultOptions
|
||||
opts
|
||||
inputs.home-manager.nixosModules.home-manager
|
||||
{
|
||||
home-manager = {
|
||||
useGlobalPkgs = true;
|
||||
useUserPackages = true;
|
||||
extraSpecialArgs = args;
|
||||
users.leana.imports = [
|
||||
"${self}/nix/home/_"
|
||||
"${self}/nix/home/${name}"
|
||||
defaultOptions
|
||||
opts
|
||||
];
|
||||
};
|
||||
}
|
||||
];
|
||||
}
|
||||
);
|
||||
|
||||
mkDarwin =
|
||||
name: sys: opts:
|
||||
withSystem sys (
|
||||
{ pkgs, ... }:
|
||||
let
|
||||
args = {
|
||||
inherit pkgs;
|
||||
hostname = name;
|
||||
};
|
||||
in
|
||||
inputs.nix-darwin.lib.darwinSystem {
|
||||
specialArgs = args;
|
||||
modules = [
|
||||
"${self}/nix/hosts/_"
|
||||
"${self}/nix/hosts/${name}"
|
||||
defaultOptions
|
||||
opts
|
||||
inputs.home-manager.darwinModules.home-manager
|
||||
{
|
||||
home-manager = {
|
||||
useGlobalPkgs = true;
|
||||
useUserPackages = true;
|
||||
extraSpecialArgs = args;
|
||||
users.leana.imports = [
|
||||
"${self}/nix/home/_"
|
||||
"${self}/nix/home/${name}"
|
||||
defaultOptions
|
||||
opts
|
||||
];
|
||||
};
|
||||
}
|
||||
];
|
||||
}
|
||||
);
|
||||
|
||||
mkHomeManager =
|
||||
name: sys: opts:
|
||||
withSystem sys (
|
||||
{ pkgs, ... }:
|
||||
let
|
||||
args = {
|
||||
inherit pkgs;
|
||||
hostname = name;
|
||||
};
|
||||
in
|
||||
inputs.home-manager.lib.homeManagerConfiguration {
|
||||
pkgs = args.pkgs;
|
||||
extraSpecialArgs = args;
|
||||
modules = [
|
||||
"${self}/nix/home/_"
|
||||
"${self}/nix/home/${name}"
|
||||
defaultOptions
|
||||
opts
|
||||
];
|
||||
}
|
||||
);
|
||||
|
||||
many = func: builtins.mapAttrs (name: opts: func name (opts.system) (opts.settings or { }));
|
||||
in
|
||||
{
|
||||
# promote helper functions into the arguments
|
||||
_module.args = {
|
||||
mkNixOSes = many mkNixOS;
|
||||
mkHomeManagers = many mkHomeManager;
|
||||
mkDarwins = many mkDarwin;
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue