nixos/udisks2: add package option

This commit is contained in:
Marco Rebhan 2024-03-04 22:01:04 +01:00
parent 8a4836def3
commit 3b12ef2f6f
No known key found for this signature in database

View File

@ -18,6 +18,8 @@ in
enable = lib.mkEnableOption "udisks2, a DBus service that allows applications to query and manipulate storage devices";
package = lib.mkPackageOption pkgs "udisks2" {};
mountOnMedia = lib.mkOption {
type = lib.types.bool;
default = false;
@ -67,11 +69,11 @@ in
config = lib.mkIf config.services.udisks2.enable {
environment.systemPackages = [ pkgs.udisks2 ];
environment.systemPackages = [ cfg.package ];
environment.etc = (lib.mapAttrs' (name: value: lib.nameValuePair "udisks2/${name}" { source = value; } ) configFiles) // (
let
libblockdev = pkgs.udisks2.libblockdev;
libblockdev = cfg.package.libblockdev;
majorVer = lib.versions.major libblockdev.version;
in {
# We need to make sure /etc/libblockdev/@major_ver@/conf.d is populated to avoid
@ -82,18 +84,18 @@ in
security.polkit.enable = true;
services.dbus.packages = [ pkgs.udisks2 ];
services.dbus.packages = [ cfg.package ];
systemd.tmpfiles.rules = [ "d /var/lib/udisks2 0755 root root -" ]
++ lib.optional cfg.mountOnMedia "D! /media 0755 root root -";
services.udev.packages = [ pkgs.udisks2 ];
services.udev.packages = [ cfg.package ];
services.udev.extraRules = lib.optionalString cfg.mountOnMedia ''
ENV{ID_FS_USAGE}=="filesystem", ENV{UDISKS_FILESYSTEM_SHARED}="1"
'';
systemd.packages = [ pkgs.udisks2 ];
systemd.packages = [ cfg.package ];
};
}