mirror of
https://github.com/oddlama/nix-config.git
synced 2025-10-11 07:10:39 +02:00
chore: clean up the inherited clutter
This commit is contained in:
parent
4da937bcd0
commit
418db9db0c
6 changed files with 25 additions and 60 deletions
|
@ -1,49 +1,5 @@
|
|||
with builtins; let
|
||||
hosts = {
|
||||
nom = {
|
||||
type = "nixos";
|
||||
system = "x86_64-linux";
|
||||
};
|
||||
ward = {
|
||||
type = "nixos";
|
||||
system = "x86_64-linux";
|
||||
};
|
||||
};
|
||||
|
||||
filterAttrs = pred: set:
|
||||
listToAttrs (concatMap (name: let
|
||||
value = set.${name};
|
||||
in
|
||||
if pred name value
|
||||
then [{inherit name value;}]
|
||||
else []) (attrNames set));
|
||||
|
||||
removeEmptyAttrs = filterAttrs (_: v: v != {});
|
||||
|
||||
# TODO: so much strange shit
|
||||
genSystemGroups = hosts: let
|
||||
systems = ["aarch64-linux" "x86_64-linux"];
|
||||
systemHostGroup = name: {
|
||||
inherit name;
|
||||
value = filterAttrs (_: host: host.system == name) hosts;
|
||||
};
|
||||
in
|
||||
removeEmptyAttrs (listToAttrs (map systemHostGroup systems));
|
||||
|
||||
genTypeGroups = hosts: let
|
||||
types = ["homeManager" "nixos"];
|
||||
typeHostGroup = name: {
|
||||
inherit name;
|
||||
value = filterAttrs (_: host: host.type == name) hosts;
|
||||
};
|
||||
in
|
||||
removeEmptyAttrs (listToAttrs (map typeHostGroup types));
|
||||
|
||||
genHostGroups = hosts: let
|
||||
all = hosts;
|
||||
systemGroups = genSystemGroups all;
|
||||
typeGroups = genTypeGroups all;
|
||||
in
|
||||
all // systemGroups // typeGroups // {inherit all;};
|
||||
in
|
||||
genHostGroups hosts
|
||||
{nixpkgs, ...}:
|
||||
nixpkgs.lib.concatMapAttrs (hostName: fileType:
|
||||
if fileType == "directory"
|
||||
then {${hostName} = import (../hosts + "/${hostName}/meta.nix");}
|
||||
else {}) (builtins.readDir ../hosts)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue