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,163 +1,166 @@
# This file is not a NixOS system module
{config, lib, pkgs, ... }: {config, lib, pkgs, ... }:
selection:
let {
settings = with lib.gvariant; { imports = [
"org/gnome/desktop/background" = { ./generic/dconf.nix
picture-options = "zoom"; ];
picture-uri = "file://${../media/wallpaper.png}";
picture-uri-dark = "file://${../media/wallpaper.png}"; config = {
proot.dconf.rules = with lib.gvariant; {
"org/gnome/desktop/background" = {
picture-options = "zoom";
picture-uri = "file://${../media/wallpaper.png}";
picture-uri-dark = "file://${../media/wallpaper.png}";
};
"org/gnome/desktop/interface" = {
clock-show-date = true;
clock-show-seconds = true;
clock-show-weekday = true;
color-scheme = "prefer-dark";
cursor-theme = "GoogleDot-White";
};
"org/gnome/desktop/media-handling" = {
automount = false;
};
"org/gnome/desktop/peripherals/mouse" = {
accel-profile = "flat";
};
"org/gnome/desktop/sound" = {
allow-volume-above-100-percent = true;
};
"org/gnome/desktop/wm/preferences" = {
button-layout = "appmenu:close";
resize-with-right-button = true;
};
"org/gnome/mutter" = {
dynamic-workspaces = true;
workspaces-only-on-primary = true;
};
"org/gnome/SessionManager" = {
logout-prompt = false;
};
"org/gnome/settings-daemon/plugins/power" = {
power-button-action = "notning";
sleep-inactive-ac-type = "nothing";
};
"org/gnome/shell" = {
enabled-extensions = [
"drive-menu@gnome-shell-extensions.gcampax.github.com"
"pop-shell@system76.com"
"workspace-indicator@gnome-shell-extensions.gcampax.github.com"
"Vitals@CoreCoding.com"
"trayIconsReloaded@selfmade.pl"
"places-menu@gnome-shell-extensions.gcampax.github.com"
"apps-menu@gnome-shell-extensions.gcampax.github.com"
"top-bar-organizer@julian.gse.jsts.xyz"
"color-picker@tuberry"
];
favorite-apps = [
(if builtins.elem pkgs.kitty config.environment.systemPackages then
"kitty.desktop"
else none)
"vivaldi-stable.desktop"
"code.desktop"
"org.gnome.Nautilus.desktop"
(if config.programs.steam.enable then
"steam.desktop"
else none)
"pavucontrol.desktop"
];
};
"org/gnome/shell/app-switcher" = {
current-workspace-only = false;
};
"org/gnome/shell/extensions/color-picker" = {
color-picker-shortcut = ["<Super><Alt>c"];
enable-shortcut = true;
enable-systray = false;
menu-key = "";
notify-style = mkUint32 1;
preview-style = mkUint32 0;
};
"org/gnome/shell/extensions/pop-shell" = {
active-hint = true;
active-hint-border-radius = mkUint32 1;
gap-inner = mkUint32 2;
gap-outer = mkUint32 1;
show-skip-taskbar = true;
show-title = true;
smart-gaps = false;
snap-to-grid = false;
tile-by-default = true;
};
"org/gnome/shell/extensions/top-bar-organizer" = {
center-box-order = ["dateMenu"];
left-box-order = ["activities" "apps-menu" "places-menu" "vitalsMenu"];
right-box-order = ["TrayIconsReloaded" "workspace-indicator" "pop-shell" "color-picker@tuberry" "drive-menu" "screenRecording" "screenSharing" "dwellClick" "a11y" "keyboard" "quickSettings"];
};
"org/gnome/shell/extensions/trayIconsReloaded" = {
icon-brightness = mkInt32 0;
icon-contrast = mkInt32 0;
icon-margin-horizontal = mkInt32 0;
icon-margin-vertical = mkInt32 0;
icon-padding-horizontal = mkInt32 4;
icon-padding-vertical = mkInt32 0;
icon-saturation = mkInt32 0;
icon-size = mkInt32 16;
icons-limit = mkInt32 16;
invoke-to-workspace = true;
position-weight = mkInt32 0;
tray-margin-left = mkInt32 0;
tray-margin-right = mkInt32 0;
};
"org/gnome/shell/extensions/vitals" = {
hide-icons = false;
hot-sensors = ["_processor_usage_" "_memory_allocated_"];
memory-measurement = mkInt32 1;
update-time = mkInt32 2;
use-higher-precision = true;
};
"org/gnome/shell/keybindings" = {
show-screenshot-ui = ["Print" "<Super><Shift>S"];
};
"org/gnome/desktop/default-applications/terminal" =
if builtins.elem pkgs.kitty config.environment.systemPackages then {
exec = "kitty";
exec-arg = "";
} else null;
"org/gnome/settings-daemon/plugins/media-keys" = {
custom-keybindings = [
(
if builtins.elem pkgs.kitty config.environment.systemPackages then
"/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/"
else null
)
];
help = mkEmptyArray "s";
screensaver = ["<Control><Super>l"];
};
"org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0" =
if builtins.elem pkgs.kitty config.environment.systemPackages then {
binding = "<Control><Alt>t";
command = "kitty";
name = "Terminal";
} else null;
}; };
"org/gnome/desktop/interface" = {
clock-show-date = true;
clock-show-seconds = true;
clock-show-weekday = true;
color-scheme = "prefer-dark";
cursor-theme = "GoogleDot-White";
};
"org/gnome/desktop/media-handling" = {
automount = false;
};
"org/gnome/desktop/peripherals/mouse" = {
accel-profile = "flat";
};
"org/gnome/desktop/sound" = {
allow-volume-above-100-percent = true;
};
"org/gnome/desktop/wm/preferences" = {
button-layout = "appmenu:close";
resize-with-right-button = true;
};
"org/gnome/mutter" = {
dynamic-workspaces = true;
workspaces-only-on-primary = true;
};
"org/gnome/SessionManager" = {
logout-prompt = false;
};
"org/gnome/settings-daemon/plugins/power" = {
power-button-action = "notning";
sleep-inactive-ac-type = "nothing";
};
"org/gnome/shell" = {
enabled-extensions = [
"drive-menu@gnome-shell-extensions.gcampax.github.com"
"pop-shell@system76.com"
"workspace-indicator@gnome-shell-extensions.gcampax.github.com"
"Vitals@CoreCoding.com"
"trayIconsReloaded@selfmade.pl"
"places-menu@gnome-shell-extensions.gcampax.github.com"
"apps-menu@gnome-shell-extensions.gcampax.github.com"
"top-bar-organizer@julian.gse.jsts.xyz"
"color-picker@tuberry"
];
favorite-apps = [
(if builtins.elem pkgs.kitty config.environment.systemPackages then
"kitty.desktop"
else none)
"vivaldi-stable.desktop"
"code.desktop"
"org.gnome.Nautilus.desktop"
(if config.programs.steam.enable then
"steam.desktop"
else none)
"pavucontrol.desktop"
];
};
"org/gnome/shell/app-switcher" = {
current-workspace-only = false;
};
"org/gnome/shell/extensions/color-picker" = {
color-picker-shortcut = ["<Super><Alt>c"];
enable-shortcut = true;
enable-systray = false;
menu-key = "";
notify-style = mkUint32 1;
preview-style = mkUint32 0;
};
"org/gnome/shell/extensions/pop-shell" = {
active-hint = true;
active-hint-border-radius = mkUint32 1;
gap-inner = mkUint32 2;
gap-outer = mkUint32 1;
show-skip-taskbar = true;
show-title = true;
smart-gaps = false;
snap-to-grid = false;
tile-by-default = true;
};
"org/gnome/shell/extensions/top-bar-organizer" = {
center-box-order = ["dateMenu"];
left-box-order = ["activities" "apps-menu" "places-menu" "vitalsMenu"];
right-box-order = ["TrayIconsReloaded" "workspace-indicator" "pop-shell" "color-picker@tuberry" "drive-menu" "screenRecording" "screenSharing" "dwellClick" "a11y" "keyboard" "quickSettings"];
};
"org/gnome/shell/extensions/trayIconsReloaded" = {
icon-brightness = mkInt32 0;
icon-contrast = mkInt32 0;
icon-margin-horizontal = mkInt32 0;
icon-margin-vertical = mkInt32 0;
icon-padding-horizontal = mkInt32 4;
icon-padding-vertical = mkInt32 0;
icon-saturation = mkInt32 0;
icon-size = mkInt32 16;
icons-limit = mkInt32 16;
invoke-to-workspace = true;
position-weight = mkInt32 0;
tray-margin-left = mkInt32 0;
tray-margin-right = mkInt32 0;
};
"org/gnome/shell/extensions/vitals" = {
hide-icons = false;
hot-sensors = ["_processor_usage_" "_memory_allocated_"];
memory-measurement = mkInt32 1;
update-time = mkInt32 2;
use-higher-precision = true;
};
"org/gnome/shell/keybindings" = {
show-screenshot-ui = ["Print" "<Super><Shift>S"];
};
"org/gnome/desktop/default-applications/terminal" =
if builtins.elem pkgs.kitty config.environment.systemPackages then {
exec = "kitty";
exec-arg = "";
} else null;
"org/gnome/settings-daemon/plugins/media-keys" = {
custom-keybindings = [
(
if builtins.elem pkgs.kitty config.environment.systemPackages then
"/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/"
else null
)
];
help = mkEmptyArray "s";
screensaver = ["<Control><Super>l"];
};
"org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0" =
if builtins.elem pkgs.kitty config.environment.systemPackages then {
binding = "<Control><Alt>t";
command = "kitty";
name = "Terminal";
} 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,30 +11,28 @@
# 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" "org/gnome/desktop/peripherals/mouse"
"org/gnome/desktop/peripherals/mouse" "org/gnome/desktop/sound"
"org/gnome/desktop/sound" "org/gnome/desktop/wm/preferences"
"org/gnome/desktop/wm/preferences" "org/gnome/mutter"
"org/gnome/mutter" "org/gnome/SessionManager"
"org/gnome/SessionManager" "org/gnome/settings-daemon/plugins/power"
"org/gnome/settings-daemon/plugins/power" "org/gnome/shell"
"org/gnome/shell" "org/gnome/shell/app-switcher"
"org/gnome/shell/app-switcher" "org/gnome/shell/extensions/color-picker"
"org/gnome/shell/extensions/color-picker" "org/gnome/shell/extensions/pop-shell"
"org/gnome/shell/extensions/pop-shell" "org/gnome/shell/extensions/top-bar-organizer"
"org/gnome/shell/extensions/top-bar-organizer" "org/gnome/shell/extensions/trayIconsReloaded"
"org/gnome/shell/extensions/trayIconsReloaded" "org/gnome/shell/extensions/vitals"
"org/gnome/shell/extensions/vitals" "org/gnome/shell/keybindings"
"org/gnome/shell/keybindings" "org/gnome/desktop/default-applications/terminal"
"org/gnome/desktop/default-applications/terminal" "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,18 +11,16 @@
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;
};
}