forked from jan-leila/nix-config
		
	
		
			
				
	
	
		
			125 lines
		
	
	
	
		
			3.8 KiB
		
	
	
	
		
			Nix
		
	
	
	
	
	
			
		
		
	
	
			125 lines
		
	
	
	
		
			3.8 KiB
		
	
	
	
		
			Nix
		
	
	
	
	
	
| {
 | |
|   lib,
 | |
|   config,
 | |
|   ...
 | |
| }: {
 | |
|   options.gnome = {
 | |
|     extraWindowControls = lib.mkEnableOption "Should we add back in the minimize and maximize window controls?";
 | |
|     clockFormat = lib.mkOption {
 | |
|       type = lib.types.enum [
 | |
|         "12h"
 | |
|         "24h"
 | |
|       ];
 | |
|       default = "24h";
 | |
|     };
 | |
|     colorScheme = lib.mkOption {
 | |
|       type = lib.types.enum [
 | |
|         "default"
 | |
|         "prefer-dark"
 | |
|         "prefer-light"
 | |
|       ];
 | |
|       default = "default";
 | |
|     };
 | |
|     accentColor = lib.mkOption {
 | |
|       type = lib.types.enum [
 | |
|         "blue"
 | |
|         "teal"
 | |
|         "green"
 | |
|         "yellow"
 | |
|         "orange"
 | |
|         "red"
 | |
|         "pink"
 | |
|         "purple"
 | |
|         "slate"
 | |
|       ];
 | |
|       default = "blue";
 | |
|     };
 | |
|     extensions = lib.mkOption {
 | |
|       type = lib.types.listOf lib.types.package;
 | |
|       default = [];
 | |
|       description = "The set of extensions to install and enable in the user environment.";
 | |
|     };
 | |
|     hotkeys = lib.mkOption {
 | |
|       type = lib.types.attrsOf (lib.types.submodule ({name, ...}: {
 | |
|         options = {
 | |
|           key = lib.mkOption {
 | |
|             type = lib.types.strMatching "[a-zA-Z0-9-]+";
 | |
|             default = builtins.replaceStrings [" " "/" "_"] ["-" "-" "-"] name;
 | |
|           };
 | |
|           name = lib.mkOption {
 | |
|             type = lib.types.str;
 | |
|             default = name;
 | |
|           };
 | |
|           binding = lib.mkOption {
 | |
|             type = lib.types.str;
 | |
|           };
 | |
|           command = lib.mkOption {
 | |
|             type = lib.types.str;
 | |
|           };
 | |
|         };
 | |
|       }));
 | |
|       default = {};
 | |
|     };
 | |
|     displayScaling = lib.mkOption {
 | |
|       type = lib.types.nullOr (lib.types.enum [100 125 150 175 200]);
 | |
|       default = null;
 | |
|       description = "Display scaling percentage for GNOME";
 | |
|     };
 | |
|     experimentalFeatures = lib.mkOption {
 | |
|       type = lib.types.submodule {
 | |
|         options = {
 | |
|           scaleMonitorFramebuffer = lib.mkEnableOption "scale-monitor-framebuffer experimental feature";
 | |
|         };
 | |
|       };
 | |
|       default = {};
 | |
|       description = "GNOME experimental features to enable";
 | |
|     };
 | |
|   };
 | |
| 
 | |
|   config = {
 | |
|     home.packages = config.gnome.extensions;
 | |
|     dconf = {
 | |
|       settings = lib.mkMerge [
 | |
|         {
 | |
|           "org/gnome/shell" = {
 | |
|             disable-user-extensions = false; # enables user extensions
 | |
|             enabled-extensions = builtins.map (extension: extension.extensionUuid) config.gnome.extensions;
 | |
|           };
 | |
| 
 | |
|           "org/gnome/desktop/wm/preferences".button-layout = lib.mkIf config.gnome.extraWindowControls ":minimize,maximize,close";
 | |
| 
 | |
|           "org/gnome/desktop/interface".color-scheme = config.gnome.colorScheme;
 | |
|           "org/gnome/desktop/interface".accent-color = config.gnome.accentColor;
 | |
|           "org/gnome/desktop/interface".clock-format = config.gnome.clockFormat;
 | |
|           "org/gnome/desktop/interface".text-scaling-factor = lib.mkIf (config.gnome.displayScaling != null) (config.gnome.displayScaling / 100.0);
 | |
| 
 | |
|           "org/gnome/mutter".experimental-features = lib.mkIf (builtins.any (x: x) (builtins.attrValues config.gnome.experimentalFeatures)) (
 | |
|             lib.optional config.gnome.experimentalFeatures.scaleMonitorFramebuffer "scale-monitor-framebuffer"
 | |
|           );
 | |
|         }
 | |
|         (
 | |
|           lib.mkMerge (
 | |
|             builtins.map (value: let
 | |
|               entry = "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/${value.key}";
 | |
|             in {
 | |
|               ${entry} = {
 | |
|                 binding = value.binding;
 | |
|                 command = value.command;
 | |
|                 name = value.name;
 | |
|               };
 | |
| 
 | |
|               "org/gnome/settings-daemon/plugins/media-keys" = {
 | |
|                 custom-keybindings = [
 | |
|                   "/${entry}/"
 | |
|                 ];
 | |
|               };
 | |
|             })
 | |
|             (
 | |
|               lib.attrsets.mapAttrsToList (_: value: value) config.gnome.hotkeys
 | |
|             )
 | |
|           )
 | |
|         )
 | |
|       ];
 | |
|     };
 | |
|   };
 | |
| }
 |