my over complex system configurations
dotfiles.isabelroses.com/
nixos
nix
flake
dotfiles
linux
1{ lib, ... }:
2let
3 inherit (lib)
4 getAttrFromPath
5 filter
6 hasAttr
7 any
8 ;
9
10 /**
11 a function that will append a list of groups if they exist in config.users.groups
12
13 # Arguments
14
15 - [config] the configuration that nixosConfigurations provides
16 - [groups] a list of groups to check for
17
18 # Type
19
20 ```
21 ifTheyExist :: AttrSet -> List -> List
22 ```
23
24 # Example
25
26 ```nix
27 ifTheyExist config ["wheel" "users"]
28 => ["wheel"]
29 ```
30 */
31 ifTheyExist = config: groups: filter (group: hasAttr group config.users.groups) groups;
32
33 /**
34 check if a predicate for any user config is true
35
36 # Arguments
37
38 - [conf] the configuration that nixosConfigurations provides
39 - [cond] predicate function to check against config variable
40
41 # Type
42
43 ```
44 anyHome :: AttrSet -> (Any -> Bool) -> Bool
45 ```
46
47 # Example
48
49 ```nix
50 anyHome config (cfg: cfg.programs.hyprland.enable)
51 => true
52 ```
53 */
54 anyHome =
55 conf: cond:
56 let
57 list = map (
58 user:
59 getAttrFromPath [
60 "home-manager"
61 "users"
62 user
63 ] conf
64 ) conf.garden.system.users;
65 in
66 any cond list;
67in
68{
69 inherit
70 ifTheyExist
71 anyHome
72 ;
73}