fork/home-manager
git clone https://git.julia.blue/fork/home-manager
75790441
master
1{ config , lib , pkgs , ...} : 2 3with lib ; 4 5let 6 7mergeSets = sets :lists . fold attrsets . recursiveUpdate { } sets ; 8 9yaml = pkgs . formats . yaml { }; 10 11cfg = config . services . udiskie ; 12 13in { 14meta . maintainers = [ maintainers . rycee ]; 15 16imports = [ 17( mkRemovedOptionModule [ "services" "udiskie" "sni" ] '' 18Support for Status Notifier Items is now configured globally through the 19 20xsession.preferStatusNotifierItems 21 22option. Please change to use that instead. 23'' ) 24]; 25 26options = { 27services . udiskie = { 28enable = mkEnableOption "" // { 29description = '' 30Whether to enable the udiskie mount daemon. 31 32Note, if you use NixOS then you must add 33`services.udisks2.enable = true` 34to your system configuration. Otherwise mounting will fail because 35the Udisk2 DBus service is not found. 36'' ; 37}; 38 39settings = mkOption { 40type = yaml . type ; 41default = { }; 42example = literalExpression '' 43{ 44program_options = { 45udisks_version = 2; 46tray = true; 47}; 48icon_names.media = [ "media-optical" ]; 49} 50'' ; 51description = '' 52Configuration written to 53{file}`$XDG_CONFIG_HOME/udiskie/config.yml`. 54 55See <https://github.com/coldfix/udiskie/blob/master/doc/udiskie.8.txt#configuration> 56for the full list of options. 57'' ; 58}; 59 60automount = mkOption { 61type = types . bool ; 62default = true ; 63description = "Whether to automatically mount new devices." ; 64}; 65 66notify = mkOption { 67type = types . bool ; 68default = true ; 69description = "Whether to show pop-up notifications." ; 70}; 71 72tray = mkOption { 73type = types . enum [ "always" "auto" "never" ]; 74default = "auto" ; 75description = '' 76Whether to display tray icon. 77 78The options are 79 80`always` 81: Always show tray icon. 82 83`auto` 84: Show tray icon only when there is a device available. 85 86`never` 87: Never show tray icon. 88'' ; 89}; 90}; 91}; 92 93config = mkIf config . services . udiskie . enable { 94assertions = [ 95( hm . assertions . assertPlatform "services.udiskie" pkgs platforms . linux ) 96]; 97 98xdg . configFile . "udiskie/config.yml" . source = 99yaml . generate "udiskie-config.yml" ( mergeSets [ 100{ 101program_options = { 102automount = cfg . automount ; 103tray = if cfg . tray == "always" then 104true 105else if cfg . tray == "never" then 106false 107else 108"auto" ; 109notify = cfg . notify ; 110}; 111} 112cfg . settings 113]); 114 115systemd . user . services . udiskie = { 116Unit = { 117Description = "udiskie mount daemon" ; 118Requires = lib . optional ( cfg . tray != "never" ) "tray.target" ; 119After = [ "graphical-session-pre.target" ] 120++ lib . optional ( cfg . tray != "never" ) "tray.target" ; 121PartOf = [ "graphical-session.target" ]; 122}; 123 124Service . ExecStart = toString ([ " ${ pkgs . udiskie } /bin/udiskie" ] 125++ optional config . xsession . preferStatusNotifierItems "--appindicator" ); 126 127Install . WantedBy = [ "graphical-session.target" ]; 128}; 129}; 130}