dconf: create generic module and use it

no more cringe function calling, yay
This commit is contained in:
Wroclaw 2024-05-29 04:46:18 +02:00
parent 23bfb2d222
commit 8f15bf0e0c
4 changed files with 244 additions and 195 deletions

View file

@ -1,9 +1,12 @@
# This file is not a NixOS system module
{config, lib, pkgs, ... }: {config, lib, pkgs, ... }:
selection:
let {
settings = with lib.gvariant; { imports = [
./generic/dconf.nix
];
config = {
proot.dconf.rules = with lib.gvariant; {
"org/gnome/desktop/background" = { "org/gnome/desktop/background" = {
picture-options = "zoom"; picture-options = "zoom";
picture-uri = "file://${../media/wallpaper.png}"; picture-uri = "file://${../media/wallpaper.png}";
@ -159,5 +162,5 @@ let
name = "Terminal"; name = "Terminal";
} else null; } else null;
}; };
in };
lib.filterAttrs (n: v: builtins.elem n selection) settings }

View file

@ -1,8 +1,9 @@
{pkgs, ... } @ moduleArgs: {pkgs, ... }:
{ {
imports = [ imports = [
../unstable-packages.nix ../unstable-packages.nix
../dconf-common.nix
]; ];
config = { config = {
services.xserver.enable = true; services.xserver.enable = true;
@ -10,8 +11,7 @@
# environment.sessionVariables.NIXOS_OZONE_WL = "1"; # environment.sessionVariables.NIXOS_OZONE_WL = "1";
programs.dconf.profiles.user.databases = [{ proot.dconf.profiles.user.rulesToApply = [
settings = import ../dconf-common.nix moduleArgs [
"org/gnome/desktop/background" "org/gnome/desktop/background"
"org/gnome/desktop/interface" "org/gnome/desktop/interface"
"org/gnome/desktop/media-handling" "org/gnome/desktop/media-handling"
@ -33,7 +33,6 @@
"org/gnome/settings-daemon/plugins/media-keys" "org/gnome/settings-daemon/plugins/media-keys"
"org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0" "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0"
]; ];
}];
environment.gnome.excludePackages = with pkgs; with pkgs.gnome; [ environment.gnome.excludePackages = with pkgs; with pkgs.gnome; [
baobab baobab

View file

@ -1,6 +1,9 @@
{pkgs, ... } @ moduleArgs: {pkgs, ... }:
{ {
imports = [
../dconf-common.nix
];
config = { config = {
services.xserver.displayManager.gdm = { services.xserver.displayManager.gdm = {
enable = true; enable = true;
@ -8,15 +11,13 @@
autoSuspend = false; autoSuspend = false;
}; };
programs.dconf.profiles.gdm.databases = [{ proot.dconf.profiles.gdm.rulesToApply = [
settings = import ../dconf-common.nix moduleArgs [
"org/gnome/desktop/interface" "org/gnome/desktop/interface"
"org/gnome/desktop/peripherals/mouse" "org/gnome/desktop/peripherals/mouse"
"org/gnome/desktop/sound" "org/gnome/desktop/sound"
"org/gnome/settings-daemon/plugins/power" "org/gnome/settings-daemon/plugins/power"
"org/gnome/shell/keybindings" "org/gnome/shell/keybindings"
]; ];
}];
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
google-cursor google-cursor

46
nix-os/generic/dconf.nix Normal file
View 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;
};
}