From e4c359d8b9b2cdb3b9b1bec4f75567ba6e6bf969 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 2 Oct 2017 13:25:31 +0200 Subject: [PATCH] udiskie: add a few configuration options The new options allow some control over automounting, notifications, and the tray icon. This commit also changes the defaults to automatically mount new devices, udiskie was previously told not to automount. The change in behavior is to closer match the default options. --- modules/misc/news.nix | 14 +++++++++ modules/services/udiskie.nix | 59 ++++++++++++++++++++++++++++++++++-- 2 files changed, 70 insertions(+), 3 deletions(-) diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 3c3058701..5bbb6fa70 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -274,6 +274,20 @@ in 'programs.vim.settings.shiftwidth'. ''; } + + { + time = "2017-10-02T11:15:03+00:00"; + condition = config.services.udiskie.enable; + message = '' + The udiskie service now defaults to automatically mounting + new devices. Previous behavior was to not automatically + mount. To restore this previous behavior add + + services.udiskie.automount = false; + + to your Home Manager configuration. + ''; + } ]; }; } diff --git a/modules/services/udiskie.nix b/modules/services/udiskie.nix index a9451c325..e4d4f5279 100644 --- a/modules/services/udiskie.nix +++ b/modules/services/udiskie.nix @@ -2,25 +2,78 @@ with lib; +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}) + ] + ); + +in + { meta.maintainers = [ maintainers.rycee ]; options = { services.udiskie = { - enable = mkEnableOption "Udiskie mount daemon"; + enable = mkEnableOption "udiskie mount daemon"; + + automount = mkOption { + type = types.bool; + default = true; + description = "Whether to automatically mount new devices."; + }; + + notify = mkOption { + type = types.bool; + default = true; + description = "Whether to show pop-up notifications."; + }; + + tray = mkOption { + type = types.enum [ "always" "auto" "never" ]; + default = "auto"; + description = '' + Whether to display tray icon. + + The options are + + + always + Always show tray icon. + + + auto + + Show tray icon only when there is a device available. + + + + never + Never show tray icon. + + + ''; + }; }; }; config = mkIf config.services.udiskie.enable { systemd.user.services.udiskie = { Unit = { - Description = "Udiskie mount daemon"; + Description = "udiskie mount daemon"; After = [ "graphical-session-pre.target" ]; PartOf = [ "graphical-session.target" ]; }; Service = { - ExecStart = "${pkgs.pythonPackages.udiskie}/bin/udiskie -2 -A -n -s"; + ExecStart = "${pkgs.pythonPackages.udiskie}/bin/udiskie -2 ${commandArgs}"; }; Install = {