2017-01-07 19:16:26 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
2017-10-02 13:25:31 +02:00
|
|
|
let
|
|
|
|
|
2022-06-05 13:39:26 +02:00
|
|
|
mergeSets = sets: lists.fold attrsets.recursiveUpdate { } sets;
|
|
|
|
|
|
|
|
yaml = pkgs.formats.yaml { };
|
2017-10-02 13:25:31 +02:00
|
|
|
|
2022-06-05 13:39:26 +02:00
|
|
|
cfg = config.services.udiskie;
|
2020-02-02 00:39:17 +01:00
|
|
|
|
|
|
|
in {
|
2017-09-26 23:40:31 +02:00
|
|
|
meta.maintainers = [ maintainers.rycee ];
|
|
|
|
|
2018-07-24 12:59:11 +02:00
|
|
|
imports = [
|
|
|
|
(mkRemovedOptionModule [ "services" "udiskie" "sni" ] ''
|
|
|
|
Support for Status Notifier Items is now configured globally through the
|
|
|
|
|
|
|
|
xsession.preferStatusNotifierItems
|
|
|
|
|
|
|
|
option. Please change to use that instead.
|
|
|
|
'')
|
|
|
|
];
|
|
|
|
|
2017-01-07 19:16:26 +01:00
|
|
|
options = {
|
|
|
|
services.udiskie = {
|
2023-07-01 09:48:09 +02:00
|
|
|
enable = mkEnableOption (lib.mdDoc "") // {
|
|
|
|
description = lib.mdDoc ''
|
2022-11-17 21:27:03 +01:00
|
|
|
Whether to enable the udiskie mount daemon.
|
2023-07-01 09:48:09 +02:00
|
|
|
|
2022-11-17 21:27:03 +01:00
|
|
|
Note, if you use NixOS then you must add
|
2023-07-01 09:48:09 +02:00
|
|
|
`services.udisks2.enable = true`
|
2022-11-17 21:27:03 +01:00
|
|
|
to your system configuration. Otherwise mounting will fail because
|
|
|
|
the Udisk2 DBus service is not found.
|
|
|
|
'';
|
|
|
|
};
|
2017-10-02 13:25:31 +02:00
|
|
|
|
2022-06-05 13:39:26 +02:00
|
|
|
settings = mkOption {
|
|
|
|
type = yaml.type;
|
|
|
|
default = { };
|
|
|
|
example = literalExpression ''
|
|
|
|
{
|
|
|
|
program_options = {
|
|
|
|
udisks_version = 2;
|
|
|
|
tray = true;
|
|
|
|
};
|
|
|
|
icon_names.media = [ "media-optical" ];
|
|
|
|
}
|
|
|
|
'';
|
2023-07-01 01:30:13 +02:00
|
|
|
description = lib.mdDoc ''
|
2022-06-05 13:39:26 +02:00
|
|
|
Configuration written to
|
2023-07-01 01:30:13 +02:00
|
|
|
{file}`$XDG_CONFIG_HOME/udiskie/config.yml`.
|
|
|
|
|
|
|
|
See <https://github.com/coldfix/udiskie/blob/master/doc/udiskie.8.txt#configuration>
|
2022-06-05 13:39:26 +02:00
|
|
|
for the full list of options.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2017-10-02 13:25:31 +02:00
|
|
|
automount = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
2023-07-01 01:30:13 +02:00
|
|
|
description = lib.mdDoc "Whether to automatically mount new devices.";
|
2017-10-02 13:25:31 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
notify = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
2023-07-01 01:30:13 +02:00
|
|
|
description = lib.mdDoc "Whether to show pop-up notifications.";
|
2017-10-02 13:25:31 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
tray = mkOption {
|
|
|
|
type = types.enum [ "always" "auto" "never" ];
|
|
|
|
default = "auto";
|
2023-07-01 02:40:42 +02:00
|
|
|
description = lib.mdDoc ''
|
2017-10-02 13:25:31 +02:00
|
|
|
Whether to display tray icon.
|
2023-07-01 02:40:42 +02:00
|
|
|
|
2017-10-02 13:25:31 +02:00
|
|
|
The options are
|
2023-07-01 02:40:42 +02:00
|
|
|
|
|
|
|
`always`
|
|
|
|
: Always show tray icon.
|
|
|
|
|
|
|
|
`auto`
|
|
|
|
: Show tray icon only when there is a device available.
|
|
|
|
|
|
|
|
`never`
|
|
|
|
: Never show tray icon.
|
2017-10-02 13:25:31 +02:00
|
|
|
'';
|
|
|
|
};
|
2017-01-07 19:16:26 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf config.services.udiskie.enable {
|
2022-04-24 16:25:54 +02:00
|
|
|
assertions = [
|
|
|
|
(hm.assertions.assertPlatform "services.udiskie" pkgs platforms.linux)
|
|
|
|
];
|
|
|
|
|
2022-06-05 13:39:26 +02:00
|
|
|
xdg.configFile."udiskie/config.yml".source =
|
|
|
|
yaml.generate "udiskie-config.yml" (mergeSets [
|
|
|
|
{
|
|
|
|
program_options = {
|
|
|
|
automount = cfg.automount;
|
|
|
|
tray = if cfg.tray == "always" then
|
|
|
|
true
|
|
|
|
else if cfg.tray == "never" then
|
|
|
|
false
|
|
|
|
else
|
|
|
|
"auto";
|
|
|
|
notify = cfg.notify;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
cfg.settings
|
|
|
|
]);
|
|
|
|
|
2017-01-07 19:16:26 +01:00
|
|
|
systemd.user.services.udiskie = {
|
2020-02-02 00:39:17 +01:00
|
|
|
Unit = {
|
|
|
|
Description = "udiskie mount daemon";
|
2022-08-22 16:40:03 +02:00
|
|
|
Requires = lib.optional (cfg.tray != "never") "tray.target";
|
|
|
|
After = [ "graphical-session-pre.target" ]
|
|
|
|
++ lib.optional (cfg.tray != "never") "tray.target";
|
2020-02-02 00:39:17 +01:00
|
|
|
PartOf = [ "graphical-session.target" ];
|
|
|
|
};
|
2017-01-07 19:16:26 +01:00
|
|
|
|
2022-06-05 13:39:26 +02:00
|
|
|
Service.ExecStart = toString ([ "${pkgs.udiskie}/bin/udiskie" ]
|
|
|
|
++ optional config.xsession.preferStatusNotifierItems "--appindicator");
|
2017-01-07 19:16:26 +01:00
|
|
|
|
2022-06-05 13:39:26 +02:00
|
|
|
Install.WantedBy = [ "graphical-session.target" ];
|
2017-01-07 19:16:26 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|