at 23.05-pre 2.3 kB view raw
1# Udisks daemon. 2 3{ config, lib, pkgs, ... }: 4 5with lib; 6 7let 8 settingsFormat = pkgs.formats.ini { 9 listToValue = concatMapStringsSep "," (generators.mkValueStringDefault {}); 10 }; 11 configFiles = mapAttrs (name: value: (settingsFormat.generate name value)) (mapAttrs' (name: value: nameValuePair name value ) config.services.udisks2.settings); 12in 13 14{ 15 16 ###### interface 17 18 options = { 19 20 services.udisks2 = { 21 22 enable = mkEnableOption (lib.mdDoc "udisks2, a DBus service that allows applications to query and manipulate storage devices."); 23 24 settings = mkOption rec { 25 type = types.attrsOf settingsFormat.type; 26 apply = recursiveUpdate default; 27 default = { 28 "udisks2.conf" = { 29 udisks2 = { 30 modules = [ "*" ]; 31 modules_load_preference = "ondemand"; 32 }; 33 defaults = { 34 encryption = "luks2"; 35 }; 36 }; 37 }; 38 example = literalExpression '' 39 { 40 "WDC-WD10EZEX-60M2NA0-WD-WCC3F3SJ0698.conf" = { 41 ATA = { 42 StandbyTimeout = 50; 43 }; 44 }; 45 }; 46 ''; 47 description = lib.mdDoc '' 48 Options passed to udisksd. 49 See [here](http://manpages.ubuntu.com/manpages/latest/en/man5/udisks2.conf.5.html) and 50 drive configuration in [here](http://manpages.ubuntu.com/manpages/latest/en/man8/udisks.8.html) for supported options. 51 ''; 52 }; 53 54 }; 55 56 }; 57 58 59 ###### implementation 60 61 config = mkIf config.services.udisks2.enable { 62 63 environment.systemPackages = [ pkgs.udisks2 ]; 64 65 environment.etc = (mapAttrs' (name: value: nameValuePair "udisks2/${name}" { source = value; } ) configFiles) // { 66 # We need to make sure /etc/libblockdev/conf.d is populated to avoid 67 # warnings 68 "libblockdev/conf.d/00-default.cfg".source = "${pkgs.libblockdev}/etc/libblockdev/conf.d/00-default.cfg"; 69 "libblockdev/conf.d/10-lvm-dbus.cfg".source = "${pkgs.libblockdev}/etc/libblockdev/conf.d/10-lvm-dbus.cfg"; 70 }; 71 72 security.polkit.enable = true; 73 74 services.dbus.packages = [ pkgs.udisks2 ]; 75 76 systemd.tmpfiles.rules = [ "d /var/lib/udisks2 0755 root root -" ]; 77 78 services.udev.packages = [ pkgs.udisks2 ]; 79 80 systemd.packages = [ pkgs.udisks2 ]; 81 }; 82 83}