udiskie: add option settings
Adds option settings, which writes settings to .config/udiskie/config.yml. Note, the option takes precedence against other options like notify, automount or tray if they are configured in settings.program_options.
This commit is contained in:
parent
be3adf9920
commit
3bf16c0fd1
|
@ -4,17 +4,11 @@ with lib;
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
cfg = config.services.udiskie;
|
mergeSets = sets: lists.fold attrsets.recursiveUpdate { } sets;
|
||||||
|
|
||||||
commandArgs = concatStringsSep " " (map (opt: "-" + opt) [
|
yaml = pkgs.formats.yaml { };
|
||||||
(if cfg.automount then "a" else "A")
|
|
||||||
(if cfg.notify then "n" else "N")
|
cfg = config.services.udiskie;
|
||||||
({
|
|
||||||
always = "t";
|
|
||||||
auto = "s";
|
|
||||||
never = "T";
|
|
||||||
}.${cfg.tray})
|
|
||||||
] ++ optional config.xsession.preferStatusNotifierItems "--appindicator");
|
|
||||||
|
|
||||||
in {
|
in {
|
||||||
meta.maintainers = [ maintainers.rycee ];
|
meta.maintainers = [ maintainers.rycee ];
|
||||||
|
@ -33,6 +27,27 @@ in {
|
||||||
services.udiskie = {
|
services.udiskie = {
|
||||||
enable = mkEnableOption "udiskie mount daemon";
|
enable = mkEnableOption "udiskie mount daemon";
|
||||||
|
|
||||||
|
settings = mkOption {
|
||||||
|
type = yaml.type;
|
||||||
|
default = { };
|
||||||
|
example = literalExpression ''
|
||||||
|
{
|
||||||
|
program_options = {
|
||||||
|
udisks_version = 2;
|
||||||
|
tray = true;
|
||||||
|
};
|
||||||
|
icon_names.media = [ "media-optical" ];
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
description = ''
|
||||||
|
Configuration written to
|
||||||
|
<filename>$XDG_CONFIG_HOME/udiskie/config.toml</filename>.
|
||||||
|
</para><para>
|
||||||
|
See <link xlink:href="https://github.com/coldfix/udiskie/blob/master/doc/udiskie.8.txt#configuration" />
|
||||||
|
for the full list of options.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
automount = mkOption {
|
automount = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = true;
|
default = true;
|
||||||
|
@ -74,6 +89,23 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf config.services.udiskie.enable {
|
config = mkIf config.services.udiskie.enable {
|
||||||
|
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
|
||||||
|
]);
|
||||||
|
|
||||||
systemd.user.services.udiskie = {
|
systemd.user.services.udiskie = {
|
||||||
Unit = {
|
Unit = {
|
||||||
Description = "udiskie mount daemon";
|
Description = "udiskie mount daemon";
|
||||||
|
@ -82,9 +114,10 @@ in {
|
||||||
PartOf = [ "graphical-session.target" ];
|
PartOf = [ "graphical-session.target" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
Service = { ExecStart = "${pkgs.udiskie}/bin/udiskie ${commandArgs}"; };
|
Service.ExecStart = toString ([ "${pkgs.udiskie}/bin/udiskie" ]
|
||||||
|
++ optional config.xsession.preferStatusNotifierItems "--appindicator");
|
||||||
|
|
||||||
Install = { WantedBy = [ "graphical-session.target" ]; };
|
Install.WantedBy = [ "graphical-session.target" ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue