From 177565567e793e5483290dbb5b9487c3ce15ca60 Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Fri, 17 Nov 2017 12:22:59 +0100 Subject: [PATCH 1/8] i3: extend module New options: i3.config.keycodebindings i3.config.window.commands i3.config.window.hideEdgeBorders i3.config.focus.mouseWarping --- modules/misc/news.nix | 12 +++++ modules/services/window-managers/i3.nix | 65 +++++++++++++++++++++++-- 2 files changed, 74 insertions(+), 3 deletions(-) diff --git a/modules/misc/news.nix b/modules/misc/news.nix index dff74cc5..d32b1e24 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -462,6 +462,18 @@ in where --no-startup-id option is necessary. ''; } + { + time = "2017-11-17T10:36:10+00:00"; + condition = config.xsession.windowManager.i3.enable; + message = '' + The i3 window manager module has been extended with the following options: + + i3.config.keycodebindings + i3.config.window.commands + i3.config.window.hideEdgeBorders + i3.config.focus.mouseWarping + ''; + } ]; }; } diff --git a/modules/services/window-managers/i3.nix b/modules/services/window-managers/i3.nix index 51e0c06a..af6a8b1f 100644 --- a/modules/services/window-managers/i3.nix +++ b/modules/services/window-managers/i3.nix @@ -101,6 +101,22 @@ let }; }; + windowCommandModule = types.submodule { + options = { + command = mkOption { + type = types.string; + description = "i3wm command to execute."; + example = "border pixel 1"; + }; + + criteria = mkOption { + type = criteriaModule; + description = "Criteria of the windows on which command should be executed."; + example = { title = "x200: ~/work"; }; + }; + }; + }; + criteriaModule = types.attrs; configModule = types.submodule { @@ -130,6 +146,22 @@ let default = 2; description = "Window border width."; }; + + hideEdgeBorders = mkOption { + type = types.enum [ "none" "vertical" "horizontal" "both" "smart" ]; + default = "none"; + description = "Hide window borders adjacent to the screen edges."; + }; + + commands = mkOption { + type = types.listOf windowCommandModule; + default = []; + description = '' + List of commands that should be executed on specific windows. + See i3wm option documentation. + ''; + example = [ { command = "border pixel 1"; criteria = { class = "XTerm"; }; } ]; + }; }; }; default = {}; @@ -200,6 +232,15 @@ let See ''; }; + + mouseWarping = mkOption { + type = types.bool; + default = true; + description = '' + Whether mouse cursor should be warped to the center of the window when switching focus + to a window on a different output. + ''; + }; }; }; default = {}; @@ -271,9 +312,8 @@ let }; defaultText = "Default i3 keybindings."; description = '' - An attribute set that assignes keypress to an action. - Only basic keybinding is supported (bindsym keycomb action), - for more advanced setup use 'i3.extraConfig'. + An attribute set that assignes key press to an action using key symbol. + See . ''; example = literalExample '' { @@ -284,6 +324,16 @@ let ''; }; + keycodebindings = mkOption { + type = types.attrs; + default = {}; + description = '' + An attribute set that assignes keypress to an action using key code. + See . + ''; + example = { "214" = "exec --no-startup-id /bin/script.sh"; }; + }; + colors = mkOption { type = types.submodule { options = { @@ -454,6 +504,10 @@ let mapAttrsToList (keycomb: action: "bindsym ${keycomb} ${action}") keybindings ); + keycodebindingsStr = keycodebindings: concatStringsSep "\n" ( + mapAttrsToList (keycomb: action: "bindcode ${keycomb} ${action}") keycodebindings + ); + colorSetStr = c: concatStringsSep " " [ c.border c.background c.text c.indicator c.childBorder ]; criteriaStr = criteria: "[${concatStringsSep " " (mapAttrsToList (k: v: ''${k}="${v}"'') criteria)}]"; @@ -486,6 +540,7 @@ let ''; floatingCriteriaStr = criteria: "for_window ${criteriaStr criteria} floating enable"; + windowCommandsStr = { command, criteria, ... }: "for_window ${criteriaStr criteria} ${command}"; startupEntryStr = { command, always, notification, workspace, ... }: '' ${if always then "exec_always" else "exec"} ${ @@ -503,9 +558,11 @@ let floating_modifier ${floating.modifier} new_window ${if window.titlebar then "normal" else "pixel"} ${toString window.border} new_float ${if floating.titlebar then "normal" else "pixel"} ${toString floating.border} + hide_edge_borders ${window.hideEdgeBorders} force_focus_wrapping ${if focus.forceWrapping then "yes" else "no"} focus_follows_mouse ${if focus.followMouse then "yes" else "no"} focus_on_window_activation ${focus.newWindow} + mouse_warping ${if focus.mouseWarping then "output" else "none"} client.focused ${colorSetStr colors.focused} client.focused_inactive ${colorSetStr colors.focusedInactive} @@ -515,11 +572,13 @@ let client.background ${colors.background} ${keybindingsStr keybindings} + ${keycodebindingsStr keycodebindings} ${concatStringsSep "\n" (mapAttrsToList modeStr modes)} ${concatStringsSep "\n" (mapAttrsToList assignStr assigns)} ${concatStringsSep "\n" (map barStr bars)} ${optionalString (gaps != null) gapsStr} ${concatStringsSep "\n" (map floatingCriteriaStr floating.criteria)} + ${concatStringsSep "\n" (map windowCommandsStr window.commands)} ${concatStringsSep "\n" (map startupEntryStr startup)} '' else "") + "\n" + cfg.extraConfig); From 64befb27ebe59aab9d117b65b3243700a8a5fe71 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 20 Nov 2017 13:58:04 +0100 Subject: [PATCH 2/8] news: minor formatting fix --- modules/misc/news.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/misc/news.nix b/modules/misc/news.nix index d32b1e24..b61f72cd 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -442,12 +442,14 @@ in December 6, 2017. ''; } + { time = "2017-11-12T00:18:59+00:00"; message = '' A new program module is available: 'programs.neovim'. ''; } + { time = "2017-11-14T19:56:49+00:00"; condition = with config.xsession.windowManager; ( @@ -462,6 +464,7 @@ in where --no-startup-id option is necessary. ''; } + { time = "2017-11-17T10:36:10+00:00"; condition = config.xsession.windowManager.i3.enable; From 455ce37398f8c2d16458c443cbcd4f2ed8616a6f Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 20 Nov 2017 14:02:28 +0100 Subject: [PATCH 3/8] home-manager: avoid unnecessary copy --- default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/default.nix b/default.nix index b9eedd47..519c6650 100644 --- a/default.nix +++ b/default.nix @@ -3,7 +3,7 @@ rec { home-manager = import ./home-manager { inherit pkgs; - path = ./.; + path = toString ./.; }; install = From 3c875267afdac6348e5e7177df10364db8bb5edd Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Mon, 20 Nov 2017 21:15:51 +0100 Subject: [PATCH 4/8] i3: config.modes.resize: add Return to defaults --- modules/services/window-managers/i3.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/services/window-managers/i3.nix b/modules/services/window-managers/i3.nix index af6a8b1f..96842788 100644 --- a/modules/services/window-managers/i3.nix +++ b/modules/services/window-managers/i3.nix @@ -418,6 +418,7 @@ let "Up" = "resize shrink height 10 px or 10 ppt"; "Right" = "resize grow width 10 px or 10 ppt"; "Escape" = "mode default"; + "Return" = "mode default"; }; }; description = '' From 592fd61788e4508b63b58f32e2f090e59e646fb0 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Fri, 24 Nov 2017 13:51:21 +0100 Subject: [PATCH 5/8] module/home-manager: remove `modulesPath` option This option has been deprecated for a month and is removed according to the news entry. --- modules/misc/news.nix | 10 ---------- modules/programs/home-manager.nix | 31 +------------------------------ 2 files changed, 1 insertion(+), 40 deletions(-) diff --git a/modules/misc/news.nix b/modules/misc/news.nix index b61f72cd..b27882ec 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -342,16 +342,6 @@ in ''; } - { - time = "2017-10-23T22:54:33+00:00"; - condition = config.programs.home-manager.modulesPath != null; - message = '' - The 'programs.home-manager.modulesPath' option is now - deprecated and will be removed on November 24, 2017. Please - use the option 'programs.home-manager.path' instead. - ''; - } - { time = "2017-10-23T23:10:29+00:00"; condition = !config.programs.home-manager.enable; diff --git a/modules/programs/home-manager.nix b/modules/programs/home-manager.nix index 724a19ae..b27be1db 100644 --- a/modules/programs/home-manager.nix +++ b/modules/programs/home-manager.nix @@ -28,43 +28,14 @@ in attempted. ''; }; - - modulesPath = mkOption { - type = types.nullOr types.str; - default = null; - example = "$HOME/devel/home-manager/modules"; - description = '' - The default path to use for Home Manager modules. If this - path does not exist then - $HOME/.config/nixpkgs/home-manager/modules - and $HOME/.nixpkgs/home-manager/modules - will be attempted. DEPRECATED: Use - programs.home-manager.path instead. - ''; - }; }; }; config = mkIf cfg.enable { - warnings = mkIf (cfg.modulesPath != null) [ - ("'programs.home-manager.modulesPath' is deprecated, " - + "please use 'programs.home-manager.path") - ]; - - assertions = [{ - assertion = cfg.path == null || cfg.modulesPath == null; - message = "Cannot simultaneously use " - + "'programs.home-manager.path' and " - + "'programs.home-manager.modulesPath'."; - }]; - home.packages = [ (import ../../home-manager { inherit pkgs; - path = - if cfg.modulesPath != null - then "$(dirname ${cfg.modulesPath})" - else cfg.path; + inherit (cfg) path; }) ]; From bcb82da88f9f5e80dbeb14f6d9a6b58e01212f8e Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Wed, 8 Nov 2017 01:17:46 +0100 Subject: [PATCH 6/8] gtk: improve theme and font configuration Specifically, allow the user to specify the package that provides the theme or font. Fixes #1. --- modules/misc/gtk.nix | 99 ++++++++++++++++++++++++++++++++++++------- modules/misc/news.nix | 27 ++++++++++++ 2 files changed, 110 insertions(+), 16 deletions(-) diff --git a/modules/misc/gtk.nix b/modules/misc/gtk.nix index f0fc8b1a..db374c35 100644 --- a/modules/misc/gtk.nix +++ b/modules/misc/gtk.nix @@ -27,6 +27,50 @@ let in "${n} = ${v'}"; + fontType = types.submodule { + options = { + package = mkOption { + type = types.nullOr types.package; + default = null; + example = literalExample "pkgs.dejavu_fonts"; + description = '' + Package providing the font. This package will be installed + to your profile. If null then the font + is assumed to already be available in your profile. + ''; + }; + + name = mkOption { + type = types.str; + example = "DejaVu Sans 8"; + description = '' + The family name and size of the font within the package. + ''; + }; + }; + }; + + themeType = types.submodule { + options = { + package = mkOption { + type = types.nullOr types.package; + default = null; + example = literalExample "pkgs.gnome3.gnome_themes_standard"; + description = '' + Package providing the theme. This package will be installed + to your profile. If null then the theme + is assumed to already be available in your profile. + ''; + }; + + name = mkOption { + type = types.str; + example = "Adwaita"; + description = "The name of the theme within the package."; + }; + }; + }; + in { @@ -36,27 +80,24 @@ in gtk = { enable = mkEnableOption "GTK 2/3 configuration"; - fontName = mkOption { - type = types.nullOr types.str; + font = mkOption { + type = types.nullOr fontType; default = null; - example = "DejaVu Sans 8"; description = '' The font to use in GTK+ 2/3 applications. ''; }; - themeName = mkOption { - type = types.nullOr types.str; + iconTheme = mkOption { + type = types.nullOr themeType; default = null; - example = "Vertex-Dark"; - description = "The name of the GTK+2/3 theme to use."; + description = "The icon theme to use."; }; - iconThemeName = mkOption { - type = types.nullOr types.str; + theme = mkOption { + type = types.nullOr themeType; default = null; - example = "Tango"; - description = "The name of the icon theme to use."; + description = "The GTK+2/3 theme to use."; }; gtk2 = mkOption { @@ -110,15 +151,24 @@ in let ini = optionalAttrs (cfg.fontName != null) - { gtk-font-name = cfg.fontName; } + { gtk-font-name = cfg.font.name; } // - optionalAttrs (cfg.themeName != null) - { gtk-theme-name = cfg.themeName; } + optionalAttrs (cfg.theme != null) + { gtk-theme-name = cfg.theme.name; } // - optionalAttrs (cfg.iconThemeName != null) - { gtk-icon-theme-name = cfg.iconThemeName; }; + optionalAttrs (cfg.iconTheme != null) + { gtk-icon-theme-name = cfg.iconTheme.name; }; + + optionalPackage = opt: + optional (opt != null && opt.package != null) opt.package; in { + + home.packages = + optionalPackage cfg.font + ++ optionalPackage cfg.theme + ++ optionalPackage cfg.iconTheme; + home.file.".gtkrc-2.0".text = concatStringsSep "\n" ( mapAttrsToList formatGtk2Option ini @@ -130,4 +180,21 @@ in xdg.configFile."gtk-3.0/gtk.css".text = cfg3.extraCss; } ); + + imports = + let + name = n: [ "gtk" n ]; + in [ + (mkChangedOptionModule (name "fontName") (name "font") ( + config: { name = getAttrFromPath (name "fontName") config; } + )) + + (mkChangedOptionModule (name "themeName") (name "theme") ( + config: { name = getAttrFromPath (name "themeName") config; } + )) + + (mkChangedOptionModule (name "iconThemeName") (name "iconTheme") ( + config: { name = getAttrFromPath (name "iconThemeName") config; } + )) + ]; } diff --git a/modules/misc/news.nix b/modules/misc/news.nix index b27882ec..656e95e5 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -467,6 +467,33 @@ in i3.config.focus.mouseWarping ''; } + + { + time = "2017-11-23T00:31:12+00:00"; + condition = + config.gtk.fontName != "_mkMergedOptionModule" + || config.gtk.themeName != "_mkMergedOptionModule" + || config.gtk.iconThemeName != "_mkMergedOptionModule"; + message = '' + The options + + gtk.fontName, gtk.themeName, and gtk.iconThemeName + + are deprecated and will be removed on December 23, 2017. + + Please use + + gtk.font.name, gtk.theme.name, and gtk.iconTheme.name + + instead. You can find information about these in the manual + page. + + This change was made to introduce the options + 'gtk.font.package', 'gtk.theme.package', and + 'gtk.iconTheme.package', which allow you to specify the + package that provides the font or theme. + ''; + } ]; }; } From e99de88c5c536346e809269d3b5b48823db123d9 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Fri, 24 Nov 2017 21:58:16 +0100 Subject: [PATCH 7/8] modules core: move modules list to own file This is to simplify use of Home Manager as a NixOS module. --- modules/default.nix | 69 ++------------------------------------- modules/modules.nix | 79 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+), 66 deletions(-) create mode 100644 modules/modules.nix diff --git a/modules/default.nix b/modules/default.nix index 7c67887c..4d0e9cc7 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -10,64 +10,6 @@ with lib; let - modules = [ - ./files.nix - ./home-environment.nix - ./manual.nix - ./misc/fontconfig.nix - ./misc/gtk.nix - ./misc/news.nix - ./misc/nixpkgs.nix - ./misc/pam.nix - ./misc/xdg.nix - ./programs/bash.nix - ./programs/beets.nix - ./programs/browserpass.nix - ./programs/command-not-found/command-not-found.nix - ./programs/eclipse.nix - ./programs/emacs.nix - ./programs/feh.nix - ./programs/firefox.nix - ./programs/git.nix - ./programs/gnome-terminal.nix - ./programs/home-manager.nix - ./programs/htop.nix - ./programs/info.nix - ./programs/lesspipe.nix - ./programs/man.nix - ./programs/neovim.nix - ./programs/rofi.nix - ./programs/ssh.nix - ./programs/termite.nix - ./programs/texlive.nix - ./programs/vim.nix - ./programs/zsh.nix - ./services/blueman-applet.nix - ./services/compton.nix - ./services/dunst.nix - ./services/gnome-keyring.nix - ./services/gpg-agent.nix - ./services/keepassx.nix - ./services/network-manager-applet.nix - ./services/owncloud-client.nix - ./services/polybar.nix - ./services/random-background.nix - ./services/redshift.nix - ./services/screen-locker.nix - ./services/syncthing.nix - ./services/taffybar.nix - ./services/tahoe-lafs.nix - ./services/udiskie.nix - ./services/window-managers/i3.nix - ./services/window-managers/xmonad.nix - ./services/xscreensaver.nix - ./systemd.nix - ./xresources.nix - ./xsession.nix - - - ]; - collectFailed = cfg: map (x: x.message) (filter (x: !x.assertion) cfg.assertions); @@ -77,15 +19,10 @@ let in fold f res res.config.warnings; - pkgsModule = { - config._module.args.baseModules = modules; - config._module.args.pkgs = lib.mkDefault pkgs; - config._module.check = check; - config.nixpkgs.system = mkDefault pkgs.system; - }; - rawModule = lib.evalModules { - modules = [ configuration ] ++ modules ++ [ pkgsModule ]; + modules = + [ configuration ] + ++ (import ./modules.nix { inherit check lib pkgs; }); }; module = showWarnings ( diff --git a/modules/modules.nix b/modules/modules.nix new file mode 100644 index 00000000..4c1e1a1a --- /dev/null +++ b/modules/modules.nix @@ -0,0 +1,79 @@ +{ pkgs +, lib + + # Whether to enable module type checking. +, check ? true +}: + +with lib; + +let + + modules = [ + ./files.nix + ./home-environment.nix + ./manual.nix + ./misc/fontconfig.nix + ./misc/gtk.nix + ./misc/news.nix + ./misc/nixpkgs.nix + ./misc/pam.nix + ./misc/xdg.nix + ./programs/bash.nix + ./programs/beets.nix + ./programs/browserpass.nix + ./programs/command-not-found/command-not-found.nix + ./programs/eclipse.nix + ./programs/emacs.nix + ./programs/feh.nix + ./programs/firefox.nix + ./programs/git.nix + ./programs/gnome-terminal.nix + ./programs/home-manager.nix + ./programs/htop.nix + ./programs/info.nix + ./programs/lesspipe.nix + ./programs/man.nix + ./programs/neovim.nix + ./programs/rofi.nix + ./programs/ssh.nix + ./programs/termite.nix + ./programs/texlive.nix + ./programs/vim.nix + ./programs/zsh.nix + ./services/blueman-applet.nix + ./services/compton.nix + ./services/dunst.nix + ./services/gnome-keyring.nix + ./services/gpg-agent.nix + ./services/keepassx.nix + ./services/network-manager-applet.nix + ./services/owncloud-client.nix + ./services/polybar.nix + ./services/random-background.nix + ./services/redshift.nix + ./services/screen-locker.nix + ./services/syncthing.nix + ./services/taffybar.nix + ./services/tahoe-lafs.nix + ./services/udiskie.nix + ./services/window-managers/i3.nix + ./services/window-managers/xmonad.nix + ./services/xscreensaver.nix + ./systemd.nix + ./xresources.nix + ./xsession.nix + + + ]; + + pkgsModule = { + config._module.args.baseModules = modules; + config._module.args.pkgs = lib.mkDefault pkgs; + config._module.check = check; + config.nixpkgs.system = mkDefault pkgs.system; + }; + +in + + map import modules ++ [ pkgsModule ] From 7876d533cf36f5378d7cdcbbfae29f497193d199 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Fri, 24 Nov 2017 22:25:36 +0100 Subject: [PATCH 8/8] gtk: fix erroneous variable reference --- modules/misc/gtk.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/misc/gtk.nix b/modules/misc/gtk.nix index db374c35..d6fedfe4 100644 --- a/modules/misc/gtk.nix +++ b/modules/misc/gtk.nix @@ -150,7 +150,7 @@ in config = mkIf cfg.enable ( let ini = - optionalAttrs (cfg.fontName != null) + optionalAttrs (cfg.font != null) { gtk-font-name = cfg.font.name; } // optionalAttrs (cfg.theme != null)