dconf: create generic module and use it
no more cringe function calling, yay
This commit is contained in:
parent
23bfb2d222
commit
8f15bf0e0c
4 changed files with 244 additions and 195 deletions
46
nix-os/generic/dconf.nix
Normal file
46
nix-os/generic/dconf.nix
Normal file
|
@ -0,0 +1,46 @@
|
|||
{ 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;
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue