2020-04-24 23:36:52 +00:00
|
|
|
# Udisks daemon.
|
|
|
|
|
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
2022-04-15 01:41:22 +00:00
|
|
|
let
|
|
|
|
settingsFormat = pkgs.formats.ini {
|
|
|
|
listToValue = concatMapStringsSep "," (generators.mkValueStringDefault {});
|
|
|
|
};
|
|
|
|
configFiles = mapAttrs (name: value: (settingsFormat.generate name value)) (mapAttrs' (name: value: nameValuePair name value ) config.services.udisks2.settings);
|
|
|
|
in
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
services.udisks2 = {
|
|
|
|
|
2022-09-09 14:08:57 +00:00
|
|
|
enable = mkEnableOption (lib.mdDoc "udisks2, a DBus service that allows applications to query and manipulate storage devices.");
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-04-15 01:41:22 +00:00
|
|
|
settings = mkOption rec {
|
|
|
|
type = types.attrsOf settingsFormat.type;
|
|
|
|
apply = recursiveUpdate default;
|
|
|
|
default = {
|
|
|
|
"udisks2.conf" = {
|
|
|
|
udisks2 = {
|
|
|
|
modules = [ "*" ];
|
|
|
|
modules_load_preference = "ondemand";
|
|
|
|
};
|
|
|
|
defaults = {
|
|
|
|
encryption = "luks2";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
example = literalExpression ''
|
|
|
|
{
|
|
|
|
"WDC-WD10EZEX-60M2NA0-WD-WCC3F3SJ0698.conf" = {
|
|
|
|
ATA = {
|
|
|
|
StandbyTimeout = 50;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
'';
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2022-04-15 01:41:22 +00:00
|
|
|
Options passed to udisksd.
|
2022-08-12 12:06:08 +00:00
|
|
|
See [here](http://manpages.ubuntu.com/manpages/latest/en/man5/udisks2.conf.5.html) and
|
|
|
|
drive configuration in [here](http://manpages.ubuntu.com/manpages/latest/en/man8/udisks.8.html) for supported options.
|
2022-04-15 01:41:22 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf config.services.udisks2.enable {
|
|
|
|
|
|
|
|
environment.systemPackages = [ pkgs.udisks2 ];
|
|
|
|
|
2022-11-21 17:40:18 +00:00
|
|
|
environment.etc = (mapAttrs' (name: value: nameValuePair "udisks2/${name}" { source = value; } ) configFiles) // {
|
|
|
|
# We need to make sure /etc/libblockdev/conf.d is populated to avoid
|
|
|
|
# warnings
|
|
|
|
"libblockdev/conf.d/00-default.cfg".source = "${pkgs.libblockdev}/etc/libblockdev/conf.d/00-default.cfg";
|
|
|
|
"libblockdev/conf.d/10-lvm-dbus.cfg".source = "${pkgs.libblockdev}/etc/libblockdev/conf.d/10-lvm-dbus.cfg";
|
|
|
|
};
|
2022-04-15 01:41:22 +00:00
|
|
|
|
2022-03-05 16:20:37 +00:00
|
|
|
security.polkit.enable = true;
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
services.dbus.packages = [ pkgs.udisks2 ];
|
|
|
|
|
|
|
|
systemd.tmpfiles.rules = [ "d /var/lib/udisks2 0755 root root -" ];
|
|
|
|
|
|
|
|
services.udev.packages = [ pkgs.udisks2 ];
|
|
|
|
|
|
|
|
systemd.packages = [ pkgs.udisks2 ];
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|