mirror of
https://codeberg.org/leana8959/.files.git
synced 2025-12-06 14:49:14 +00:00
Drop flake parts
Use native nix functions to speed up and reduce complexity
This commit is contained in:
parent
85e2bd6728
commit
daefd1534f
15 changed files with 501 additions and 423 deletions
85
nix/lib/default.nix
Normal file
85
nix/lib/default.nix
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
inputs:
|
||||
|
||||
let
|
||||
inherit (inputs.nixpkgs) lib;
|
||||
in
|
||||
|
||||
{
|
||||
mkNixOS =
|
||||
sharedModules:
|
||||
{
|
||||
hostname,
|
||||
system,
|
||||
modules ? [ ],
|
||||
}:
|
||||
inputs.nixpkgs.lib.nixosSystem {
|
||||
specialArgs = {
|
||||
inherit hostname;
|
||||
};
|
||||
modules = sharedModules { inherit hostname system; } ++ modules;
|
||||
};
|
||||
|
||||
mkDarwin =
|
||||
sharedModules:
|
||||
{
|
||||
hostname,
|
||||
system,
|
||||
modules ? [ ],
|
||||
}:
|
||||
inputs.nix-darwin.lib.darwinSystem {
|
||||
specialArgs = {
|
||||
inherit hostname;
|
||||
};
|
||||
modules = sharedModules { inherit hostname system; } ++ modules;
|
||||
};
|
||||
|
||||
mkHomeManager =
|
||||
sharedModules:
|
||||
{
|
||||
hostname,
|
||||
system,
|
||||
modules ? [ ],
|
||||
}:
|
||||
let
|
||||
pkgs = import inputs.nixpkgs { };
|
||||
in
|
||||
inputs.home-manager.lib.homeManagerConfiguration {
|
||||
inherit pkgs;
|
||||
extraSpecialArgs = {
|
||||
inherit hostname;
|
||||
};
|
||||
modules = sharedModules { inherit hostname system; } ++ modules;
|
||||
};
|
||||
|
||||
many = func: builtins.mapAttrs (hostname: cfgs: func (cfgs // { inherit hostname; }));
|
||||
|
||||
maybePathOrDefault =
|
||||
path: default:
|
||||
if
|
||||
lib.pathExists # Test directory/default.nix or just the file
|
||||
(if lib.pathIsDirectory path then (lib.path.append path "default.nix") else path)
|
||||
then
|
||||
path
|
||||
else
|
||||
default;
|
||||
|
||||
mergeAttrsWith =
|
||||
f: xs: ys:
|
||||
builtins.foldl' (
|
||||
acc: n: acc // (if acc ? ${n} then { ${n} = f xs.${n} ys.${n}; } else { ${n} = ys.${n}; })
|
||||
) xs (builtins.attrNames ys);
|
||||
|
||||
modulesFromDir =
|
||||
path:
|
||||
lib.pipe (builtins.readDir path) [
|
||||
(lib.filterAttrs (moduleName: _: moduleName != "default.nix"))
|
||||
(lib.mapAttrs' (
|
||||
moduleName: _: {
|
||||
name = lib.strings.removeSuffix ".nix" moduleName;
|
||||
value = lib.path.append path moduleName;
|
||||
}
|
||||
))
|
||||
];
|
||||
|
||||
mkNerdFont = import ./mkNerdFont.nix;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue