{ config, lib, osConfig, ... }: let cfg = config.gnome; in { imports = [ ./extensions ]; options.gnome = with lib.types; { profilePicture = lib.mkOption { type = nullOr path; default = null; }; keyboard = { sources = lib.mkOption { type = listOf str; default = [ "us" ]; }; }; keybindings = { builtin = lib.mkOption { type = attrsOf (listOf str); default = { }; }; custom = lib.mkOption { type = listOf (submodule { options = { binding = lib.mkOption { type = str; }; command = lib.mkOption { type = str; }; name = lib.mkOption { type = str; }; }; }); default = [ ]; }; }; scalingFactor = lib.mkOption { type = numbers.positive; default = 1; }; power = { powerButton = lib.mkOption { type = enum [ "suspend" "interactive" "hibernate" "nothing" ]; default = "interactive"; }; }; nightLight = { enable = lib.mkEnableOption { }; temperature = lib.mkOption { type = ints.between 1700 4700; default = 2700; }; schedule = lib.mkOption { type = nullOr (submodule { options = { from = lib.mkOption { type = numbers.between 0 23.99; default = 20.0; }; to = lib.mkOption { type = numbers.between 0 23.99; default = 8.0; }; }; }); default = null; }; }; calendar = { showWeekNumbers = lib.mkEnableOption { }; }; automaticTimeZone = lib.mkEnableOption { }; region = lib.mkOption { type = str; default = osConfig.i18n.defaultLocale; }; }; config = { dconf.settings = with lib.hm.gvariant; { "org/gnome/shell/keybindings" = cfg.keybindings.builtin; "org/gnome/settings-daemon/plugins/media-keys" = { custom-keybindings = ( lib.lists.imap0 ( i: _: "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom${toString i}/" ) cfg.keybindings.custom ); }; "org/gnome/desktop/input-sources" = { sources = map ( source: mkTuple [ "xkb" source ] ) cfg.keyboard.sources; }; "org/gnome/mutter" = { experimental-features = [ "scale-monitor-framebuffer" ]; }; "org/gnome/settings-daemon/plugins/xsettings" = { overrides = [ (mkTuple [ "GdkWindowScalingFactor" cfg.scalingFactor ]) ]; }; "org/gnome/desktop/interface" = { scaling-factor = cfg.scalingFactor; }; "org/gnome/settings-daemon/plugins/power" = { "power-button-action" = cfg.power.powerButton; }; "org/gnome/settings-daemon/plugins/color" = with cfg.nightLight; { night-light-enabled = enable; night-light-temperature = temperature; night-light-schedule-automatic = isNull schedule; night-light-schedule-from = lib.mkIf (!isNull schedule) schedule.from; night-light-schedule-to = lib.mkIf (!isNull schedule) schedule.to; }; "org/gnome/desktop/calendar" = { show-weekdate = cfg.calendar.showWeekNumbers; }; "org/gnome/desktop/datetime" = { automatic-timezone = cfg.automaticTimeZone; }; "system/locale" = { region = cfg.region; }; } // (builtins.listToAttrs ( lib.lists.imap0 (i: keybinding: { name = "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom${toString i}"; value = keybinding; }) cfg.keybindings.custom )); home.file.".face".source = lib.mkIf (!isNull cfg.profilePicture) cfg.profilePicture; }; }