diff options
author | Katharina Fey <kookie@spacekookie.de> | 2020-02-03 10:05:30 +0100 |
---|---|---|
committer | Katharina Fey <kookie@spacekookie.de> | 2020-02-03 10:05:30 +0100 |
commit | c488527c95c874d3b8743c915173ad7bfb05d5af (patch) | |
tree | 2b874dc5606a9dff44096a5e8557f00dc52ac2b6 /home-manager/modules/services | |
parent | 899a451e08f7d6d2c8214d119c2a0316849a0ed4 (diff) | |
parent | 6cc4fd6ede4909226cb81d3475834251ed1b7210 (diff) |
Merge commit '6cc4fd6ede4909226cb81d3475834251ed1b7210'
Diffstat (limited to 'home-manager/modules/services')
50 files changed, 1472 insertions, 844 deletions
diff --git a/home-manager/modules/services/blueman-applet.nix b/home-manager/modules/services/blueman-applet.nix index 186dc7454f9..5a57acccc27 100644 --- a/home-manager/modules/services/blueman-applet.nix +++ b/home-manager/modules/services/blueman-applet.nix @@ -5,33 +5,32 @@ with lib; { options = { services.blueman-applet = { - enable = mkEnableOption '' - Blueman applet. - - Note, for the applet to work, 'blueman' package should also be installed system-wide - since it requires running 'blueman-mechanism' service activated via dbus. - You can add it to the dbus packages in system configuration: - - services.dbus.packages = [ pkgs.blueman ]; - ''; + enable = mkEnableOption "" // { + description = '' + Whether to enable the Blueman applet. + </para><para> + Note, for the applet to work, the 'blueman' service should + be enabled system-wide. You can enable it in the system + configuration using + <programlisting language="nix"> + services.blueman.enable = true; + </programlisting> + ''; + }; }; }; config = mkIf config.services.blueman-applet.enable { systemd.user.services.blueman-applet = { - Unit = { - Description = "Blueman applet"; - After = [ "graphical-session-pre.target" ]; - PartOf = [ "graphical-session.target" ]; - }; + Unit = { + Description = "Blueman applet"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; - Install = { - WantedBy = [ "graphical-session.target" ]; - }; + Install = { WantedBy = [ "graphical-session.target" ]; }; - Service = { - ExecStart = "${pkgs.blueman}/bin/blueman-applet"; - }; + Service = { ExecStart = "${pkgs.blueman}/bin/blueman-applet"; }; }; }; } diff --git a/home-manager/modules/services/cbatticon.nix b/home-manager/modules/services/cbatticon.nix new file mode 100644 index 00000000000..0de69c5f9ec --- /dev/null +++ b/home-manager/modules/services/cbatticon.nix @@ -0,0 +1,118 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.services.cbatticon; + + package = pkgs.cbatticon; + + makeCommand = commandName: commandArg: + optional (commandArg != null) + (let cmd = pkgs.writeShellScript commandName commandArg; + in "--${commandName} ${cmd}"); + + commandLine = concatStringsSep " " ([ "${package}/bin/cbatticon" ] + ++ makeCommand "command-critical-level" cfg.commandCriticalLevel + ++ makeCommand "command-left-click" cfg.commandLeftClick + ++ optional (cfg.iconType != null) "--icon-type ${cfg.iconType}" + ++ optional (cfg.lowLevelPercent != null) + "--low-level ${toString cfg.lowLevelPercent}" + ++ optional (cfg.criticalLevelPercent != null) + "--critical-level ${toString cfg.criticalLevelPercent}" + ++ optional (cfg.updateIntervalSeconds != null) + "--update-interval ${toString cfg.updateIntervalSeconds}" + ++ optional (cfg.hideNotification != null && cfg.hideNotification) + "--hide-notification"); + +in { + meta.maintainers = [ maintainers.pmiddend ]; + + options = { + services.cbatticon = { + enable = mkEnableOption "cbatticon"; + + commandCriticalLevel = mkOption { + type = types.nullOr types.lines; + default = null; + example = '' + notify-send "battery critical!" + ''; + description = '' + Command to execute when the critical battery level is reached. + ''; + }; + + commandLeftClick = mkOption { + type = types.nullOr types.lines; + default = null; + description = '' + Command to execute when left clicking on the tray icon. + ''; + }; + + iconType = mkOption { + type = + types.nullOr (types.enum [ "standard" "notification" "symbolic" ]); + default = null; + example = "symbolic"; + description = "Icon type to display in the system tray."; + }; + + lowLevelPercent = mkOption { + type = types.nullOr (types.ints.between 0 100); + default = null; + example = 20; + description = '' + Low level percentage of the battery in percent (without the + percent symbol). + ''; + }; + + criticalLevelPercent = mkOption { + type = types.nullOr (types.ints.between 0 100); + default = null; + example = 5; + description = '' + Critical level percentage of the battery in percent (without + the percent symbol). + ''; + }; + + updateIntervalSeconds = mkOption { + type = types.nullOr types.ints.positive; + default = null; + example = 5; + description = '' + Number of seconds between updates of the battery information. + ''; + }; + + hideNotification = mkOption { + type = types.nullOr types.bool; + default = null; + description = "Hide the notification popups."; + }; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ package ]; + + systemd.user.services.cbatticon = { + Unit = { + Description = "cbatticon system tray battery icon"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; + + Install = { WantedBy = [ "graphical-session.target" ]; }; + + Service = { + ExecStart = commandLine; + Restart = "on-abort"; + }; + }; + }; +} diff --git a/home-manager/modules/services/compton.nix b/home-manager/modules/services/compton.nix index c227f0a8c07..c5b96af34da 100644 --- a/home-manager/modules/services/compton.nix +++ b/home-manager/modules/services/compton.nix @@ -7,44 +7,41 @@ let cfg = config.services.compton; - configFile = pkgs.writeText "compton.conf" - (optionalString cfg.fade '' - # fading - fading = true; - fade-delta = ${toString cfg.fadeDelta}; - fade-in-step = ${elemAt cfg.fadeSteps 0}; - fade-out-step = ${elemAt cfg.fadeSteps 1}; - fade-exclude = ${toJSON cfg.fadeExclude}; - '' + - optionalString cfg.shadow '' - - # shadows - shadow = true; - shadow-offset-x = ${toString (elemAt cfg.shadowOffsets 0)}; - shadow-offset-y = ${toString (elemAt cfg.shadowOffsets 1)}; - shadow-opacity = ${cfg.shadowOpacity}; - shadow-exclude = ${toJSON cfg.shadowExclude}; - no-dock-shadow = ${toJSON cfg.noDockShadow}; - no-dnd-shadow = ${toJSON cfg.noDNDShadow}; - '' + - optionalString cfg.blur '' - - # blur - blur-background = true; - blur-background-exclude = ${toJSON cfg.blurExclude}; - '' + '' - - # opacity - active-opacity = ${cfg.activeOpacity}; - inactive-opacity = ${cfg.inactiveOpacity}; - menu-opacity = ${cfg.menuOpacity}; - opacity-rule = ${toJSON cfg.opacityRule}; - - # other options - backend = ${toJSON cfg.backend}; - vsync = ${toJSON cfg.vSync}; - refresh-rate = ${toString cfg.refreshRate}; - '' + cfg.extraOptions); + configFile = pkgs.writeText "compton.conf" (optionalString cfg.fade '' + # fading + fading = true; + fade-delta = ${toString cfg.fadeDelta}; + fade-in-step = ${elemAt cfg.fadeSteps 0}; + fade-out-step = ${elemAt cfg.fadeSteps 1}; + fade-exclude = ${toJSON cfg.fadeExclude}; + '' + optionalString cfg.shadow '' + + # shadows + shadow = true; + shadow-offset-x = ${toString (elemAt cfg.shadowOffsets 0)}; + shadow-offset-y = ${toString (elemAt cfg.shadowOffsets 1)}; + shadow-opacity = ${cfg.shadowOpacity}; + shadow-exclude = ${toJSON cfg.shadowExclude}; + no-dock-shadow = ${toJSON cfg.noDockShadow}; + no-dnd-shadow = ${toJSON cfg.noDNDShadow}; + '' + optionalString cfg.blur '' + + # blur + blur-background = true; + blur-background-exclude = ${toJSON cfg.blurExclude}; + '' + '' + + # opacity + active-opacity = ${cfg.activeOpacity}; + inactive-opacity = ${cfg.inactiveOpacity}; + menu-opacity = ${cfg.menuOpacity}; + opacity-rule = ${toJSON cfg.opacityRule}; + + # other options + backend = ${toJSON cfg.backend}; + vsync = ${toJSON cfg.vSync}; + refresh-rate = ${toString cfg.refreshRate}; + '' + cfg.extraOptions); in { @@ -61,11 +58,8 @@ in { blurExclude = mkOption { type = types.listOf types.str; - default = []; - example = [ - "class_g = 'slop'" - "class_i = 'polybar'" - ]; + default = [ ]; + example = [ "class_g = 'slop'" "class_i = 'polybar'" ]; description = '' List of windows to exclude background blur. See the @@ -105,12 +99,8 @@ in { fadeExclude = mkOption { type = types.listOf types.str; - default = []; - example = [ - "window_type *= 'menu'" - "name ~= 'Firefox$'" - "focused = 1" - ]; + default = [ ]; + example = [ "window_type *= 'menu'" "name ~= 'Firefox$'" "focused = 1" ]; description = '' List of conditions of windows that should not be faded. See the @@ -150,12 +140,8 @@ in { shadowExclude = mkOption { type = types.listOf types.str; - default = []; - example = [ - "window_type *= 'menu'" - "name ~= 'Firefox$'" - "focused = 1" - ]; + default = [ ]; + example = [ "window_type *= 'menu'" "name ~= 'Firefox$'" "focused = 1" ]; description = '' List of conditions of windows that should have no shadow. See the @@ -212,11 +198,8 @@ in { opacityRule = mkOption { type = types.listOf types.str; - default = []; - example = [ - "87:class_i ?= 'scratchpad'" - "91:class_i ?= 'xterm'" - ]; + default = [ ]; + example = [ "87:class_i ?= 'scratchpad'" "91:class_i ?= 'xterm'" ]; description = '' List of opacity rules. See the @@ -256,7 +239,7 @@ in { default = 0; example = 60; description = '' - Screen refresh rate (0 = automatically detect). + Screen refresh rate (0 = automatically detect). ''; }; @@ -293,16 +276,13 @@ in { PartOf = [ "graphical-session.target" ]; }; - Install = { - WantedBy = [ "graphical-session.target" ]; - }; + Install = { WantedBy = [ "graphical-session.target" ]; }; Service = { ExecStart = "${cfg.package}/bin/compton --config ${configFile}"; Restart = "always"; RestartSec = 3; - } - // optionalAttrs (cfg.backend == "glx") { + } // optionalAttrs (cfg.backend == "glx") { # Temporarily fixes corrupt colours with Mesa 18. Environment = [ "allow_rgb10_configs=false" ]; }; diff --git a/home-manager/modules/services/dunst.nix b/home-manager/modules/services/dunst.nix index 96b1f71a2fa..d32e875137b 100644 --- a/home-manager/modules/services/dunst.nix +++ b/home-manager/modules/services/dunst.nix @@ -6,17 +6,19 @@ let cfg = config.services.dunst; - eitherStrBoolIntList = with types; either str (either bool (either int (listOf str))); + eitherStrBoolIntList = with types; + either str (either bool (either int (listOf str))); toDunstIni = generators.toINI { mkKeyValue = key: value: - let - value' = - if isBool value then (if value then "yes" else "no") - else if isString value then "\"${value}\"" - else toString value; - in - "${key}=${value'}"; + let + value' = if isBool value then + (if value then "yes" else "no") + else if isString value then + ''"${value}"'' + else + toString value; + in "${key}=${value'}"; }; themeType = types.submodule { @@ -48,9 +50,7 @@ let size = "32x32"; }; -in - -{ +in { meta.maintainers = [ maintainers.rycee ]; options = { @@ -65,7 +65,7 @@ in settings = mkOption { type = with types; attrsOf (attrsOf eitherStrBoolIntList); - default = {}; + default = { }; description = "Configuration written to ~/.config/dunstrc"; example = literalExample '' { @@ -87,86 +87,73 @@ in }; }; - config = mkIf cfg.enable ( - mkMerge [ - { - xdg.dataFile."dbus-1/services/org.knopwob.dunst.service".source = - "${pkgs.dunst}/share/dbus-1/services/org.knopwob.dunst.service"; - - services.dunst.settings.global.icon_path = - let - useCustomTheme = - cfg.iconTheme.package != hicolorTheme.package - || cfg.iconTheme.name != hicolorTheme.name - || cfg.iconTheme.size != hicolorTheme.size; - - basePaths = [ - "/run/current-system/sw" - config.home.profileDirectory - cfg.iconTheme.package - ] ++ optional useCustomTheme hicolorTheme.package; - - themes = - [ - cfg.iconTheme - ] ++ optional useCustomTheme ( - hicolorTheme // { size = cfg.iconTheme.size; } - ); - - categories = [ - "actions" - "animations" - "apps" - "categories" - "devices" - "emblems" - "emotes" - "filesystem" - "intl" - "mimetypes" - "places" - "status" - "stock" - ]; - in - concatStringsSep ":" ( - concatMap (theme: - concatMap (basePath: - map (category: - "${basePath}/share/icons/${theme.name}/${theme.size}/${category}" - ) categories - ) basePaths - ) themes - ); - - systemd.user.services.dunst = { - Unit = { - Description = "Dunst notification daemon"; - After = [ "graphical-session-pre.target" ]; - PartOf = [ "graphical-session.target" ]; - }; - - Service = { - Type = "dbus"; - BusName = "org.freedesktop.Notifications"; - ExecStart = "${pkgs.dunst}/bin/dunst"; - }; + config = mkIf cfg.enable (mkMerge [ + { + xdg.dataFile."dbus-1/services/org.knopwob.dunst.service".source = + "${pkgs.dunst}/share/dbus-1/services/org.knopwob.dunst.service"; + + services.dunst.settings.global.icon_path = let + useCustomTheme = cfg.iconTheme.package != hicolorTheme.package + || cfg.iconTheme.name != hicolorTheme.name || cfg.iconTheme.size + != hicolorTheme.size; + + basePaths = [ + "/run/current-system/sw" + config.home.profileDirectory + cfg.iconTheme.package + ] ++ optional useCustomTheme hicolorTheme.package; + + themes = [ cfg.iconTheme ] ++ optional useCustomTheme + (hicolorTheme // { size = cfg.iconTheme.size; }); + + categories = [ + "actions" + "animations" + "apps" + "categories" + "devices" + "emblems" + "emotes" + "filesystem" + "intl" + "mimetypes" + "places" + "status" + "stock" + ]; + in concatStringsSep ":" (concatMap (theme: + concatMap (basePath: + map (category: + "${basePath}/share/icons/${theme.name}/${theme.size}/${category}") + categories) basePaths) themes); + + systemd.user.services.dunst = { + Unit = { + Description = "Dunst notification daemon"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; }; - } - - (mkIf (cfg.settings != {}) { - xdg.configFile."dunst/dunstrc" = { - text = toDunstIni cfg.settings; - onChange = '' - pkillVerbose="" - if [[ -v VERBOSE ]]; then - pkillVerbose="-e" - fi - $DRY_RUN_CMD ${pkgs.procps}/bin/pkill -u $USER $pkillVerbose dunst || true - unset pkillVerbose - ''; + + Service = { + Type = "dbus"; + BusName = "org.freedesktop.Notifications"; + ExecStart = "${pkgs.dunst}/bin/dunst"; }; - }) - ] - ); + }; + } + + (mkIf (cfg.settings != { }) { + xdg.configFile."dunst/dunstrc" = { + text = toDunstIni cfg.settings; + onChange = '' + pkillVerbose="" + if [[ -v VERBOSE ]]; then + pkillVerbose="-e" + fi + $DRY_RUN_CMD ${pkgs.procps}/bin/pkill -u $USER $pkillVerbose dunst || true + unset pkillVerbose + ''; + }; + }) + ]); } diff --git a/home-manager/modules/services/dwm-status.nix b/home-manager/modules/services/dwm-status.nix index 2b010cec1e1..7a19e5e5fc9 100644 --- a/home-manager/modules/services/dwm-status.nix +++ b/home-manager/modules/services/dwm-status.nix @@ -10,9 +10,8 @@ let configText = builtins.toJSON ({ inherit (cfg) order; } // cfg.extraConfig); configFile = pkgs.writeText "dwm-status.json" configText; -in -{ +in { options = { services.dwm-status = { enable = mkEnableOption "dwm-status user service"; @@ -32,7 +31,7 @@ in extraConfig = mkOption { type = types.attrs; - default = {}; + default = { }; example = literalExample '' { separator = "#"; @@ -58,13 +57,9 @@ in PartOf = [ "graphical-session.target" ]; }; - Install = { - WantedBy = [ "graphical-session.target" ]; - }; + Install = { WantedBy = [ "graphical-session.target" ]; }; - Service = { - ExecStart = "${cfg.package}/bin/dwm-status ${configFile}"; - }; + Service = { ExecStart = "${cfg.package}/bin/dwm-status ${configFile}"; }; }; }; } diff --git a/home-manager/modules/services/emacs.nix b/home-manager/modules/services/emacs.nix index 33d6871c61b..5b0e88db72d 100644 --- a/home-manager/modules/services/emacs.nix +++ b/home-manager/modules/services/emacs.nix @@ -8,26 +8,21 @@ let emacsCfg = config.programs.emacs; emacsBinPath = "${emacsCfg.finalPackage}/bin"; -in - -{ - options.services.emacs = { - enable = mkEnableOption "the Emacs daemon"; - }; +in { + options.services.emacs = { enable = mkEnableOption "the Emacs daemon"; }; config = mkIf cfg.enable { - assertions = [ - { - assertion = emacsCfg.enable; - message = "The Emacs service module requires" - + " 'programs.emacs.enable = true'."; - } - ]; + assertions = [{ + assertion = emacsCfg.enable; + message = "The Emacs service module requires" + + " 'programs.emacs.enable = true'."; + }]; systemd.user.services.emacs = { Unit = { Description = "Emacs: the extensible, self-documenting text editor"; - Documentation = "info:emacs man:emacs(1) https://gnu.org/software/emacs/"; + Documentation = + "info:emacs man:emacs(1) https://gnu.org/software/emacs/"; # Avoid killing the Emacs session, which may be full of # unsaved buffers. @@ -35,14 +30,13 @@ in }; Service = { - ExecStart = "${pkgs.runtimeShell} -l -c 'exec ${emacsBinPath}/emacs --fg-daemon'"; + ExecStart = + "${pkgs.runtimeShell} -l -c 'exec ${emacsBinPath}/emacs --fg-daemon'"; ExecStop = "${emacsBinPath}/emacsclient --eval '(kill-emacs)'"; Restart = "on-failure"; }; - Install = { - WantedBy = [ "default.target" ]; - }; + Install = { WantedBy = [ "default.target" ]; }; }; }; } diff --git a/home-manager/modules/services/flameshot.nix b/home-manager/modules/services/flameshot.nix index 87b494d0fcd..c8659d51d1e 100644 --- a/home-manager/modules/services/flameshot.nix +++ b/home-manager/modules/services/flameshot.nix @@ -7,16 +7,10 @@ let cfg = config.services.flameshot; package = pkgs.flameshot; -in - -{ +in { meta.maintainers = [ maintainers.hamhut1066 ]; - options = { - services.flameshot = { - enable = mkEnableOption "Flameshot"; - }; - }; + options = { services.flameshot = { enable = mkEnableOption "Flameshot"; }; }; config = mkIf cfg.enable { home.packages = [ package ]; @@ -33,9 +27,7 @@ in PartOf = [ "graphical-session.target" ]; }; - Install = { - WantedBy = [ "graphical-session.target" ]; - }; + Install = { WantedBy = [ "graphical-session.target" ]; }; Service = { Environment = "PATH=${config.home.profileDirectory}/bin"; diff --git a/home-manager/modules/services/getmail.nix b/home-manager/modules/services/getmail.nix index 46d4c1752d4..e7a1b1a4627 100644 --- a/home-manager/modules/services/getmail.nix +++ b/home-manager/modules/services/getmail.nix @@ -6,17 +6,19 @@ let cfg = config.services.getmail; - accounts = filter (a: a.getmail.enable) - (attrValues config.accounts.email.accounts); + accounts = + filter (a: a.getmail.enable) (attrValues config.accounts.email.accounts); # Note: The getmail service does not expect a path, but just the filename! - renderConfigFilepath = a: if a.primary then "getmailrc" else "getmail${a.name}"; - configFiles = concatMapStringsSep " " (a: " --rcfile ${renderConfigFilepath a}") accounts; -in -{ + renderConfigFilepath = a: + if a.primary then "getmailrc" else "getmail${a.name}"; + configFiles = + concatMapStringsSep " " (a: " --rcfile ${renderConfigFilepath a}") accounts; +in { options = { services.getmail = { - enable = mkEnableOption "the getmail systemd service to automatically retrieve mail"; + enable = mkEnableOption + "the getmail systemd service to automatically retrieve mail"; frequency = mkOption { type = types.str; @@ -36,25 +38,17 @@ in config = mkIf cfg.enable { systemd.user.services.getmail = { - Unit = { - Description = "getmail email fetcher"; - }; - Service = { - ExecStart = "${pkgs.getmail}/bin/getmail ${configFiles}"; - }; + Unit = { Description = "getmail email fetcher"; }; + Service = { ExecStart = "${pkgs.getmail}/bin/getmail ${configFiles}"; }; }; systemd.user.timers.getmail = { - Unit = { - Description = "getmail email fetcher"; - }; + Unit = { Description = "getmail email fetcher"; }; Timer = { OnCalendar = "${cfg.frequency}"; Unit = "getmail.service"; }; - Install = { - WantedBy = [ "timers.target" ]; - }; + Install = { WantedBy = [ "timers.target" ]; }; }; }; diff --git a/home-manager/modules/services/gnome-keyring.nix b/home-manager/modules/services/gnome-keyring.nix index 4ca6c7cacf2..6d8317dcffc 100644 --- a/home-manager/modules/services/gnome-keyring.nix +++ b/home-manager/modules/services/gnome-keyring.nix @@ -6,9 +6,7 @@ let cfg = config.services.gnome-keyring; -in - -{ +in { meta.maintainers = [ maintainers.rycee ]; options = { @@ -16,8 +14,8 @@ in enable = mkEnableOption "GNOME Keyring"; components = mkOption { - type = types.listOf (types.enum ["pkcs11" "secrets" "ssh"]); - default = []; + type = types.listOf (types.enum [ "pkcs11" "secrets" "ssh" ]); + default = [ ]; description = '' The GNOME keyring components to start. If empty then the default set of components will be started. @@ -34,22 +32,15 @@ in }; Service = { - ExecStart = - let - args = concatStringsSep " " ( - [ "--start" "--foreground" ] - ++ optional (cfg.components != []) ( - "--components=" + concatStringsSep "," cfg.components - ) - ); - in - "${pkgs.gnome3.gnome_keyring}/bin/gnome-keyring-daemon ${args}"; + ExecStart = let + args = concatStringsSep " " ([ "--start" "--foreground" ] + ++ optional (cfg.components != [ ]) + ("--components=" + concatStringsSep "," cfg.components)); + in "${pkgs.gnome3.gnome_keyring}/bin/gnome-keyring-daemon ${args}"; Restart = "on-abort"; }; - Install = { - WantedBy = [ "graphical-session-pre.target" ]; - }; + Install = { WantedBy = [ "graphical-session-pre.target" ]; }; }; }; } diff --git a/home-manager/modules/services/gpg-agent.nix b/home-manager/modules/services/gpg-agent.nix index 5dc942fef63..16a4723fea7 100644 --- a/home-manager/modules/services/gpg-agent.nix +++ b/home-manager/modules/services/gpg-agent.nix @@ -129,6 +129,26 @@ in configuration file. ''; }; + + pinentryFlavor = mkOption { + type = types.nullOr (types.enum pkgs.pinentry.flavors); + example = "gnome3"; + default = "gtk2"; + description = '' + Which pinentry interface to use. If not + <literal>null</literal>, it sets + <option>pinentry-program</option> in + <filename>gpg-agent.conf</filename>. Beware that + <literal>pinentry-gnome3</literal> may not work on non-Gnome + systems. You can fix it by adding the following to your + system configuration: + <programlisting language="nix"> + services.dbus.packages = [ pkgs.gcr ]; + </programlisting> + For this reason, the default is <literal>gtk2</literal> for + now. + ''; + }; }; }; @@ -153,6 +173,9 @@ in optional (cfg.maxCacheTtlSsh != null) "max-cache-ttl-ssh ${toString cfg.maxCacheTtlSsh}" ++ + optional (cfg.pinentryFlavor != null) + "pinentry-program ${pkgs.pinentry.${cfg.pinentryFlavor}}/bin/pinentry" + ++ [ cfg.extraConfig ] ); diff --git a/home-manager/modules/services/grobi.nix b/home-manager/modules/services/grobi.nix new file mode 100644 index 00000000000..4dfc5d6331f --- /dev/null +++ b/home-manager/modules/services/grobi.nix @@ -0,0 +1,97 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.services.grobi; + + eitherStrBoolIntList = with types; + either str (either bool (either int (listOf str))); + +in { + meta.maintainers = [ maintainers.mbrgm ]; + + options = { + services.grobi = { + enable = mkEnableOption "the grobi display setup daemon"; + + executeAfter = mkOption { + type = with types; listOf str; + default = [ ]; + example = [ "setxkbmap dvorak" ]; + description = '' + Commands to be run after an output configuration was + changed. The Nix value declared here will be translated to + JSON and written to the <option>execute_after</option> key + in <filename>~/.config/grobi.conf</filename>. + ''; + }; + + rules = mkOption { + type = with types; listOf (attrsOf eitherStrBoolIntList); + default = [ ]; + example = literalExample '' + [ + { + name = "Home"; + outputs_connected = [ "DP-2" ]; + configure_single = "DP-2"; + primary = true; + atomic = true; + execute_after = [ + "${pkgs.xorg.xrandr}/bin/xrandr --dpi 96" + "${pkgs.xmonad-with-packages}/bin/xmonad --restart"; + ]; + } + { + name = "Mobile"; + outputs_disconnected = [ "DP-2" ]; + configure_single = "eDP-1"; + primary = true; + atomic = true; + execute_after = [ + "${pkgs.xorg.xrandr}/bin/xrandr --dpi 120" + "${pkgs.xmonad-with-packages}/bin/xmonad --restart"; + ]; + } + ] + ''; + description = '' + These are the rules grobi tries to match to the current + output configuration. The rules are evaluated top to bottom, + the first matching rule is applied and processing stops. See + <link xlink:href="https://github.com/fd0/grobi/blob/master/doc/grobi.conf"/> + for more information. The Nix value declared here will be + translated to JSON and written to the <option>rules</option> + key in <filename>~/.config/grobi.conf</filename>. + ''; + }; + }; + }; + + config = mkIf cfg.enable { + systemd.user.services.grobi = { + Unit = { + Description = "grobi display auto config daemon"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; + + Service = { + Type = "simple"; + ExecStart = "${pkgs.grobi}/bin/grobi watch -v"; + Restart = "always"; + RestartSec = "2s"; + Environment = "PATH=${pkgs.xorg.xrandr}/bin:${pkgs.bash}/bin"; + }; + + Install = { WantedBy = [ "graphical-session.target" ]; }; + }; + + xdg.configFile."grobi.conf".text = builtins.toJSON { + execute_after = cfg.executeAfter; + rules = cfg.rules; + }; + }; +} diff --git a/home-manager/modules/services/hound.nix b/home-manager/modules/services/hound.nix index a252a68d271..00589f3405f 100644 --- a/home-manager/modules/services/hound.nix +++ b/home-manager/modules/services/hound.nix @@ -6,23 +6,16 @@ let cfg = config.services.hound; - configFile = pkgs.writeText "hound-config.json" ( - builtins.toJSON { - max-concurrent-indexers = cfg.maxConcurrentIndexers; - dbpath = cfg.databasePath; - repos = cfg.repositories; - health-check-url = "/healthz"; - } - ); + configFile = pkgs.writeText "hound-config.json" (builtins.toJSON { + max-concurrent-indexers = cfg.maxConcurrentIndexers; + dbpath = cfg.databasePath; + repos = cfg.repositories; + health-check-url = "/healthz"; + }); - houndOptions = [ - "--addr ${cfg.listenAddress}" - "--conf ${configFile}" - ]; + houndOptions = [ "--addr ${cfg.listenAddress}" "--conf ${configFile}" ]; -in - -{ +in { meta.maintainers = [ maintainers.adisbladis ]; options.services.hound = { @@ -37,7 +30,7 @@ in databasePath = mkOption { type = types.path; default = "${config.xdg.dataHome}/hound"; - defaultText = "\$XDG_DATA_HOME/hound"; + defaultText = "$XDG_DATA_HOME/hound"; description = "The Hound database path."; }; @@ -49,7 +42,7 @@ in repositories = mkOption { type = types.attrsOf (types.uniq types.attrs); - default = {}; + default = { }; example = literalExample '' { SomeGitRepo = { @@ -67,17 +60,14 @@ in home.packages = [ pkgs.hound ]; systemd.user.services.hound = { - Unit = { - Description = "Hound source code search engine"; - }; + Unit = { Description = "Hound source code search engine"; }; - Install = { - WantedBy = [ "default.target" ]; - }; + Install = { WantedBy = [ "default.target" ]; }; Service = { Environment = "PATH=${makeBinPath [ pkgs.mercurial pkgs.git ]}"; - ExecStart = "${pkgs.hound}/bin/houndd ${concatStringsSep " " houndOptions}"; + ExecStart = + "${pkgs.hound}/bin/houndd ${concatStringsSep " " houndOptions}"; }; }; }; diff --git a/home-manager/modules/services/imapnotify-accounts.nix b/home-manager/modules/services/imapnotify-accounts.nix index 1c780bf28c3..94bdce5dfb4 100644 --- a/home-manager/modules/services/imapnotify-accounts.nix +++ b/home-manager/modules/services/imapnotify-accounts.nix @@ -16,13 +16,16 @@ with lib; onNotifyPost = mkOption { type = with types; either str (attrsOf str); default = ""; - example = { mail = "\${pkgs.notmuch}/bin/notmuch new && \${pkgs.libnotify}/bin/notify-send 'New mail arrived'"; }; + example = { + mail = + "\${pkgs.notmuch}/bin/notmuch new && \${pkgs.libnotify}/bin/notify-send 'New mail arrived'"; + }; description = "Shell commands to run after onNotify event."; }; boxes = mkOption { type = types.listOf types.str; - default = []; + default = [ ]; example = [ "Inbox" "[Gmail]/MyLabel" ]; description = "IMAP folders to watch."; }; diff --git a/home-manager/modules/services/imapnotify.nix b/home-manager/modules/services/imapnotify.nix index fbb0713e978..b59b006e335 100644 --- a/home-manager/modules/services/imapnotify.nix +++ b/home-manager/modules/services/imapnotify.nix @@ -6,102 +6,85 @@ let cfg = config.services.imapnotify; - safeName = lib.replaceChars ["@" ":" "\\" "[" "]"] ["-" "-" "-" "" ""]; + safeName = lib.replaceChars [ "@" ":" "\\" "[" "]" ] [ "-" "-" "-" "" "" ]; imapnotifyAccounts = - filter (a: a.imapnotify.enable) - (attrValues config.accounts.email.accounts); + filter (a: a.imapnotify.enable) (attrValues config.accounts.email.accounts); genAccountUnit = account: - let - name = safeName account.name; - in - { - name = "imapnotify-${name}"; - value = { - Unit = { - Description = "imapnotify for ${name}"; - }; - - Service = { - ExecStart = "${pkgs.imapnotify}/bin/imapnotify -c ${genAccountConfig account}"; - } // optionalAttrs account.notmuch.enable { - Environment = "NOTMUCH_CONFIG=${config.xdg.configHome}/notmuch/notmuchrc"; - }; - - Install = { - WantedBy = [ "default.target" ]; - }; + let name = safeName account.name; + in { + name = "imapnotify-${name}"; + value = { + Unit = { Description = "imapnotify for ${name}"; }; + + Service = { + ExecStart = + "${pkgs.imapnotify}/bin/imapnotify -c ${genAccountConfig account}"; + } // optionalAttrs account.notmuch.enable { + Environment = + "NOTMUCH_CONFIG=${config.xdg.configHome}/notmuch/notmuchrc"; }; + + Install = { WantedBy = [ "default.target" ]; }; }; + }; genAccountConfig = account: - pkgs.writeText "imapnotify-${safeName account.name}-config.js" ( - let - port = - if account.imap.port != null then account.imap.port - else if account.imap.tls.enable then 993 - else 143; - - toJSON = builtins.toJSON; - in - '' - var child_process = require('child_process'); - - function getStdout(cmd) { - var stdout = child_process.execSync(cmd); - return stdout.toString().trim(); - } - - exports.host = ${toJSON account.imap.host} - exports.port = ${toJSON port}; - exports.tls = ${toJSON account.imap.tls.enable}; - exports.username = ${toJSON account.userName}; - exports.password = getStdout("${toString account.passwordCommand}"); - exports.onNotify = ${toJSON account.imapnotify.onNotify}; - exports.onNotifyPost = ${toJSON account.imapnotify.onNotifyPost}; - exports.boxes = ${toJSON account.imapnotify.boxes}; - '' - ); - -in - -{ + pkgs.writeText "imapnotify-${safeName account.name}-config.js" (let + port = if account.imap.port != null then + account.imap.port + else if account.imap.tls.enable then + 993 + else + 143; + + toJSON = builtins.toJSON; + in '' + var child_process = require('child_process'); + + function getStdout(cmd) { + var stdout = child_process.execSync(cmd); + return stdout.toString().trim(); + } + + exports.host = ${toJSON account.imap.host} + exports.port = ${toJSON port}; + exports.tls = ${toJSON account.imap.tls.enable}; + exports.username = ${toJSON account.userName}; + exports.password = getStdout("${toString account.passwordCommand}"); + exports.onNotify = ${toJSON account.imapnotify.onNotify}; + exports.onNotifyPost = ${toJSON account.imapnotify.onNotifyPost}; + exports.boxes = ${toJSON account.imapnotify.boxes}; + ''); + +in { meta.maintainers = [ maintainers.nickhu ]; options = { - services.imapnotify = { - enable = mkEnableOption "imapnotify"; - }; + services.imapnotify = { enable = mkEnableOption "imapnotify"; }; accounts.email.accounts = mkOption { - type = with types; attrsOf (submodule ( - import ./imapnotify-accounts.nix - )); + type = with types; attrsOf (submodule (import ./imapnotify-accounts.nix)); }; }; config = mkIf cfg.enable { - assertions = - let - checkAccounts = pred: msg: - let - badAccounts = filter pred imapnotifyAccounts; - in - { - assertion = badAccounts == []; - message = "imapnotify: Missing ${msg} for accounts: " - + concatMapStringsSep ", " (a: a.name) badAccounts; - }; - in - [ - (checkAccounts (a: a.maildir == null) "maildir configuration") - (checkAccounts (a: a.imap == null) "IMAP configuration") - (checkAccounts (a: a.passwordCommand == null) "password command") - (checkAccounts (a: a.userName == null) "username") - ]; - - systemd.user.services = - listToAttrs (map genAccountUnit imapnotifyAccounts); + assertions = let + checkAccounts = pred: msg: + let badAccounts = filter pred imapnotifyAccounts; + in { + assertion = badAccounts == [ ]; + message = "imapnotify: Missing ${msg} for accounts: " + + concatMapStringsSep ", " (a: a.name) badAccounts; + }; + in [ + (checkAccounts (a: a.maildir == null) "maildir configuration") + (checkAccounts (a: a.imap == null) "IMAP configuration") + (checkAccounts (a: a.passwordCommand == null) "password command") + (checkAccounts (a: a.userName == null) "username") + ]; + + systemd.user.services = listToAttrs (map genAccountUnit imapnotifyAccounts); }; } diff --git a/home-manager/modules/services/kdeconnect.nix b/home-manager/modules/services/kdeconnect.nix index bd698fcf836..82de1f0eb7c 100644 --- a/home-manager/modules/services/kdeconnect.nix +++ b/home-manager/modules/services/kdeconnect.nix @@ -7,9 +7,7 @@ let cfg = config.services.kdeconnect; package = pkgs.kdeconnect; -in - -{ +in { meta.maintainers = [ maintainers.adisbladis ]; options = { @@ -31,14 +29,13 @@ in systemd.user.services.kdeconnect = { Unit = { - Description = "Adds communication between your desktop and your smartphone"; + Description = + "Adds communication between your desktop and your smartphone"; After = [ "graphical-session-pre.target" ]; PartOf = [ "graphical-session.target" ]; }; - Install = { - WantedBy = [ "graphical-session.target" ]; - }; + Install = { WantedBy = [ "graphical-session.target" ]; }; Service = { Environment = "PATH=${config.home.profileDirectory}/bin"; @@ -52,16 +49,16 @@ in systemd.user.services.kdeconnect-indicator = { Unit = { Description = "kdeconnect-indicator"; - After = [ "graphical-session-pre.target" - "polybar.service" - "taffybar.service" - "stalonetray.service" ]; + After = [ + "graphical-session-pre.target" + "polybar.service" + "taffybar.service" + "stalonetray.service" + ]; PartOf = [ "graphical-session.target" ]; }; - Install = { - WantedBy = [ "graphical-session.target" ]; - }; + Install = { WantedBy = [ "graphical-session.target" ]; }; Service = { Environment = "PATH=${config.home.profileDirectory}/bin"; diff --git a/home-manager/modules/services/keepassx.nix b/home-manager/modules/services/keepassx.nix index ad791786f05..dc37066e20c 100644 --- a/home-manager/modules/services/keepassx.nix +++ b/home-manager/modules/services/keepassx.nix @@ -13,19 +13,15 @@ with lib; config = mkIf config.services.keepassx.enable { systemd.user.services.keepassx = { - Unit = { - Description = "KeePassX password manager"; - After = [ "graphical-session-pre.target" ]; - PartOf = [ "graphical-session.target" ]; - }; + Unit = { + Description = "KeePassX password manager"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; - Install = { - WantedBy = [ "graphical-session.target" ]; - }; + Install = { WantedBy = [ "graphical-session.target" ]; }; - Service = { - ExecStart = "${pkgs.keepassx}/bin/keepassx -min -lock"; - }; + Service = { ExecStart = "${pkgs.keepassx}/bin/keepassx -min -lock"; }; }; }; } diff --git a/home-manager/modules/services/lorri.nix b/home-manager/modules/services/lorri.nix new file mode 100644 index 00000000000..3b2c244e3c0 --- /dev/null +++ b/home-manager/modules/services/lorri.nix @@ -0,0 +1,51 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.services.lorri; + +in { + meta.maintainers = [ maintainers.gerschtli ]; + + options = { services.lorri.enable = mkEnableOption "lorri build daemon"; }; + + config = mkIf cfg.enable { + home.packages = [ pkgs.lorri ]; + + systemd.user = { + services.lorri = { + Unit = { + Description = "lorri build daemon"; + Requires = "lorri.socket"; + After = "lorri.socket"; + RefuseManualStart = true; + }; + + Service = { + ExecStart = "${pkgs.lorri}/bin/lorri daemon"; + PrivateTmp = true; + ProtectSystem = "strict"; + ProtectHome = "read-only"; + Restart = "on-failure"; + Environment = let + path = with pkgs; + makeSearchPath "bin" [ nix gitMinimal gnutar gzip ]; + in "PATH=${path}"; + }; + }; + + sockets.lorri = { + Unit = { Description = "Socket for lorri build daemon"; }; + + Socket = { + ListenStream = "%t/lorri/daemon.socket"; + RuntimeDirectory = "lorri"; + }; + + Install = { WantedBy = [ "sockets.target" ]; }; + }; + }; + }; +} diff --git a/home-manager/modules/services/mbsync.nix b/home-manager/modules/services/mbsync.nix index 73c3b326695..ac6ac1ef78a 100644 --- a/home-manager/modules/services/mbsync.nix +++ b/home-manager/modules/services/mbsync.nix @@ -6,14 +6,10 @@ let cfg = config.services.mbsync; - mbsyncOptions = - [ "--all" - ] ++ optional (cfg.verbose) "--verbose" - ++ optional (cfg.configFile != null) "--config ${cfg.configFile}"; + mbsyncOptions = [ "--all" ] ++ optional (cfg.verbose) "--verbose" + ++ optional (cfg.configFile != null) "--config ${cfg.configFile}"; -in - -{ +in { meta.maintainers = [ maintainers.pjones ]; options.services.mbsync = { @@ -81,30 +77,28 @@ in config = mkIf cfg.enable { systemd.user.services.mbsync = { - Unit = { - Description = "mbsync mailbox synchronization"; - }; + Unit = { Description = "mbsync mailbox synchronization"; }; Service = { Type = "oneshot"; - ExecStart = "${cfg.package}/bin/mbsync ${concatStringsSep " " mbsyncOptions}"; - } // (optionalAttrs (cfg.postExec != null) { ExecStartPost = cfg.postExec; }) - // (optionalAttrs (cfg.preExec != null) { ExecStartPre = cfg.preExec; }); + ExecStart = + "${cfg.package}/bin/mbsync ${concatStringsSep " " mbsyncOptions}"; + } // (optionalAttrs (cfg.postExec != null) { + ExecStartPost = cfg.postExec; + }) // (optionalAttrs (cfg.preExec != null) { + ExecStartPre = cfg.preExec; + }); }; systemd.user.timers.mbsync = { - Unit = { - Description = "mbsync mailbox synchronization"; - }; + Unit = { Description = "mbsync mailbox synchronization"; }; Timer = { OnCalendar = cfg.frequency; Unit = "mbsync.service"; }; - Install = { - WantedBy = [ "timers.target" ]; - }; + Install = { WantedBy = [ "timers.target" ]; }; }; }; } diff --git a/home-manager/modules/services/mpdris2.nix b/home-manager/modules/services/mpdris2.nix index 450f84c5912..cb8cefba6bd 100644 --- a/home-manager/modules/services/mpdris2.nix +++ b/home-manager/modules/services/mpdris2.nix @@ -9,11 +9,11 @@ let toIni = generators.toINI { mkKeyValue = key: value: let - value' = - if isBool value then (if value then "True" else "False") - else toString value; - in - "${key} = ${value'}"; + value' = if isBool value then + (if value then "True" else "False") + else + toString value; + in "${key} = ${value'}"; }; mpdris2Conf = { @@ -29,9 +29,7 @@ let }; }; -in - -{ +in { meta.maintainers = [ maintainers.pjones ]; options.services.mpdris2 = { @@ -76,25 +74,27 @@ in }; config = mkIf cfg.enable { - assertions = [ - { - assertion = config.services.mpd.enable; - message = "The mpdris2 module requires 'services.mpd.enable = true'."; - } - ]; + assertions = [{ + assertion = config.services.mpd.enable; + message = "The mpdris2 module requires 'services.mpd.enable = true'."; + }]; xdg.configFile."mpDris2/mpDris2.conf".text = toIni mpdris2Conf; systemd.user.services.mpdris2 = { + Install = { WantedBy = [ "default.target" ]; }; + Unit = { Description = "MPRIS 2 support for MPD"; - After = [ "graphical-session-pre.target" "mpd.service" ]; - PartOf = [ "graphical-session.target" ]; + After = [ "mpd.service" ]; }; Service = { Type = "simple"; + Restart = "on-failure"; + RestartSec = "5s"; ExecStart = "${cfg.package}/bin/mpDris2"; + BusName = "org.mpris.MediaPlayer2.mpd"; }; }; }; diff --git a/home-manager/modules/services/muchsync.nix b/home-manager/modules/services/muchsync.nix index 72bf737c27d..b7004418d35 100644 --- a/home-manager/modules/services/muchsync.nix +++ b/home-manager/modules/services/muchsync.nix @@ -150,23 +150,21 @@ in { }; config = let - mapRemotes = gen: with attrsets; mapAttrs' + mapRemotes = gen: + with attrsets; + mapAttrs' (name: remoteCfg: nameValuePair "muchsync-${name}" (gen name remoteCfg)) cfg.remotes; in mkIf (cfg.remotes != { }) { - assertions = [ - { - assertion = config.programs.notmuch.enable; - message = '' - The muchsync module requires 'programs.notmuch.enable = true'. - ''; - } - ]; + assertions = [{ + assertion = config.programs.notmuch.enable; + message = '' + The muchsync module requires 'programs.notmuch.enable = true'. + ''; + }]; systemd.user.services = mapRemotes (name: remoteCfg: { - Unit = { - Description = "muchsync sync service (${name})"; - }; + Unit = { Description = "muchsync sync service (${name})"; }; Service = { CPUSchedulingPolicy = "idle"; IOSchedulingClass = "idle"; @@ -175,8 +173,7 @@ in { ''"NOTMUCH_CONFIG=${config.home.sessionVariables.NOTMUCH_CONFIG}"'' ''"NMBGIT=${config.home.sessionVariables.NMBGIT}"'' ]; - ExecStart = concatStringsSep " " ( - [ "${pkgs.muchsync}/bin/muchsync" ] + ExecStart = concatStringsSep " " ([ "${pkgs.muchsync}/bin/muchsync" ] ++ [ "-s ${escapeShellArg remoteCfg.sshCommand}" ] ++ optional (!remoteCfg.upload) "--noup" @@ -187,25 +184,20 @@ in { # remote configuration ++ [ (escapeShellArg remoteCfg.remote.host) ] ++ optional (remoteCfg.remote.muchsyncPath != "") - "-r ${escapeShellArg remoteCfg.remote.muchsyncPath}" + "-r ${escapeShellArg remoteCfg.remote.muchsyncPath}" ++ optional remoteCfg.remote.checkForModifiedFiles "-F" - ++ optional (!remoteCfg.remote.importNew) "--nonew" - ); + ++ optional (!remoteCfg.remote.importNew) "--nonew"); }; }); systemd.user.timers = mapRemotes (name: remoteCfg: { - Unit = { - Description = "muchsync periodic sync (${name})"; - }; + Unit = { Description = "muchsync periodic sync (${name})"; }; Timer = { Unit = "muchsync-${name}.service"; OnCalendar = remoteCfg.frequency; Persistent = true; }; - Install = { - WantedBy = [ "timers.target" ]; - }; + Install = { WantedBy = [ "timers.target" ]; }; }); }; } diff --git a/home-manager/modules/services/network-manager-applet.nix b/home-manager/modules/services/network-manager-applet.nix index 72a4711e39a..bf57ed65091 100644 --- a/home-manager/modules/services/network-manager-applet.nix +++ b/home-manager/modules/services/network-manager-applet.nix @@ -6,9 +6,7 @@ let cfg = config.services.network-manager-applet; -in - -{ +in { meta.maintainers = [ maintainers.rycee ]; options = { @@ -25,17 +23,13 @@ in PartOf = [ "graphical-session.target" ]; }; - Install = { - WantedBy = [ "graphical-session.target" ]; - }; + Install = { WantedBy = [ "graphical-session.target" ]; }; Service = { - ExecStart = toString ( - [ - "${pkgs.networkmanagerapplet}/bin/nm-applet" - "--sm-disable" - ] ++ optional config.xsession.preferStatusNotifierItems "--indicator" - ); + ExecStart = toString + ([ "${pkgs.networkmanagerapplet}/bin/nm-applet" "--sm-disable" ] + ++ optional config.xsession.preferStatusNotifierItems + "--indicator"); }; }; }; diff --git a/home-manager/modules/services/nextcloud-client.nix b/home-manager/modules/services/nextcloud-client.nix index 3d8dc0bc80b..555ca11ad64 100644 --- a/home-manager/modules/services/nextcloud-client.nix +++ b/home-manager/modules/services/nextcloud-client.nix @@ -4,9 +4,7 @@ with lib; { options = { - services.nextcloud-client = { - enable = mkEnableOption "Nextcloud Client"; - }; + services.nextcloud-client = { enable = mkEnableOption "Nextcloud Client"; }; }; config = mkIf config.services.nextcloud-client.enable { @@ -22,9 +20,7 @@ with lib; ExecStart = "${pkgs.nextcloud-client}/bin/nextcloud"; }; - Install = { - WantedBy = [ "graphical-session.target" ]; - }; + Install = { WantedBy = [ "graphical-session.target" ]; }; }; }; } diff --git a/home-manager/modules/services/owncloud-client.nix b/home-manager/modules/services/owncloud-client.nix index d98a508f088..d55d8ffa2a4 100644 --- a/home-manager/modules/services/owncloud-client.nix +++ b/home-manager/modules/services/owncloud-client.nix @@ -4,9 +4,7 @@ with lib; { options = { - services.owncloud-client = { - enable = mkEnableOption "Owncloud Client"; - }; + services.owncloud-client = { enable = mkEnableOption "Owncloud Client"; }; }; config = mkIf config.services.owncloud-client.enable { @@ -22,9 +20,7 @@ with lib; ExecStart = "${pkgs.owncloud-client}/bin/owncloud"; }; - Install = { - WantedBy = [ "graphical-session.target" ]; - }; + Install = { WantedBy = [ "graphical-session.target" ]; }; }; }; } diff --git a/home-manager/modules/services/parcellite.nix b/home-manager/modules/services/parcellite.nix index 455989ffe07..ce04238613b 100644 --- a/home-manager/modules/services/parcellite.nix +++ b/home-manager/modules/services/parcellite.nix @@ -7,15 +7,11 @@ let cfg = config.services.parcellite; package = pkgs.parcellite; -in - -{ +in { meta.maintainers = [ maintainers.gleber ]; options = { - services.parcellite = { - enable = mkEnableOption "Parcellite"; - }; + services.parcellite = { enable = mkEnableOption "Parcellite"; }; }; config = mkIf cfg.enable { @@ -28,17 +24,9 @@ in PartOf = [ "graphical-session.target" ]; }; - Install = { - WantedBy = [ "graphical-session.target" ]; - }; + Install = { WantedBy = [ "graphical-session.target" ]; }; Service = { - # PATH have been added in nixpkgs.parcellite, keeping it here for - # backward compatibility. XDG_DATA_DIRS is necessary to make it pick up - # icons correctly. - Environment = '' - PATH=${package}/bin:${pkgs.which}/bin:${pkgs.xdotool}/bin XDG_DATA_DIRS=${pkgs.hicolor_icon_theme}/share - ''; ExecStart = "${package}/bin/parcellite"; Restart = "on-abort"; }; diff --git a/home-manager/modules/services/password-store-sync.nix b/home-manager/modules/services/password-store-sync.nix new file mode 100644 index 00000000000..81933914980 --- /dev/null +++ b/home-manager/modules/services/password-store-sync.nix @@ -0,0 +1,71 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + serviceCfg = config.services.password-store-sync; + programCfg = config.programs.password-store; + +in { + meta.maintainers = with maintainers; [ pacien ]; + + options.services.password-store-sync = { + enable = mkEnableOption "Password store periodic sync"; + + frequency = mkOption { + type = types.str; + default = "*:0/5"; + description = '' + How often to synchronise the password store git repository with its + default upstream. + </para><para> + This value is passed to the systemd timer configuration as the + <literal>onCalendar</literal> option. + See + <citerefentry> + <refentrytitle>systemd.time</refentrytitle> + <manvolnum>7</manvolnum> + </citerefentry> + for more information about the format. + ''; + }; + }; + + config = mkIf serviceCfg.enable { + assertions = [{ + assertion = programCfg.enable; + message = "The 'services.password-store-sync' module requires" + + " 'programs.password-store.enable = true'."; + }]; + + systemd.user.services.password-store-sync = { + Unit = { Description = "Password store sync"; }; + + Service = { + CPUSchedulingPolicy = "idle"; + IOSchedulingClass = "idle"; + Environment = let + makeEnvironmentPairs = + mapAttrsToList (key: value: "${key}=${builtins.toJSON value}"); + in makeEnvironmentPairs programCfg.settings; + ExecStart = toString (pkgs.writeShellScript "password-store-sync" '' + ${pkgs.pass}/bin/pass git pull --rebase && \ + ${pkgs.pass}/bin/pass git push + ''); + }; + }; + + systemd.user.timers.password-store-sync = { + Unit = { Description = "Password store periodic sync"; }; + + Timer = { + Unit = "password-store-sync.service"; + OnCalendar = serviceCfg.frequency; + Persistent = true; + }; + + Install = { WantedBy = [ "timers.target" ]; }; + }; + }; +} diff --git a/home-manager/modules/services/pasystray.nix b/home-manager/modules/services/pasystray.nix index 8f92f34c091..7c6651d9499 100644 --- a/home-manager/modules/services/pasystray.nix +++ b/home-manager/modules/services/pasystray.nix @@ -6,31 +6,25 @@ with lib; meta.maintainers = [ maintainers.pltanton ]; options = { - services.pasystray = { - enable = mkEnableOption "PulseAudio system tray"; - }; + services.pasystray = { enable = mkEnableOption "PulseAudio system tray"; }; }; config = mkIf config.services.pasystray.enable { systemd.user.services.pasystray = { - Unit = { - Description = "PulseAudio system tray"; - After = [ "graphical-session-pre.target" ]; - PartOf = [ "graphical-session.target" ]; - }; + Unit = { + Description = "PulseAudio system tray"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; - Install = { - WantedBy = [ "graphical-session.target" ]; - }; + Install = { WantedBy = [ "graphical-session.target" ]; }; - Service = { - Environment = - let - toolPaths = makeBinPath [ pkgs.paprefs pkgs.pavucontrol ]; - in - [ "PATH=${toolPaths}" ]; - ExecStart = "${pkgs.pasystray}/bin/pasystray"; - }; + Service = { + Environment = + let toolPaths = makeBinPath [ pkgs.paprefs pkgs.pavucontrol ]; + in [ "PATH=${toolPaths}" ]; + ExecStart = "${pkgs.pasystray}/bin/pasystray"; + }; }; }; } diff --git a/home-manager/modules/services/polybar.nix b/home-manager/modules/services/polybar.nix index 4225ed9b38c..934a990638f 100644 --- a/home-manager/modules/services/polybar.nix +++ b/home-manager/modules/services/polybar.nix @@ -6,30 +6,28 @@ let cfg = config.services.polybar; - eitherStrBoolIntList = with types; either str (either bool (either int (listOf str))); + eitherStrBoolIntList = with types; + either str (either bool (either int (listOf str))); toPolybarIni = generators.toINI { mkKeyValue = key: value: let quoted = v: - if hasPrefix " " v || hasSuffix " " v - then ''"${v}"'' - else v; - - value' = - if isBool value then (if value then "true" else "false") - else if (isString value && key != "include-file") then quoted value - else toString value; - in - "${key}=${value'}"; + if hasPrefix " " v || hasSuffix " " v then ''"${v}"'' else v; + + value' = if isBool value then + (if value then "true" else "false") + else if (isString value && key != "include-file") then + quoted value + else + toString value; + in "${key}=${value'}"; }; configFile = pkgs.writeText "polybar.conf" (toPolybarIni cfg.config + "\n" + cfg.extraConfig); -in - -{ +in { options = { services.polybar = { enable = mkEnableOption "Polybar status bar"; @@ -39,7 +37,7 @@ in default = pkgs.polybar; defaultText = literalExample "pkgs.polybar"; description = "Polybar package to install."; - example = literalExample '' + example = literalExample '' pkgs.polybar.override { i3GapsSupport = true; alsaSupport = true; @@ -50,15 +48,14 @@ in }; config = mkOption { - type = types.coercedTo - types.path + type = types.coercedTo types.path (p: { "section/base" = { include-file = "${p}"; }; }) (types.attrsOf (types.attrsOf eitherStrBoolIntList)); description = '' Polybar configuration. Can be either path to a file, or set of attributes that will be used to create the final configuration. ''; - default = {}; + default = { }; example = literalExample '' { "bar/top" = { @@ -118,25 +115,20 @@ in Description = "Polybar status bar"; After = [ "graphical-session-pre.target" ]; PartOf = [ "graphical-session.target" ]; - X-Restart-Triggers = [ - "${config.xdg.configFile."polybar/config".source}" - ]; + X-Restart-Triggers = + [ "${config.xdg.configFile."polybar/config".source}" ]; }; Service = { Type = "forking"; Environment = "PATH=${cfg.package}/bin:/run/wrappers/bin"; ExecStart = - let - scriptPkg = pkgs.writeShellScriptBin "polybar-start" cfg.script; - in - "${scriptPkg}/bin/polybar-start"; + let scriptPkg = pkgs.writeShellScriptBin "polybar-start" cfg.script; + in "${scriptPkg}/bin/polybar-start"; Restart = "on-failure"; }; - Install = { - WantedBy = [ "graphical-session.target" ]; - }; + Install = { WantedBy = [ "graphical-session.target" ]; }; }; }; diff --git a/home-manager/modules/services/random-background.nix b/home-manager/modules/services/random-background.nix index cbec97ae7cb..9deee8deb5c 100644 --- a/home-manager/modules/services/random-background.nix +++ b/home-manager/modules/services/random-background.nix @@ -6,23 +6,26 @@ let cfg = config.services.random-background; - flags = lib.concatStringsSep " " ( - [ - "--bg-${cfg.display}" - "--no-fehbg" - "--randomize" - ] - ++ lib.optional (!cfg.enableXinerama) "--no-xinerama" - ); + flags = lib.concatStringsSep " " + ([ "--bg-${cfg.display}" "--no-fehbg" "--randomize" ] + ++ lib.optional (!cfg.enableXinerama) "--no-xinerama"); -in - -{ +in { meta.maintainers = [ maintainers.rycee ]; options = { services.random-background = { - enable = mkEnableOption "random desktop background"; + enable = mkEnableOption "" // { + description = '' + Whether to enable random desktop background. + </para><para> + Note, if you are using NixOS and have set up a custom + desktop manager session for Home Manager, then the session + configuration must have the <option>bgSupport</option> + option set to <literal>true</literal> or the background + image set by this module may be overwritten. + ''; + }; imageDirectory = mkOption { type = types.str; @@ -63,41 +66,32 @@ in }; }; - config = mkIf cfg.enable ( - mkMerge ([ - { - systemd.user.services.random-background = { - Unit = { - Description = "Set random desktop background using feh"; - After = [ "graphical-session-pre.target" ]; - PartOf = [ "graphical-session.target" ]; - }; - - Service = { - Type = "oneshot"; - ExecStart = "${pkgs.feh}/bin/feh ${flags} ${cfg.imageDirectory}"; - IOSchedulingClass = "idle"; - }; + config = mkIf cfg.enable (mkMerge ([ + { + systemd.user.services.random-background = { + Unit = { + Description = "Set random desktop background using feh"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; - Install = { - WantedBy = [ "graphical-session.target" ]; - }; + Service = { + Type = "oneshot"; + ExecStart = "${pkgs.feh}/bin/feh ${flags} ${cfg.imageDirectory}"; + IOSchedulingClass = "idle"; }; - } - (mkIf (cfg.interval != null) { - systemd.user.timers.random-background = { - Unit = { - Description = "Set random desktop background using feh"; - }; - Timer = { - OnUnitActiveSec = cfg.interval; - }; + Install = { WantedBy = [ "graphical-session.target" ]; }; + }; + } + (mkIf (cfg.interval != null) { + systemd.user.timers.random-background = { + Unit = { Description = "Set random desktop background using feh"; }; - Install = { - WantedBy = [ "timers.target" ]; - }; - }; - }) - ])); + Timer = { OnUnitActiveSec = cfg.interval; }; + + Install = { WantedBy = [ "timers.target" ]; }; + }; + }) + ])); } diff --git a/home-manager/modules/services/redshift.nix b/home-manager/modules/services/redshift.nix index 1452fcc95ed..86cbab205f6 100644 --- a/home-manager/modules/services/redshift.nix +++ b/home-manager/modules/services/redshift.nix @@ -8,9 +8,7 @@ let cfg = config.services.redshift; -in - -{ +in { meta.maintainers = [ maintainers.rycee ]; options.services.redshift = { @@ -113,7 +111,7 @@ in extraOptions = mkOption { type = types.listOf types.str; - default = []; + default = [ ]; example = [ "-v" "-m randr" ]; description = '' Additional command-line arguments to pass to @@ -123,17 +121,13 @@ in }; config = mkIf cfg.enable { - assertions = [ - { - assertion = - cfg.provider == "manual" - -> cfg.latitude != null && cfg.longitude != null; - message = - "Must provide services.redshift.latitude and" - + " services.redshift.latitude when" - + " services.redshift.provider is set to \"manual\"."; - } - ]; + assertions = [{ + assertion = cfg.provider == "manual" -> cfg.latitude != null + && cfg.longitude != null; + message = "Must provide services.redshift.latitude and" + + " services.redshift.latitude when" + + " services.redshift.provider is set to \"manual\"."; + }]; systemd.user.services.redshift = { Unit = { @@ -142,27 +136,25 @@ in PartOf = [ "graphical-session.target" ]; }; - Install = { - WantedBy = [ "graphical-session.target" ]; - }; + Install = { WantedBy = [ "graphical-session.target" ]; }; Service = { - ExecStart = - let - providerString = - if cfg.provider == "manual" - then "${cfg.latitude}:${cfg.longitude}" - else cfg.provider; - - args = [ - "-l ${providerString}" - "-t ${toString cfg.temperature.day}:${toString cfg.temperature.night}" - "-b ${toString cfg.brightness.day}:${toString cfg.brightness.night}" - ] ++ cfg.extraOptions; - - command = if cfg.tray then "redshift-gtk" else "redshift"; - in - "${cfg.package}/bin/${command} ${concatStringsSep " " args}"; + ExecStart = let + providerString = if cfg.provider == "manual" then + "${cfg.latitude}:${cfg.longitude}" + else + cfg.provider; + + args = [ + "-l ${providerString}" + "-t ${toString cfg.temperature.day}:${ + toString cfg.temperature.night + }" + "-b ${toString cfg.brightness.day}:${toString cfg.brightness.night}" + ] ++ cfg.extraOptions; + + command = if cfg.tray then "redshift-gtk" else "redshift"; + in "${cfg.package}/bin/${command} ${concatStringsSep " " args}"; RestartSec = 3; Restart = "always"; }; diff --git a/home-manager/modules/services/rsibreak.nix b/home-manager/modules/services/rsibreak.nix index 242e03432e8..77eaa71f958 100644 --- a/home-manager/modules/services/rsibreak.nix +++ b/home-manager/modules/services/rsibreak.nix @@ -6,9 +6,7 @@ let cfg = config.services.rsibreak; -in - -{ +in { options.services.rsibreak = { enable = mkEnableOption "rsibreak"; @@ -23,9 +21,7 @@ in PartOf = [ "graphical-session.target" ]; }; - Install = { - WantedBy = [ "graphical-session.target" ]; - }; + Install = { WantedBy = [ "graphical-session.target" ]; }; Service = { Environment = "PATH=${config.home.profileDirectory}/bin"; diff --git a/home-manager/modules/services/screen-locker.nix b/home-manager/modules/services/screen-locker.nix index e3da14069bc..30591a7d1a5 100644 --- a/home-manager/modules/services/screen-locker.nix +++ b/home-manager/modules/services/screen-locker.nix @@ -29,7 +29,7 @@ in { xautolockExtraOptions = mkOption { type = types.listOf types.str; - default = []; + default = [ ]; description = '' Extra command-line arguments to pass to <command>xautolock</command>. ''; @@ -37,7 +37,7 @@ in { xssLockExtraOptions = mkOption { type = types.listOf types.str; - default = []; + default = [ ]; description = '' Extra command-line arguments to pass to <command>xss-lock</command>. ''; @@ -53,9 +53,7 @@ in { PartOf = [ "graphical-session.target" ]; }; - Install = { - WantedBy = [ "graphical-session.target" ]; - }; + Install = { WantedBy = [ "graphical-session.target" ]; }; Service = { ExecStart = concatStringsSep " " ([ @@ -67,10 +65,21 @@ in { }; }; - # xss-lock will run specified screen locker when the session is locked via loginctl - # can't be started as a systemd service, - # see https://bitbucket.org/raymonad/xss-lock/issues/13/allow-operation-as-systemd-user-unit - xsession.initExtra = "${pkgs.xss-lock}/bin/xss-lock ${concatStringsSep " " cfg.xssLockExtraOptions} -- ${cfg.lockCmd} &"; + systemd.user.services.xss-lock = { + Unit = { + Description = "xss-lock, session locker service"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; + + Install = { WantedBy = [ "graphical-session.target" ]; }; + + Service = { + ExecStart = concatStringsSep " " + ([ "${pkgs.xss-lock}/bin/xss-lock" "-s \${XDG_SESSION_ID}" ] + ++ cfg.xssLockExtraOptions ++ [ "-- ${cfg.lockCmd}" ]); + }; + }; }; } diff --git a/home-manager/modules/services/spotifyd.nix b/home-manager/modules/services/spotifyd.nix new file mode 100644 index 00000000000..bc231814eba --- /dev/null +++ b/home-manager/modules/services/spotifyd.nix @@ -0,0 +1,52 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.services.spotifyd; + + configFile = pkgs.writeText "spotifyd.conf" '' + ${generators.toINI { } cfg.settings} + ''; + +in { + options.services.spotifyd = { + enable = mkEnableOption "SpotifyD connect"; + + settings = mkOption { + type = types.attrsOf (types.attrsOf types.str); + default = { }; + description = "Configuration for spotifyd"; + example = literalExample '' + { + global = { + user = "Alex"; + password = "foo"; + device_name = "nix"; + }; + } + ''; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ pkgs.spotifyd ]; + + systemd.user.services.spotifyd = { + Unit = { + Description = "spotify daemon"; + Documentation = "https://github.com/Spotifyd/spotifyd"; + }; + + Install.WantedBy = [ "default.target" ]; + + Service = { + ExecStart = + "${pkgs.spotifyd}/bin/spotifyd --no-daemon --config-path ${configFile}"; + Restart = "always"; + RestartSec = 12; + }; + }; + }; +} diff --git a/home-manager/modules/services/stalonetray.nix b/home-manager/modules/services/stalonetray.nix index 934e78c99a1..cca60498963 100644 --- a/home-manager/modules/services/stalonetray.nix +++ b/home-manager/modules/services/stalonetray.nix @@ -6,9 +6,7 @@ let cfg = config.services.stalonetray; -in - -{ +in { options = { services.stalonetray = { enable = mkEnableOption "Stalonetray system tray"; @@ -22,19 +20,18 @@ in }; config = mkOption { - type = with types; - attrsOf (nullOr (either str (either bool int))); - description = '' - Stalonetray configuration as a set of attributes. - ''; - default = {}; - example = { - geometry = "3x1-600+0"; - decorations = null; - icon_size = 30; - sticky = true; - background = "#cccccc"; - }; + type = with types; attrsOf (nullOr (either str (either bool int))); + description = '' + Stalonetray configuration as a set of attributes. + ''; + default = { }; + example = { + geometry = "3x1-600+0"; + decorations = null; + icon_size = 30; + sticky = true; + background = "#cccccc"; + }; }; extraConfig = mkOption { @@ -42,11 +39,11 @@ in description = "Additional configuration lines for stalonetrayrc."; default = ""; example = '' - geometry 3x1-600+0 - decorations none - icon_size 30 - sticky true - background "#cccccc" + geometry 3x1-600+0 + decorations none + icon_size 30 + sticky true + background "#cccccc" ''; }; }; @@ -63,9 +60,7 @@ in PartOf = [ "graphical-session.target" ]; }; - Install = { - WantedBy = [ "graphical-session.target" ]; - }; + Install = { WantedBy = [ "graphical-session.target" ]; }; Service = { ExecStart = "${cfg.package}/bin/stalonetray"; @@ -74,17 +69,18 @@ in }; } - (mkIf (cfg.config != {}) { - home.file.".stalonetrayrc".text = - let - valueToString = v: - if isBool v then (if v then "true" else "false") - else if (v==null) then "none" - else ''"${toString v}"''; - in - concatStrings ( - mapAttrsToList (k: v: "${k} ${valueToString v}\n") cfg.config - ); + (mkIf (cfg.config != { }) { + home.file.".stalonetrayrc".text = let + valueToString = v: + if isBool v then + (if v then "true" else "false") + else if (v == null) then + "none" + else + ''"${toString v}"''; + in concatStrings (mapAttrsToList (k: v: '' + ${k} ${valueToString v} + '') cfg.config); }) (mkIf (cfg.extraConfig != "") { diff --git a/home-manager/modules/services/status-notifier-watcher.nix b/home-manager/modules/services/status-notifier-watcher.nix index 8a2ded8720a..3c3e54877b4 100644 --- a/home-manager/modules/services/status-notifier-watcher.nix +++ b/home-manager/modules/services/status-notifier-watcher.nix @@ -6,9 +6,7 @@ let cfg = config.services.status-notifier-watcher; -in - -{ +in { meta.maintainers = [ maintainers.pltanton ]; options = { @@ -17,30 +15,30 @@ in package = mkOption { default = pkgs.haskellPackages.status-notifier-item; - defaultText = literalExample "pkgs.haskellPackages.status-notifier-item"; + defaultText = + literalExample "pkgs.haskellPackages.status-notifier-item"; type = types.package; example = literalExample "pkgs.haskellPackages.status-notifier-item"; - description = "The package to use for the status notifier watcher binary."; + description = + "The package to use for the status notifier watcher binary."; }; }; }; config = mkIf cfg.enable { systemd.user.services.status-notifier-watcher = { - Unit = { - Description = "SNI watcher"; - After = [ "graphical-session-pre.target" ]; - PartOf = [ "graphical-session.target" ]; - Before = [ "taffybar.service" ]; - }; - - Service = { - ExecStart = "${cfg.package}/bin/status-notifier-watcher"; - }; - - Install = { - WantedBy = [ "graphical-session.target" "taffybar.service" ]; - }; + Unit = { + Description = "SNI watcher"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + Before = [ "taffybar.service" ]; + }; + + Service = { ExecStart = "${cfg.package}/bin/status-notifier-watcher"; }; + + Install = { + WantedBy = [ "graphical-session.target" "taffybar.service" ]; + }; }; }; } diff --git a/home-manager/modules/services/syncthing.nix b/home-manager/modules/services/syncthing.nix index 7fc556c5234..2ef10540164 100644 --- a/home-manager/modules/services/syncthing.nix +++ b/home-manager/modules/services/syncthing.nix @@ -22,21 +22,21 @@ with lib; systemd.user.services = { syncthing = { Unit = { - Description = "Syncthing - Open Source Continuous File Synchronization"; + Description = + "Syncthing - Open Source Continuous File Synchronization"; Documentation = "man:syncthing(1)"; After = [ "network.target" ]; }; Service = { - ExecStart = "${pkgs.syncthing}/bin/syncthing -no-browser -no-restart -logflags=0"; + ExecStart = + "${pkgs.syncthing}/bin/syncthing -no-browser -no-restart -logflags=0"; Restart = "on-failure"; SuccessExitStatus = [ 3 4 ]; RestartForceExitStatus = [ 3 4 ]; }; - Install = { - WantedBy = [ "default.target" ]; - }; + Install = { WantedBy = [ "default.target" ]; }; }; }; }) @@ -46,10 +46,12 @@ with lib; qsyncthingtray = { Unit = { Description = "QSyncthingTray"; - After = [ "graphical-session-pre.target" - "polybar.service" - "taffybar.service" - "stalonetray.service" ]; + After = [ + "graphical-session-pre.target" + "polybar.service" + "taffybar.service" + "stalonetray.service" + ]; PartOf = [ "graphical-session.target" ]; }; @@ -58,9 +60,7 @@ with lib; ExecStart = "${pkgs.qsyncthingtray}/bin/QSyncthingTray"; }; - Install = { - WantedBy = [ "graphical-session.target" ]; - }; + Install = { WantedBy = [ "graphical-session.target" ]; }; }; }; }) diff --git a/home-manager/modules/services/taffybar.nix b/home-manager/modules/services/taffybar.nix index 69531a19dc9..5392755423d 100644 --- a/home-manager/modules/services/taffybar.nix +++ b/home-manager/modules/services/taffybar.nix @@ -6,9 +6,7 @@ let cfg = config.services.taffybar; -in - -{ +in { meta.maintainers = [ maintainers.rycee ]; options = { @@ -38,9 +36,7 @@ in Restart = "on-failure"; }; - Install = { - WantedBy = [ "graphical-session.target" ]; - }; + Install = { WantedBy = [ "graphical-session.target" ]; }; }; xsession.importedVariables = [ "GDK_PIXBUF_MODULE_FILE" ]; diff --git a/home-manager/modules/services/tahoe-lafs.nix b/home-manager/modules/services/tahoe-lafs.nix index bb7be8d7db9..742b779b270 100644 --- a/home-manager/modules/services/tahoe-lafs.nix +++ b/home-manager/modules/services/tahoe-lafs.nix @@ -6,20 +6,14 @@ with lib; meta.maintainers = [ maintainers.rycee ]; options = { - services.tahoe-lafs = { - enable = mkEnableOption "Tahoe-LAFS"; - }; + services.tahoe-lafs = { enable = mkEnableOption "Tahoe-LAFS"; }; }; config = mkIf config.services.tahoe-lafs.enable { systemd.user.services.tahoe-lafs = { - Unit = { - Description = "Tahoe-LAFS"; - }; + Unit = { Description = "Tahoe-LAFS"; }; - Service = { - ExecStart = "${pkgs.tahoelafs}/bin/tahoe run -C %h/.tahoe"; - }; + Service = { ExecStart = "${pkgs.tahoelafs}/bin/tahoe run -C %h/.tahoe"; }; }; }; } diff --git a/home-manager/modules/services/taskwarrior-sync.nix b/home-manager/modules/services/taskwarrior-sync.nix index 4179ac8aa85..d16c0681bee 100644 --- a/home-manager/modules/services/taskwarrior-sync.nix +++ b/home-manager/modules/services/taskwarrior-sync.nix @@ -6,9 +6,7 @@ let cfg = config.services.taskwarrior-sync; -in - -{ +in { meta.maintainers = with maintainers; [ minijackson pacien ]; options.services.taskwarrior-sync = { @@ -32,9 +30,7 @@ in config = mkIf cfg.enable { systemd.user.services.taskwarrior-sync = { - Unit = { - Description = "Taskwarrior sync"; - }; + Unit = { Description = "Taskwarrior sync"; }; Service = { CPUSchedulingPolicy = "idle"; IOSchedulingClass = "idle"; @@ -43,16 +39,12 @@ in }; systemd.user.timers.taskwarrior-sync = { - Unit = { - Description = "Taskwarrior periodic sync"; - }; + Unit = { Description = "Taskwarrior periodic sync"; }; Timer = { Unit = "taskwarrior-sync.service"; OnCalendar = cfg.frequency; }; - Install = { - WantedBy = [ "timers.target" ]; - }; + Install = { WantedBy = [ "timers.target" ]; }; }; }; } diff --git a/home-manager/modules/services/udiskie.nix b/home-manager/modules/services/udiskie.nix index c058a23de6c..2444d68ff93 100644 --- a/home-manager/modules/services/udiskie.nix +++ b/home-manager/modules/services/udiskie.nix @@ -6,19 +6,17 @@ let cfg = config.services.udiskie; - commandArgs = - concatStringsSep " " ( - map (opt: "-" + opt) [ - (if cfg.automount then "a" else "A") - (if cfg.notify then "n" else "N") - ({ always = "t"; auto = "s"; never = "T"; }.${cfg.tray}) - ] - ++ optional config.xsession.preferStatusNotifierItems "--appindicator" - ); - -in - -{ + commandArgs = concatStringsSep " " (map (opt: "-" + opt) [ + (if cfg.automount then "a" else "A") + (if cfg.notify then "n" else "N") + ({ + always = "t"; + auto = "s"; + never = "T"; + }.${cfg.tray}) + ] ++ optional config.xsession.preferStatusNotifierItems "--appindicator"); + +in { meta.maintainers = [ maintainers.rycee ]; imports = [ @@ -77,19 +75,17 @@ in config = mkIf config.services.udiskie.enable { systemd.user.services.udiskie = { - Unit = { - Description = "udiskie mount daemon"; - After = [ "graphical-session-pre.target" ]; - PartOf = [ "graphical-session.target" ]; - }; + Unit = { + Description = "udiskie mount daemon"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; - Service = { - ExecStart = "${pkgs.udiskie}/bin/udiskie -2 ${commandArgs}"; - }; + Service = { + ExecStart = "${pkgs.udiskie}/bin/udiskie -2 ${commandArgs}"; + }; - Install = { - WantedBy = [ "graphical-session.target" ]; - }; + Install = { WantedBy = [ "graphical-session.target" ]; }; }; }; } diff --git a/home-manager/modules/services/unclutter.nix b/home-manager/modules/services/unclutter.nix index 6b5ac866ec5..5e760639591 100644 --- a/home-manager/modules/services/unclutter.nix +++ b/home-manager/modules/services/unclutter.nix @@ -55,9 +55,7 @@ in { Restart = "always"; }; - Install = { - WantedBy = [ "graphical-session.target" ]; - }; + Install = { WantedBy = [ "graphical-session.target" ]; }; }; }; } diff --git a/home-manager/modules/services/unison.nix b/home-manager/modules/services/unison.nix new file mode 100644 index 00000000000..93c59e8fd62 --- /dev/null +++ b/home-manager/modules/services/unison.nix @@ -0,0 +1,121 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.services.unison; + + pairOf = t: + let list = types.addCheck (types.listOf t) (l: length l == 2); + in list // { description = list.description + " of length 2"; }; + + pairOptions = { + options = { + stateDirectory = mkOption { + type = types.path; + default = "${config.xdg.dataHome}/unison"; + defaultText = "$XDG_DATA_HOME/unison"; + description = '' + Unison state directory to use. + ''; + }; + + commandOptions = mkOption rec { + type = with types; attrsOf str; + apply = mergeAttrs default; + default = { + repeat = "watch"; + sshcmd = "${pkgs.openssh}/bin/ssh"; + ui = "text"; + auto = "true"; + batch = "true"; + log = "false"; # don't log to file, handled by systemd + }; + description = '' + Additional command line options as a dictionary to pass to the + <literal>unison</literal> program. + </para><para> + See + <citerefentry> + <refentrytitle>unison</refentrytitle> + <manvolnum>1</manvolnum> + </citerefentry> + for a list of available options. + ''; + }; + + roots = mkOption { + type = pairOf types.str; + example = literalExample '' + [ + "/home/user/documents" + "ssh://remote/documents" + ] + ''; + description = '' + Pair of roots to synchronise. + ''; + }; + }; + }; + + serialiseArg = key: val: "-${key}=${escapeShellArg val}"; + + serialiseArgs = args: concatStringsSep " " (mapAttrsToList serialiseArg args); + + makeDefs = gen: + mapAttrs' + (name: pairCfg: nameValuePair "unison-pair-${name}" (gen name pairCfg)) + cfg.pairs; + +in { + meta.maintainers = with maintainers; [ pacien ]; + + options.services.unison = { + enable = mkEnableOption "Unison synchronisation"; + + pairs = mkOption { + type = with types; attrsOf (submodule pairOptions); + default = { }; + example = literalExample '' + { + roots = [ + "/home/user/documents" + "ssh://remote/documents" + ]; + } + ''; + description = '' + Unison root pairs to keep synchronised. + ''; + }; + }; + + config = mkIf cfg.enable { + systemd.user.services = makeDefs (name: pairCfg: { + Unit = { + Description = "Unison pair sync (${name})"; + # Retry forever, useful in case of network disruption. + StartLimitIntervalSec = 0; + }; + + Service = { + Restart = "always"; + RestartSec = 60; + + CPUSchedulingPolicy = "idle"; + IOSchedulingClass = "idle"; + + Environment = [ "UNISON='${toString pairCfg.stateDirectory}'" ]; + ExecStart = '' + ${pkgs.unison}/bin/unison \ + ${serialiseArgs pairCfg.commandOptions} \ + ${strings.concatMapStringsSep " " escapeShellArg pairCfg.roots} + ''; + }; + + Install = { WantedBy = [ "default.target" ]; }; + }); + }; +} diff --git a/home-manager/modules/services/window-managers/awesome.nix b/home-manager/modules/services/window-managers/awesome.nix index fe914864e2a..d2e2903f83b 100644 --- a/home-manager/modules/services/window-managers/awesome.nix +++ b/home-manager/modules/services/window-managers/awesome.nix @@ -9,12 +9,9 @@ let getLuaPath = lib: dir: "${lib}/${dir}/lua/${pkgs.luaPackages.lua.luaversion}"; makeSearchPath = lib.concatMapStrings (path: " --search ${getLuaPath path "share"}" - + " --search ${getLuaPath path "lib"}" - ); + + " --search ${getLuaPath path "lib"}"); -in - -{ +in { options = { xsession.windowManager.awesome = { enable = mkEnableOption "Awesome window manager."; @@ -27,31 +24,29 @@ in }; luaModules = mkOption { - default = []; - type = types.listOf types.package; - description = '' - List of lua packages available for being - used in the Awesome configuration. - ''; - example = literalExample "[ luaPackages.oocairo ]"; + default = [ ]; + type = types.listOf types.package; + description = '' + List of lua packages available for being + used in the Awesome configuration. + ''; + example = literalExample "[ luaPackages.oocairo ]"; }; noArgb = mkOption { - default = false; - type = types.bool; - description = '' - Disable client transparency support, which can be greatly - detrimental to performance in some setups - ''; + default = false; + type = types.bool; + description = '' + Disable client transparency support, which can be greatly + detrimental to performance in some setups + ''; }; }; }; config = mkIf cfg.enable { home.packages = [ awesome ]; - xsession.windowManager.command = - "${awesome}/bin/awesome " - + optionalString cfg.noArgb "--no-argb " - + makeSearchPath cfg.luaModules; + xsession.windowManager.command = "${awesome}/bin/awesome " + + optionalString cfg.noArgb "--no-argb " + makeSearchPath cfg.luaModules; }; } diff --git a/home-manager/modules/services/window-managers/bspwm/default.nix b/home-manager/modules/services/window-managers/bspwm/default.nix new file mode 100644 index 00000000000..9ea5adbc880 --- /dev/null +++ b/home-manager/modules/services/window-managers/bspwm/default.nix @@ -0,0 +1,74 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.xsession.windowManager.bspwm; + bspwm = cfg.package; + + camelToSnake = s: + builtins.replaceStrings lib.upperChars (map (c: "_${c}") lib.lowerChars) s; + + formatConfig = n: v: + let + formatList = x: + if isList x then + throw "can not convert 2-dimensional lists to bspwm format" + else + formatValue x; + + formatValue = v: + if isBool v then + (if v then "true" else "false") + else if isList v then + concatMapStringsSep ", " formatList v + else if isString v then + "${lib.strings.escapeShellArg v}" + else + toString v; + in "bspc config ${n} ${formatValue v}"; + + formatMonitors = n: v: "bspc monitor ${n} -d ${concatStringsSep " " v}"; + + formatRules = target: directiveOptions: + let + formatDirective = n: v: + if isBool v then + (if v then "${camelToSnake n}=on" else "${camelToSnake n}=off") + else if (n == "desktop" || n == "node") then + "${camelToSnake n}='${v}'" + else + "${camelToSnake n}=${lib.strings.escapeShellArg v}"; + + directives = + filterAttrs (n: v: v != null && !(lib.strings.hasPrefix "_" n)) + directiveOptions; + directivesStr = builtins.concatStringsSep " " + (mapAttrsToList formatDirective directives); + in "bspc rule -a ${target} ${directivesStr}"; + + formatStartupPrograms = map (s: "${s} &"); + +in { + options = import ./options.nix { + inherit pkgs; + inherit lib; + }; + + config = mkIf cfg.enable { + home.packages = [ bspwm ]; + xsession.windowManager.command = let + configFile = pkgs.writeShellScript "bspwmrc" (concatStringsSep "\n" + ((mapAttrsToList formatMonitors cfg.monitors) + ++ (mapAttrsToList formatConfig cfg.settings) + ++ (mapAttrsToList formatRules cfg.rules) ++ ['' + # java gui fixes + export _JAVA_AWT_WM_NONREPARENTING=1 + bspc rule -a sun-awt-X11-XDialogPeer state=floating + ''] ++ [ cfg.extraConfig ] + ++ (formatStartupPrograms cfg.startupPrograms))); + configCmdOpt = optionalString (cfg.settings != null) "-c ${configFile}"; + in "${cfg.package}/bin/bspwm ${configCmdOpt}"; + }; +} diff --git a/home-manager/modules/services/window-managers/bspwm/options.nix b/home-manager/modules/services/window-managers/bspwm/options.nix new file mode 100644 index 00000000000..58a58a1a782 --- /dev/null +++ b/home-manager/modules/services/window-managers/bspwm/options.nix @@ -0,0 +1,214 @@ +{ pkgs, lib }: + +with lib; + +let + + rule = types.submodule { + options = { + monitor = mkOption { + type = types.nullOr types.str; + default = null; + description = "The monitor where the rule should be applied."; + example = "HDMI-0"; + }; + + desktop = mkOption { + type = types.nullOr types.str; + default = null; + description = "The desktop where the rule should be applied."; + example = "^8"; + }; + + node = mkOption { + type = types.nullOr types.str; + default = null; + description = "The node where the rule should be applied."; + example = "1"; + }; + + state = mkOption { + type = types.nullOr + (types.enum [ "tiled" "pseudo_tiled" "floating" "fullscreen" ]); + default = null; + description = "The state in which a new window should spawn."; + example = "floating"; + }; + + layer = mkOption { + type = types.nullOr (types.enum [ "below" "normal" "above" ]); + default = null; + description = "The layer where a new window should spawn."; + example = "above"; + }; + + splitDir = mkOption { + type = types.nullOr (types.enum [ "north" "west" "south" "east" ]); + default = null; + description = "The direction where the container is going to be split."; + example = "south"; + }; + + splitRatio = mkOption { + type = types.nullOr types.float; + default = null; + description = '' + The ratio between the new window and the previous existing window in + the desktop. + ''; + example = 0.65; + }; + + hidden = mkOption { + type = types.nullOr types.bool; + default = null; + description = "Whether the node should occupy any space."; + example = true; + }; + + sticky = mkOption { + type = types.nullOr types.bool; + default = null; + description = "Whether the node should stay on the focused desktop."; + example = true; + }; + + private = mkOption { + type = types.nullOr types.bool; + default = null; + description = '' + Whether the node should stay in the same tiling position and size. + ''; + example = true; + }; + + locked = mkOption { + type = types.nullOr types.bool; + default = null; + description = '' + Whether the node should ignore <command>node --close</command> + messages. + ''; + example = true; + }; + + marked = mkOption { + type = types.nullOr types.bool; + default = null; + description = "Whether the node will be marked for deferred actions."; + example = true; + }; + + center = mkOption { + type = types.nullOr types.bool; + default = null; + description = '' + Whether the node will be put in the center, in floating mode. + ''; + example = true; + }; + + follow = mkOption { + type = types.nullOr types.bool; + default = null; + description = "Whether focus should follow the node when it is moved."; + example = true; + }; + + manage = mkOption { + type = types.nullOr types.bool; + default = null; + description = '' + Whether the window should be managed by bspwm. If false, the window + will be ignored by bspwm entirely. This is useful for overlay apps, + e.g. screenshot tools. + ''; + example = true; + }; + + focus = mkOption { + type = types.nullOr types.bool; + default = null; + description = "Whether the node should gain focus on creation."; + example = true; + }; + + border = mkOption { + type = types.nullOr types.bool; + default = null; + description = "Whether the node should have border."; + example = true; + }; + }; + }; + +in { + xsession.windowManager.bspwm = { + enable = mkEnableOption "bspwm window manager."; + + package = mkOption { + type = types.package; + default = pkgs.bspwm; + defaultText = literalExample "pkgs.bspwm"; + description = "bspwm package to use."; + example = literalExample "pkgs.bspwm-unstable"; + }; + + settings = mkOption { + type = with types; + let primitive = either bool (either int (either float str)); + in attrsOf (either primitive (listOf primitive)); + default = { }; + description = "bspwm configuration"; + example = { + "border_width" = 2; + "split_ratio" = 0.52; + "gapless_monocle" = true; + }; + }; + + extraConfig = mkOption { + type = types.lines; + default = ""; + description = "Additional configuration to add."; + example = '' + bspc subscribe all > ~/bspc-report.log & + ''; + }; + + monitors = mkOption { + type = types.attrsOf (types.listOf types.str); + default = { }; + description = "bspc monitor configurations"; + example = { "HDMI-0" = [ "web" "terminal" "III" "IV" ]; }; + }; + + rules = mkOption { + type = types.attrsOf rule; + default = { }; + description = "bspc rules"; + example = literalExample '' + { + "Gimp" = { + desktop = "^8"; + state = "floating"; + follow = true; + }; + "Kupfer.py" = { + focus = true; + }; + "Screenkey" = { + manage = false; + }; + } + ''; + }; + + startupPrograms = mkOption { + type = types.listOf types.str; + default = [ ]; + description = "Programs to be executed during startup."; + example = [ "numlockx on" "tilda" ]; + }; + }; +} diff --git a/home-manager/modules/services/window-managers/i3.nix b/home-manager/modules/services/window-managers/i3.nix index 6c52ff6c335..7a4ec90b1cd 100644 --- a/home-manager/modules/services/window-managers/i3.nix +++ b/home-manager/modules/services/window-managers/i3.nix @@ -416,6 +416,18 @@ let ''; }; + workspaceAutoBackAndForth = mkOption { + type = types.bool; + default = false; + example = true; + description = '' + Assume you are on workspace "1: www" and switch to "2: IM" using + mod+2 because somebody sent you a message. You donβt need to remember + where you came from now, you can just press $mod+2 again to switch + back to "1: www". + ''; + }; + keybindings = mkOption { type = types.attrsOf (types.nullOr types.str); default = mapAttrs (n: mkOptionDefault) { @@ -444,25 +456,32 @@ let "${cfg.config.modifier}+Shift+space" = "floating toggle"; "${cfg.config.modifier}+space" = "focus mode_toggle"; - "${cfg.config.modifier}+1" = "workspace 1"; - "${cfg.config.modifier}+2" = "workspace 2"; - "${cfg.config.modifier}+3" = "workspace 3"; - "${cfg.config.modifier}+4" = "workspace 4"; - "${cfg.config.modifier}+5" = "workspace 5"; - "${cfg.config.modifier}+6" = "workspace 6"; - "${cfg.config.modifier}+7" = "workspace 7"; - "${cfg.config.modifier}+8" = "workspace 8"; - "${cfg.config.modifier}+9" = "workspace 9"; - - "${cfg.config.modifier}+Shift+1" = "move container to workspace 1"; - "${cfg.config.modifier}+Shift+2" = "move container to workspace 2"; - "${cfg.config.modifier}+Shift+3" = "move container to workspace 3"; - "${cfg.config.modifier}+Shift+4" = "move container to workspace 4"; - "${cfg.config.modifier}+Shift+5" = "move container to workspace 5"; - "${cfg.config.modifier}+Shift+6" = "move container to workspace 6"; - "${cfg.config.modifier}+Shift+7" = "move container to workspace 7"; - "${cfg.config.modifier}+Shift+8" = "move container to workspace 8"; - "${cfg.config.modifier}+Shift+9" = "move container to workspace 9"; + "${cfg.config.modifier}+a" = "focus parent"; + + "${cfg.config.modifier}+Shift+minus" = "move scratchpad"; + "${cfg.config.modifier}+minus" = "scratchpad show"; + + "${cfg.config.modifier}+1" = "workspace number 1"; + "${cfg.config.modifier}+2" = "workspace number 2"; + "${cfg.config.modifier}+3" = "workspace number 3"; + "${cfg.config.modifier}+4" = "workspace number 4"; + "${cfg.config.modifier}+5" = "workspace number 5"; + "${cfg.config.modifier}+6" = "workspace number 6"; + "${cfg.config.modifier}+7" = "workspace number 7"; + "${cfg.config.modifier}+8" = "workspace number 8"; + "${cfg.config.modifier}+9" = "workspace number 9"; + "${cfg.config.modifier}+0" = "workspace number 10"; + + "${cfg.config.modifier}+Shift+1" = "move container to workspace number 1"; + "${cfg.config.modifier}+Shift+2" = "move container to workspace number 2"; + "${cfg.config.modifier}+Shift+3" = "move container to workspace number 3"; + "${cfg.config.modifier}+Shift+4" = "move container to workspace number 4"; + "${cfg.config.modifier}+Shift+5" = "move container to workspace number 5"; + "${cfg.config.modifier}+Shift+6" = "move container to workspace number 6"; + "${cfg.config.modifier}+Shift+7" = "move container to workspace number 7"; + "${cfg.config.modifier}+Shift+8" = "move container to workspace number 8"; + "${cfg.config.modifier}+Shift+9" = "move container to workspace number 9"; + "${cfg.config.modifier}+Shift+0" = "move container to workspace number 10"; "${cfg.config.modifier}+Shift+c" = "reload"; "${cfg.config.modifier}+Shift+r" = "restart"; @@ -752,6 +771,7 @@ let focus_on_window_activation ${focus.newWindow} mouse_warping ${if focus.mouseWarping then "output" else "none"} workspace_layout ${workspaceLayout} + workspace_auto_back_and_forth ${if workspaceAutoBackAndForth then "yes" else "no"} client.focused ${colorSetStr colors.focused} client.focused_inactive ${colorSetStr colors.focusedInactive} diff --git a/home-manager/modules/services/window-managers/xmonad.nix b/home-manager/modules/services/window-managers/xmonad.nix index 6b3426b963b..7be03874a89 100644 --- a/home-manager/modules/services/window-managers/xmonad.nix +++ b/home-manager/modules/services/window-managers/xmonad.nix @@ -9,15 +9,13 @@ let xmonad = pkgs.xmonad-with-packages.override { ghcWithPackages = cfg.haskellPackages.ghcWithPackages; packages = self: - cfg.extraPackages self - ++ optionals cfg.enableContribAndExtras [ - self.xmonad-contrib self.xmonad-extras + cfg.extraPackages self ++ optionals cfg.enableContribAndExtras [ + self.xmonad-contrib + self.xmonad-extras ]; }; -in - -{ +in { options = { xsession.windowManager.xmonad = { enable = mkEnableOption "xmonad window manager"; @@ -35,7 +33,7 @@ in }; extraPackages = mkOption { - default = self: []; + default = self: [ ]; defaultText = "self: []"; example = literalExample '' haskellPackages: [ diff --git a/home-manager/modules/services/xcape.nix b/home-manager/modules/services/xcape.nix index 26115a93062..f4f77caa331 100644 --- a/home-manager/modules/services/xcape.nix +++ b/home-manager/modules/services/xcape.nix @@ -6,9 +6,7 @@ let cfg = config.services.xcape; -in - -{ +in { meta.maintainers = [ maintainers.nickhu ]; options = { @@ -27,8 +25,11 @@ in mapExpression = mkOption { type = types.attrsOf types.str; - default = {}; - example = { Shift_L = "Escape"; Control_L = "Control_L|O"; }; + default = { }; + example = { + Shift_L = "Escape"; + Control_L = "Control_L|O"; + }; description = '' The value has the grammar <literal>Key[|OtherKey]</literal>. </para> @@ -63,14 +64,13 @@ in Type = "forking"; ExecStart = "${pkgs.xcape}/bin/xcape" + optionalString (cfg.timeout != null) " -t ${toString cfg.timeout}" - + optionalString (cfg.mapExpression != {}) - " -e '${builtins.concatStringsSep ";" - (attrsets.mapAttrsToList (n: v: "${n}=${v}") cfg.mapExpression)}'"; + + optionalString (cfg.mapExpression != { }) " -e '${ + builtins.concatStringsSep ";" + (attrsets.mapAttrsToList (n: v: "${n}=${v}") cfg.mapExpression) + }'"; }; - Install = { - WantedBy = [ "graphical-session.target" ]; - }; + Install = { WantedBy = [ "graphical-session.target" ]; }; }; }; } diff --git a/home-manager/modules/services/xembed-sni-proxy.nix b/home-manager/modules/services/xembed-sni-proxy.nix index d9e5ae783f9..ff63d108b77 100644 --- a/home-manager/modules/services/xembed-sni-proxy.nix +++ b/home-manager/modules/services/xembed-sni-proxy.nix @@ -6,9 +6,7 @@ let cfg = config.services.xembed-sni-proxy; -in - -{ +in { meta.maintainers = [ maintainers.rycee ]; options = { @@ -35,9 +33,7 @@ in PartOf = [ "graphical-session.target" ]; }; - Install = { - WantedBy = [ "graphical-session.target" ]; - }; + Install = { WantedBy = [ "graphical-session.target" ]; }; Service = { Environment = "PATH=${config.home.profileDirectory}/bin"; diff --git a/home-manager/modules/services/xscreensaver.nix b/home-manager/modules/services/xscreensaver.nix index 4001c294e86..73a365aa730 100644 --- a/home-manager/modules/services/xscreensaver.nix +++ b/home-manager/modules/services/xscreensaver.nix @@ -6,9 +6,7 @@ let cfg = config.services.xscreensaver; -in - -{ +in { meta.maintainers = [ maintainers.rycee ]; options = { @@ -17,7 +15,7 @@ in settings = mkOption { type = with types; attrsOf (either bool (either int str)); - default = {}; + default = { }; example = { mode = "blank"; lock = false; @@ -38,19 +36,17 @@ in mapAttrs' (n: nameValuePair "xscreensaver.${n}") cfg.settings; systemd.user.services.xscreensaver = { - Unit = { - Description = "XScreenSaver"; - After = [ "graphical-session-pre.target" ]; - PartOf = [ "graphical-session.target" ]; - }; + Unit = { + Description = "XScreenSaver"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; - Service = { - ExecStart = "${pkgs.xscreensaver}/bin/xscreensaver -no-splash"; - }; + Service = { + ExecStart = "${pkgs.xscreensaver}/bin/xscreensaver -no-splash"; + }; - Install = { - WantedBy = [ "graphical-session.target" ]; - }; + Install = { WantedBy = [ "graphical-session.target" ]; }; }; }; } diff --git a/home-manager/modules/services/xsuspender.nix b/home-manager/modules/services/xsuspender.nix index 22a5ca536a5..2eb40f5dd34 100644 --- a/home-manager/modules/services/xsuspender.nix +++ b/home-manager/modules/services/xsuspender.nix @@ -61,7 +61,7 @@ let ''; type = types.nullOr types.str; default = null; - example = ''echo resuming ...''; + example = "echo resuming ..."; }; sendSignals = mkOption { @@ -74,7 +74,8 @@ let }; suspendSubtreePattern = mkOption { - description = "Also suspend descendant processes that match this regex."; + description = + "Also suspend descendant processes that match this regex."; type = types.nullOr types.str; default = null; }; @@ -105,9 +106,7 @@ let }; }; -in - -{ +in { meta.maintainers = [ maintainers.offline ]; options = { @@ -117,13 +116,13 @@ in defaults = mkOption { description = "XSuspender defaults."; type = xsuspenderOptions; - default = {}; + default = { }; }; rules = mkOption { description = "Attribute set of XSuspender rules."; type = types.attrsOf xsuspenderOptions; - default = {}; + default = { }; example = { Chromium = { suspendDelay = 10; @@ -147,9 +146,9 @@ in }; config = mkIf cfg.enable { - services.xsuspender.iniContent = - let - mkSection = values: filterAttrs (_: v: v != null) { + services.xsuspender.iniContent = let + mkSection = values: + filterAttrs (_: v: v != null) { match_wm_class_contains = values.matchWmClassContains; match_wm_class_group_contains = values.matchWmClassGroupContains; match_wm_name_contains = values.matchWmNameContains; @@ -164,25 +163,22 @@ in auto_suspend_on_battery = values.autoSuspendOnBattery; downclock_on_battery = values.downclockOnBattery; }; - in - { - Default = mkSection cfg.defaults; - } - // mapAttrs (_: mkSection) cfg.rules; + in { + Default = mkSection cfg.defaults; + } // mapAttrs (_: mkSection) cfg.rules; # To make the xsuspender tool available. home.packages = [ pkgs.xsuspender ]; - xdg.configFile."xsuspender.conf".text = generators.toINI {} cfg.iniContent; + xdg.configFile."xsuspender.conf".text = generators.toINI { } cfg.iniContent; systemd.user.services.xsuspender = { Unit = { Description = "XSuspender"; After = [ "graphical-session-pre.target" ]; PartOf = [ "graphical-session.target" ]; - X-Restart-Triggers = [ - "${config.xdg.configFile."xsuspender.conf".source}" - ]; + X-Restart-Triggers = + [ "${config.xdg.configFile."xsuspender.conf".source}" ]; }; Service = { @@ -190,9 +186,7 @@ in Environment = mkIf cfg.debug [ "G_MESSAGE_DEBUG=all" ]; }; - Install = { - WantedBy = [ "graphical-session.target" ]; - }; + Install = { WantedBy = [ "graphical-session.target" ]; }; }; }; } |