refactor: pivot to lovesegfault's config structure

This commit is contained in:
oddlama 2022-12-08 23:41:07 +01:00
parent d7e6ab7071
commit 04fc94267a
No known key found for this signature in database
GPG key ID: 14EFE510775FE39A
29 changed files with 588 additions and 1150 deletions

35
nix/hosts.nix Normal file
View file

@ -0,0 +1,35 @@
let
hosts = {
nom = {
type = "nixos";
hostname = "nom";
hostPlatform = "x86_64-linux";
remoteBuild = true;
};
};
inherit (builtins) attrNames concatMap listToAttrs;
filterAttrs = pred: set:
listToAttrs (concatMap (name: let
value = set.${name};
in
if pred name value
then [{inherit name value;}]
else []) (attrNames set));
systemPred = system: (_: v: builtins.match ".*${system}.*" v.hostPlatform != null);
genFamily = filter: hosts: rec {
all = filterAttrs filter hosts;
nixos = genFamily (_: v: v.type == "nixos") all;
homeManager = genFamily (_: v: v.type == "home-manager") all;
linux = genFamily (systemPred "-linux") all;
aarch64-linux = genFamily (systemPred "aarch64-linux") all;
x86_64-linux = genFamily (systemPred "x86_64-linux") all;
};
in
genFamily (_: _: true) hosts