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