46 lines
1.3 KiB
Nix
46 lines
1.3 KiB
Nix
{ config, lib, pkgs, options, ... }:
|
|
|
|
# proot.dconf.rules
|
|
# proot.dconf.profiles.<profile>.rulesToApply
|
|
# proot.dconf.profiles.<profile>.extraRules
|
|
let
|
|
cfg = config.proot.dconf;
|
|
profileOpts = lib.types.submodule {
|
|
options = {
|
|
rulesToApply = lib.mkOption {
|
|
type = lib.types.listOf lib.types.str;
|
|
default = lib.attrNames cfg.rules;
|
|
description = lib.mdDoc "A list of rules keys to apply for profile";
|
|
};
|
|
extraRules = lib.mkOption {
|
|
type = lib.types.attrs;
|
|
default = {};
|
|
description = lib.mdDoc "An attrset of additional dconf rules to apply ontop of selected";
|
|
};
|
|
};
|
|
};
|
|
|
|
mapper = _: value: {
|
|
databases = lib.singleton {
|
|
settings = lib.filterAttrs (key: _: lib.elem key value.rulesToApply) cfg.rules // value.extraRules;
|
|
};
|
|
};
|
|
in
|
|
{
|
|
options.proot.dconf = {
|
|
rules = lib.mkOption {
|
|
type = lib.types.attrs;
|
|
default = {};
|
|
description = lib.mdDoc "An attrset of dconf rules to pull from";
|
|
};
|
|
profiles = lib.mkOption {
|
|
type = lib.types.attrsOf profileOpts;
|
|
default = {};
|
|
description = lib.mdDoc "An attret of profiles to create, with pulled rules";
|
|
};
|
|
};
|
|
|
|
config = {
|
|
programs.dconf.profiles = lib.mapAttrs mapper cfg.profiles;
|
|
};
|
|
}
|