fork/home-manager
git clone https://git.julia.blue/fork/home-manager
75790441
master
1{ config , lib , pkgs , ...} : 2 3with lib ; 4 5let 6 7cfg = config . xsession . windowManager . spectrwm ; 8 9renderedValue = val : 10if isBool val then if val then "1" else "0" else toString val ; 11 12renderedSettings = settings : 13mapAttrsToList ( name :value :" ${ name } = ${ renderedValue value } " ) settings ; 14 15renderedBindings = bindings : 16mapAttrsToList ( name :value :"bind[ ${ name } ] = ${ value } " ) bindings ; 17 18renderedUnbindings = unbindings :map ( value :"bind[] = ${ value } " ) unbindings ; 19 20renderedPrograms = programs : 21mapAttrsToList ( name :value :"program[ ${ name } ] = ${ value } " ) programs ; 22 23renderedQuirks = quirks : 24mapAttrsToList ( name :value :"quirk[ ${ name } ] = ${ value } " ) quirks ; 25 26settingType = types . oneOf [ types . bool types . int types . str ]; 27 28in { 29meta . maintainers = [ hm . maintainers . loicreynier ]; 30 31options = { 32xsession . windowManager . spectrwm = { 33enable = mkEnableOption "Spectrwm window manager" ; 34 35package = mkOption { 36type = types . package ; 37default = pkgs . spectrwm ; 38defaultText = literalExpression "pkgs.spectrwm" ; 39description = '' 40Package providing the {command}`spectrwm` command. 41'' ; 42}; 43 44settings = mkOption { 45type = types . attrsOf settingType ; 46default = { }; 47example = literalExpression '' 48{ 49modkey = "Mod4"; 50workspace_limit = 5; 51focus_mode = "manual"; 52focus_close = "next"; 53} 54'' ; 55description = "Spectrwm settings." ; 56}; 57 58bindings = mkOption { 59type = types . attrsOf types . str ; 60default = { }; 61example = literalExpression '' 62{ 63term = "Mod+Return"; 64restart = "Mod+Shift+r"; 65quit = "Mod+Shift+q"; 66} 67'' ; 68description = "Spectrwm keybindings." ; 69}; 70 71unbindings = mkOption { 72type = types . listOf types . str ; 73default = [ ]; 74example = literalExpression '' 75[ 76"MOD+e" 77"MOD+f" 78"MOD+m" 79"MOD+s" 80"MOD+u" 81"MOD+t" 82] 83'' ; 84description = '' 85List of keybindings to disable from default Spectrwm configuration. 86'' ; 87}; 88 89programs = mkOption { 90type = types . attrsOf types . str ; 91default = { }; 92example = literalExpression '' 93{ 94term = "alacritty"; 95search = "dmenu -ip -p 'Window name/id:'; 96} 97'' ; 98description = "Spectrwm programs variables." ; 99}; 100 101quirks = mkOption { 102type = types . attrsOf types . str ; 103default = { }; 104example = literalExpression '' 105{ 106Matplotlib = "FLOAT"; 107Pavucontrol = "FLOAT"; 108} 109'' ; 110description = "Spectrwm quicks (custom window rules)." ; 111}; 112}; 113}; 114 115config = mkIf cfg . enable { 116assertions = [ 117( hm . assertions . assertPlatform "xsession.windowManager.spectrwm" pkgs 118platforms . linux ) 119]; 120 121home . packages = [ cfg . package ]; 122 123xsession . windowManager . command = " ${ cfg . package } /bin/spectrwm" ; 124 125xdg . configFile . "spectrwm/spectrwm.conf" . text = '' 126# Generated by Home Manager 127${ concatStringsSep "\n" ( # \ 128renderedSettings cfg . settings # \ 129++ renderedPrograms cfg . programs # \ 130++ renderedQuirks cfg . quirks # \ 131++ renderedBindings cfg . bindings # \ 132++ renderedUnbindings cfg . unbindings )} 133'' ; 134}; 135}