fork/home-manager
git clone https://git.julia.blue/fork/home-manager
e0c70942
master
1{ config , lib , moduleName , cfg , pkgs , capitalModuleName ? moduleName } : 2 3with lib ; 4 5let 6isI3 = moduleName == "i3" ; 7isSway = ! isI3 ; 8 9inherit ( config . home ) stateVersion ; 10 11fontOptions = types . submodule { 12options = { 13names = mkOption { 14type = types . listOf types . str ; 15default = [ "monospace" ]; 16defaultText = literalExpression ''[ "monospace" ]'' ; 17description = '' 18List of font names list used for window titles. Only FreeType fonts are supported. 19The order here is important (e.g. icons font should go before the one used for text). 20'' ; 21example = literalExpression ''[ "FontAwesome" "Terminus" ]'' ; 22}; 23 24style = mkOption { 25type = types . str ; 26default = "" ; 27description = '' 28The font style to use for window titles. 29'' ; 30example = "Bold Semi-Condensed" ; 31}; 32 33size = mkOption { 34type = types . float ; 35default = 8.0 ; 36description = '' 37The font size to use for window titles. 38'' ; 39example = 11.5 ; 40}; 41}; 42}; 43 44startupModule = types . submodule { 45options = { 46command = mkOption { 47type = types . str ; 48description = "Command that will be executed on startup." ; 49}; 50 51always = mkOption { 52type = types . bool ; 53default = false ; 54description = "Whether to run command on each ${ moduleName } restart." ; 55}; 56} // optionalAttrs isI3 { 57notification = mkOption { 58type = types . bool ; 59default = true ; 60description = '' 61Whether to enable startup-notification support for the command. 62See {option}`--no-startup-id` option description in the i3 user guide. 63'' ; 64}; 65 66workspace = mkOption { 67type = types . nullOr types . str ; 68default = null ; 69description = '' 70Launch application on a particular workspace. DEPRECATED: 71Use [](#opt-xsession.windowManager.i3.config.assigns) 72instead. See <https://github.com/nix-community/home-manager/issues/265>. 73'' ; 74}; 75}; 76 77}; 78 79barModule = types . submodule { 80options = let 81versionAtLeast2009 = versionAtLeast stateVersion "20.09" ; 82mkNullableOption = { type , default , ...} @args : 83mkOption ( args // { 84type = types . nullOr type ; 85default = if versionAtLeast2009 then null else default ; 86defaultText = literalExpression '' 87null for state version ≥ 20.09, as example otherwise 88'' ; 89example = default ; 90}); 91in { 92fonts = mkOption { 93type = with types ; either ( listOf str ) fontOptions ; 94default = { }; 95example = literalExpression '' 96{ 97names = [ "DejaVu Sans Mono" "FontAwesome5Free" ]; 98style = "Bold Semi-Condensed"; 99size = 11.0; 100} 101'' ; 102description = "Font configuration for this bar." ; 103}; 104 105extraConfig = mkOption { 106type = types . lines ; 107default = "" ; 108description = "Extra configuration lines for this bar." ; 109}; 110 111id = mkOption { 112type = types . nullOr types . str ; 113default = null ; 114description = '' 115Specifies the bar ID for the configured bar instance. 116If this option is missing, the ID is set to bar-x, where x corresponds 117to the position of the embedding bar block in the config file. 118'' ; 119}; 120 121mode = mkNullableOption { 122type = types . enum [ "dock" "hide" "invisible" ]; 123default = "dock" ; 124description = "Bar visibility mode." ; 125}; 126 127hiddenState = mkNullableOption { 128type = types . enum [ "hide" "show" ]; 129default = "hide" ; 130description = "The default bar mode when 'bar.mode' == 'hide'." ; 131}; 132 133position = mkNullableOption { 134type = types . enum [ "top" "bottom" ]; 135default = "bottom" ; 136description = "The edge of the screen ${ moduleName } bar should show up." ; 137}; 138 139workspaceButtons = mkNullableOption { 140type = types . bool ; 141default = true ; 142description = "Whether workspace buttons should be shown or not." ; 143}; 144 145workspaceNumbers = mkNullableOption { 146type = types . bool ; 147default = true ; 148description = 149"Whether workspace numbers should be displayed within the workspace buttons." ; 150}; 151 152command = mkOption { 153type = types . str ; 154default = let 155# If the user uses the "system" Sway (i.e. cfg.package == null) then the bar has 156# to come from a different package 157pkg = if isSway && isNull cfg . package then pkgs . sway else cfg . package ; 158in " ${ pkg } /bin/ ${ moduleName } bar" ; 159defaultText = "i3bar" ; 160description = "Command that will be used to start a bar." ; 161example = if isI3 then 162"\${pkgs.i3}/bin/i3bar -t" 163else 164"\${pkgs.waybar}/bin/waybar" ; 165}; 166 167statusCommand = mkNullableOption { 168type = types . str ; 169default = " ${ pkgs . i3status } /bin/i3status" ; 170description = "Command that will be used to get status lines." ; 171}; 172 173colors = mkOption { 174type = types . submodule { 175options = { 176background = mkNullableOption { 177type = types . str ; 178default = "#000000" ; 179description = "Background color of the bar." ; 180}; 181 182statusline = mkNullableOption { 183type = types . str ; 184default = "#ffffff" ; 185description = "Text color to be used for the statusline." ; 186}; 187 188separator = mkNullableOption { 189type = types . str ; 190default = "#666666" ; 191description = "Text color to be used for the separator." ; 192}; 193 194focusedBackground = mkOption { 195type = types . nullOr types . str ; 196default = null ; 197description = 198"Background color of the bar on the currently focused monitor output." ; 199example = "#000000" ; 200}; 201 202focusedStatusline = mkOption { 203type = types . nullOr types . str ; 204default = null ; 205description = 206"Text color to be used for the statusline on the currently focused monitor output." ; 207example = "#ffffff" ; 208}; 209 210focusedSeparator = mkOption { 211type = types . nullOr types . str ; 212default = null ; 213description = 214"Text color to be used for the separator on the currently focused monitor output." ; 215example = "#666666" ; 216}; 217 218focusedWorkspace = mkNullableOption { 219type = barColorSetModule ; 220default = { 221border = "#4c7899" ; 222background = "#285577" ; 223text = "#ffffff" ; 224}; 225description = '' 226Border, background and text color for a workspace button when the workspace has focus. 227'' ; 228}; 229 230activeWorkspace = mkNullableOption { 231type = barColorSetModule ; 232default = { 233border = "#333333" ; 234background = "#5f676a" ; 235text = "#ffffff" ; 236}; 237description = '' 238Border, background and text color for a workspace button when the workspace is active. 239'' ; 240}; 241 242inactiveWorkspace = mkNullableOption { 243type = barColorSetModule ; 244default = { 245border = "#333333" ; 246background = "#222222" ; 247text = "#888888" ; 248}; 249description = '' 250Border, background and text color for a workspace button when the workspace does not 251have focus and is not active. 252'' ; 253}; 254 255urgentWorkspace = mkNullableOption { 256type = barColorSetModule ; 257default = { 258border = "#2f343a" ; 259background = "#900000" ; 260text = "#ffffff" ; 261}; 262description = '' 263Border, background and text color for a workspace button when the workspace contains 264a window with the urgency hint set. 265'' ; 266}; 267 268bindingMode = mkNullableOption { 269type = barColorSetModule ; 270default = { 271border = "#2f343a" ; 272background = "#900000" ; 273text = "#ffffff" ; 274}; 275description = 276"Border, background and text color for the binding mode indicator" ; 277}; 278}; 279}; 280default = { }; 281description = '' 282Bar color settings. All color classes can be specified using submodules 283with 'border', 'background', 'text', fields and RGB color hex-codes as values. 284See default values for the reference. 285Note that 'background', 'status', and 'separator' parameters take a single RGB value. 286 287See <https://i3wm.org/docs/userguide.html#_colors>. 288'' ; 289}; 290 291trayOutput = mkNullableOption { 292type = types . str ; 293# Sway/Wayland doesn't have the concept of a primary output. The default for sway is to show it on all outputs 294default = if isI3 then "primary" else "*" ; 295description = "Where to output tray." ; 296}; 297 298trayPadding = mkNullableOption { 299type = types . int ; 300default = null ; 301description = '' 302Sets the pixel padding of the system tray. 303This padding will surround the tray on all sides and between each item. 304'' ; 305}; 306}; 307}; 308 309barColorSetModule = types . submodule { 310options = { 311border = mkOption { 312type = types . str ; 313visible = false ; 314}; 315 316background = mkOption { 317type = types . str ; 318visible = false ; 319}; 320 321text = mkOption { 322type = types . str ; 323visible = false ; 324}; 325}; 326}; 327 328colorSetModule = types . submodule { 329options = { 330border = mkOption { 331type = types . str ; 332visible = false ; 333}; 334 335childBorder = mkOption { 336type = types . str ; 337visible = false ; 338}; 339 340background = mkOption { 341type = types . str ; 342visible = false ; 343}; 344 345text = mkOption { 346type = types . str ; 347visible = false ; 348}; 349 350indicator = mkOption { 351type = types . str ; 352visible = false ; 353}; 354}; 355}; 356 357windowCommandModule = types . submodule { 358options = { 359command = mkOption { 360type = types . str ; 361description = " ${ capitalModuleName } wm command to execute." ; 362example = "border pixel 1" ; 363}; 364 365criteria = mkOption { 366type = criteriaModule ; 367description = '' 368Criteria of the windows on which command should be executed. 369 370A value of `true` is equivalent to using an empty 371criteria (which is different from an empty string criteria). 372'' ; 373example = literalExpression '' 374{ 375title = "x200: ~/work"; 376floating = true; 377}; 378'' ; 379}; 380}; 381}; 382 383criteriaModule = types . attrsOf ( types . either types . str types . bool ); 384in { 385fonts = mkOption { 386type = with types ; either ( listOf str ) fontOptions ; 387default = { }; 388example = literalExpression '' 389{ 390names = [ "DejaVu Sans Mono" "FontAwesome5Free" ]; 391style = "Bold Semi-Condensed"; 392size = 11.0; 393} 394'' ; 395description = "Font configuration for window titles, nagbar..." ; 396}; 397 398window = mkOption { 399type = types . submodule { 400options = { 401titlebar = mkOption { 402type = types . bool ; 403default = if versionOlder stateVersion "23.05" then 404( isI3 && ( cfg . config . gaps == null )) 405else 406true ; 407defaultText = if isI3 then '' 408true for state version ≥ 23.05 409config.gaps == null for state version < 23.05 410'' else '' 411true for state version ≥ 23.05 412false for state version < 23.05 413'' ; 414description = "Whether to show window titlebars." ; 415}; 416 417border = mkOption { 418type = types . int ; 419default = 2 ; 420description = "Window border width." ; 421}; 422 423hideEdgeBorders = mkOption { 424type = types . enum [ "none" "vertical" "horizontal" "both" "smart" ]; 425default = "none" ; 426description = "Hide window borders adjacent to the screen edges." ; 427}; 428 429commands = mkOption { 430type = types . listOf windowCommandModule ; 431default = [ ]; 432description = '' 433List of commands that should be executed on specific windows. 434See {option}`for_window` ${ moduleName } wm option documentation. 435'' ; 436example = [{ 437command = "border pixel 1" ; 438criteria = { class = "XTerm" ; }; 439}]; 440}; 441}; 442}; 443default = { }; 444description = "Window titlebar and border settings." ; 445}; 446 447floating = mkOption { 448type = types . submodule { 449options = { 450titlebar = mkOption { 451type = types . bool ; 452default = if versionOlder stateVersion "23.05" then 453( isI3 && ( cfg . config . gaps == null )) 454else 455true ; 456defaultText = if isI3 then '' 457true for state version ≥ 23.05 458config.gaps == null for state version < 23.05 459'' else '' 460true for state version ≥ 23.05 461false for state version < 23.05 462'' ; 463description = "Whether to show floating window titlebars." ; 464}; 465 466border = mkOption { 467type = types . int ; 468default = 2 ; 469description = "Floating windows border width." ; 470}; 471 472modifier = mkOption { 473type = types . str ; 474default = cfg . config . modifier ; 475defaultText = " ${ moduleName } .config.modifier" ; 476description = 477"Modifier key or keys that can be used to drag floating windows." ; 478example = "Mod4" ; 479}; 480 481criteria = mkOption { 482type = types . listOf criteriaModule ; 483default = [ ]; 484description = 485"List of criteria for windows that should be opened in a floating mode." ; 486example = [ 487{ "title" = "Steam - Update News" ; } 488{ "class" = "Pavucontrol" ; } 489]; 490}; 491}; 492}; 493default = { }; 494description = "Floating window settings." ; 495}; 496 497focus = mkOption { 498type = types . submodule { 499options = { 500newWindow = mkOption { 501type = types . enum [ "smart" "urgent" "focus" "none" ]; 502default = "smart" ; 503description = '' 504This option modifies focus behavior on new window activation. 505 506See <https://i3wm.org/docs/userguide.html#focus_on_window_activation> 507'' ; 508example = "none" ; 509}; 510 511followMouse = mkOption { 512type = if isSway then 513types . either ( types . enum [ "yes" "no" "always" ]) types . bool 514else 515types . bool ; 516default = if isSway then "yes" else true ; 517description = "Whether focus should follow the mouse." ; 518apply = val : 519if ( isSway && isBool val ) then ( lib . hm . booleans . yesNo val ) else val ; 520}; 521 522wrapping = mkOption { 523type = types . enum [ "yes" "no" "force" "workspace" ]; 524default = { 525i3 = if cfg . config . focus . forceWrapping then "force" else "yes" ; 526# the sway module's logic was inverted and incorrect, 527# so preserve it for backwards compatibility purposes 528sway = if cfg . config . focus . forceWrapping then "yes" else "no" ; 529}.${ moduleName }; 530description = '' 531Whether the window focus commands automatically wrap around the edge of containers. 532 533See <https://i3wm.org/docs/userguide.html#_focus_wrapping> 534'' ; 535}; 536 537forceWrapping = mkOption { 538type = types . bool ; 539default = false ; 540description = '' 541Whether to force focus wrapping in tabbed or stacked containers. 542 543This option is deprecated, use {option}`focus.wrapping` instead. 544'' ; 545}; 546 547mouseWarping = mkOption { 548type = if isSway then 549types . oneOf [ types . bool ( types . enum [ "container" "output" ]) ] 550else 551types . bool ; 552default = true ; 553description = '' 554Whether mouse cursor should be warped to the center of the window when switching focus 555to a window on a different output. 556'' ; 557}; 558}; 559}; 560default = { }; 561description = "Focus related settings." ; 562}; 563 564assigns = mkOption { 565type = types . attrsOf ( types . listOf criteriaModule ); 566default = { }; 567description = '' 568An attribute set that assigns applications to workspaces based 569on criteria. 570'' ; 571example = literalExpression '' 572{ 573"1: web" = [{ class = "^Firefox$"; }]; 574"0: extra" = [{ class = "^Firefox$"; window_role = "About"; }]; 575} 576'' ; 577}; 578 579modifier = mkOption { 580type = types . enum [ "Shift" "Control" "Mod1" "Mod2" "Mod3" "Mod4" "Mod5" ]; 581default = "Mod1" ; 582description = "Modifier key that is used for all default keybindings." ; 583example = "Mod4" ; 584}; 585 586workspaceLayout = mkOption { 587type = types . enum [ "default" "stacking" "tabbed" ]; 588default = "default" ; 589example = "tabbed" ; 590description = '' 591The mode in which new containers on workspace level will 592start. 593'' ; 594}; 595 596workspaceAutoBackAndForth = mkOption { 597type = types . bool ; 598default = false ; 599example = true ; 600description = '' 601Assume you are on workspace "1: www" and switch to "2: IM" using 602mod+2 because somebody sent you a message. You don’t need to remember 603where you came from now, you can just press $mod+2 again to switch 604back to "1: www". 605'' ; 606}; 607 608keycodebindings = mkOption { 609type = types . attrsOf ( types . nullOr types . str ); 610default = { }; 611description = '' 612An attribute set that assigns keypress to an action using key code. 613See <https://i3wm.org/docs/userguide.html#keybindings>. 614'' ; 615example = { "214" = "exec /bin/script.sh" ; }; 616}; 617 618colors = mkOption { 619type = types . submodule { 620options = { 621background = mkOption { 622type = types . str ; 623default = "#ffffff" ; 624description = '' 625Background color of the window. Only applications which do not cover 626the whole area expose the color. 627'' ; 628}; 629 630focused = mkOption { 631type = colorSetModule ; 632default = { 633border = "#4c7899" ; 634background = "#285577" ; 635text = "#ffffff" ; 636indicator = "#2e9ef4" ; 637childBorder = "#285577" ; 638}; 639description = "A window which currently has the focus." ; 640}; 641 642focusedInactive = mkOption { 643type = colorSetModule ; 644default = { 645border = "#333333" ; 646background = "#5f676a" ; 647text = "#ffffff" ; 648indicator = "#484e50" ; 649childBorder = "#5f676a" ; 650}; 651description = '' 652A window which is the focused one of its container, 653but it does not have the focus at the moment. 654'' ; 655}; 656 657unfocused = mkOption { 658type = colorSetModule ; 659default = { 660border = "#333333" ; 661background = "#222222" ; 662text = "#888888" ; 663indicator = "#292d2e" ; 664childBorder = "#222222" ; 665}; 666description = "A window which is not focused." ; 667}; 668 669urgent = mkOption { 670type = colorSetModule ; 671default = { 672border = "#2f343a" ; 673background = "#900000" ; 674text = "#ffffff" ; 675indicator = "#900000" ; 676childBorder = "#900000" ; 677}; 678description = "A window which has its urgency hint activated." ; 679}; 680 681placeholder = mkOption { 682type = colorSetModule ; 683default = { 684border = "#000000" ; 685background = "#0c0c0c" ; 686text = "#ffffff" ; 687indicator = "#000000" ; 688childBorder = "#0c0c0c" ; 689}; 690description = '' 691Background and text color are used to draw placeholder window 692contents (when restoring layouts). Border and indicator are ignored. 693'' ; 694}; 695}; 696}; 697default = { }; 698description = '' 699Color settings. All color classes can be specified using submodules 700with 'border', 'background', 'text', 'indicator' and 'childBorder' fields 701and RGB color hex-codes as values. See default values for the reference. 702Note that ' ${ moduleName } .config.colors.background' parameter takes a single RGB value. 703 704See <https://i3wm.org/docs/userguide.html#_changing_colors>. 705'' ; 706}; 707 708bars = mkOption { 709type = types . listOf barModule ; 710default = if versionAtLeast stateVersion "20.09" then [{ 711mode = "dock" ; 712hiddenState = "hide" ; 713position = "bottom" ; 714workspaceButtons = true ; 715workspaceNumbers = true ; 716statusCommand = " ${ pkgs . i3status } /bin/i3status" ; 717fonts = { 718names = [ "monospace" ]; 719size = 8.0 ; 720}; 721trayOutput = "primary" ; 722colors = { 723background = "#000000" ; 724statusline = "#ffffff" ; 725separator = "#666666" ; 726focusedWorkspace = { 727border = "#4c7899" ; 728background = "#285577" ; 729text = "#ffffff" ; 730}; 731activeWorkspace = { 732border = "#333333" ; 733background = "#5f676a" ; 734text = "#ffffff" ; 735}; 736inactiveWorkspace = { 737border = "#333333" ; 738background = "#222222" ; 739text = "#888888" ; 740}; 741urgentWorkspace = { 742border = "#2f343a" ; 743background = "#900000" ; 744text = "#ffffff" ; 745}; 746bindingMode = { 747border = "#2f343a" ; 748background = "#900000" ; 749text = "#ffffff" ; 750}; 751}; 752}] else 753[ { } ]; 754defaultText = literalExpression "see code" ; 755description = '' 756${ capitalModuleName } bars settings blocks. Set to empty list to remove bars completely. 757'' ; 758}; 759 760startup = mkOption { 761type = types . listOf startupModule ; 762default = [ ]; 763description = '' 764Commands that should be executed at startup. 765 766See <https://i3wm.org/docs/userguide.html#_automatically_starting_applications_on_i3_startup>. 767'' ; 768example = if isI3 then 769literalExpression '' 770[ 771{ command = "systemctl --user restart polybar"; always = true; notification = false; } 772{ command = "dropbox start"; notification = false; } 773{ command = "firefox"; } 774]; 775'' 776else 777literalExpression '' 778[ 779{ command = "systemctl --user restart waybar"; always = true; } 780{ command = "dropbox start"; } 781{ command = "firefox"; } 782] 783'' ; 784}; 785 786gaps = mkOption { 787type = types . nullOr ( types . submodule { 788options = { 789inner = mkOption { 790type = types . nullOr types . int ; 791default = null ; 792description = "Inner gaps value." ; 793example = 12 ; 794}; 795 796outer = mkOption { 797type = types . nullOr types . int ; 798default = null ; 799description = "Outer gaps value." ; 800example = 5 ; 801}; 802 803horizontal = mkOption { 804type = types . nullOr types . int ; 805default = null ; 806description = "Horizontal gaps value." ; 807example = 5 ; 808}; 809 810vertical = mkOption { 811type = types . nullOr types . int ; 812default = null ; 813description = "Vertical gaps value." ; 814example = 5 ; 815}; 816 817top = mkOption { 818type = types . nullOr types . int ; 819default = null ; 820description = "Top gaps value." ; 821example = 5 ; 822}; 823 824left = mkOption { 825type = types . nullOr types . int ; 826default = null ; 827description = "Left gaps value." ; 828example = 5 ; 829}; 830 831bottom = mkOption { 832type = types . nullOr types . int ; 833default = null ; 834description = "Bottom gaps value." ; 835example = 5 ; 836}; 837 838right = mkOption { 839type = types . nullOr types . int ; 840default = null ; 841description = "Right gaps value." ; 842example = 5 ; 843}; 844 845smartGaps = mkOption { 846type = types . bool ; 847default = false ; 848description = '' 849This option controls whether to disable all gaps (outer and inner) 850on workspace with a single container. 851'' ; 852example = true ; 853}; 854 855smartBorders = mkOption { 856type = types . enum [ "on" "off" "no_gaps" ]; 857default = "off" ; 858description = '' 859This option controls whether to disable container borders on 860workspace with a single container. 861'' ; 862}; 863}; 864}); 865default = null ; 866description = '' 867Gaps related settings. 868'' ; 869}; 870 871terminal = mkOption { 872type = types . str ; 873default = if isI3 then "i3-sensible-terminal" else " ${ pkgs . foot } /bin/foot" ; 874description = "Default terminal to run." ; 875example = "alacritty" ; 876}; 877 878menu = mkOption { 879type = types . str ; 880default = if isSway then 881" ${ pkgs . dmenu } /bin/dmenu_path | ${ pkgs . dmenu } /bin/dmenu | ${ pkgs . findutils } /bin/xargs swaymsg exec --" 882else 883" ${ pkgs . dmenu } /bin/dmenu_run" ; 884description = "Default launcher to use." ; 885example = "bemenu-run" ; 886}; 887 888defaultWorkspace = mkOption { 889type = types . nullOr types . str ; 890default = null ; 891description = '' 892The default workspace to show when ${ 893if isSway then "sway" else "i3" 894} is launched. 895This must to correspond to the value of the keybinding of the default workspace. 896'' ; 897example = "workspace number 9" ; 898}; 899 900workspaceOutputAssign = mkOption { 901type = with types ; 902let 903workspaceOutputOpts = submodule { 904options = { 905workspace = mkOption { 906type = str ; 907default = "" ; 908example = "Web" ; 909description = '' 910Name of the workspace to assign. 911'' ; 912}; 913 914output = mkOption { 915type = with types ; either str ( listOf str ); 916default = "" ; 917apply = lists . toList ; 918example = "eDP" ; 919description = '' 920Name(s) of the output(s) from {command}` 921${ if isSway then "swaymsg" else "i3-msg" } -t get_outputs 922`. 923'' ; 924}; 925}; 926}; 927in listOf workspaceOutputOpts ; 928default = [ ]; 929description = "Assign workspaces to outputs." ; 930}; 931}