mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-10 19:55:41 +03:00

After final improvements to the official formatter implementation, this commit now performs the first treewide reformat of Nix files using it. This is part of the implementation of RFC 166. Only "inactive" files are reformatted, meaning only files that aren't being touched by any PR with activity in the past 2 months. This is to avoid conflicts for PRs that might soon be merged. Later we can do a full treewide reformat to get the rest, which should not cause as many conflicts. A CI check has already been running for some time to ensure that new and already-formatted files are formatted, so the files being reformatted here should also stay formatted. This commit was automatically created and can be verified using nix-builda08b3a4d19
.tar.gz \ --argstr baseRevb32a094368
result/bin/apply-formatting $NIXPKGS_PATH
114 lines
3.3 KiB
Nix
114 lines
3.3 KiB
Nix
# Udisks daemon.
|
|
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
let
|
|
cfg = config.services.udisks2;
|
|
settingsFormat = pkgs.formats.ini {
|
|
listToValue = lib.concatMapStringsSep "," (lib.generators.mkValueStringDefault { });
|
|
};
|
|
configFiles = lib.mapAttrs (name: value: (settingsFormat.generate name value)) (
|
|
lib.mapAttrs' (name: value: lib.nameValuePair name value) config.services.udisks2.settings
|
|
);
|
|
in
|
|
|
|
{
|
|
|
|
###### interface
|
|
|
|
options = {
|
|
|
|
services.udisks2 = {
|
|
|
|
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;
|
|
description = ''
|
|
When enabled, instructs udisks2 to mount removable drives under `/media/` directory, instead of the
|
|
default, ACL-controlled `/run/media/$USER/`. Since `/media/` is not mounted as tmpfs by default, it
|
|
requires cleanup to get rid of stale mountpoints; enabling this option will take care of this at boot.
|
|
'';
|
|
};
|
|
|
|
settings = lib.mkOption rec {
|
|
type = lib.types.attrsOf settingsFormat.type;
|
|
apply = lib.recursiveUpdate default;
|
|
default = {
|
|
"udisks2.conf" = {
|
|
udisks2 = {
|
|
modules = [ "*" ];
|
|
modules_load_preference = "ondemand";
|
|
};
|
|
defaults = {
|
|
encryption = "luks2";
|
|
};
|
|
};
|
|
};
|
|
example = lib.literalExpression ''
|
|
{
|
|
"WDC-WD10EZEX-60M2NA0-WD-WCC3F3SJ0698.conf" = {
|
|
ATA = {
|
|
StandbyTimeout = 50;
|
|
};
|
|
};
|
|
};
|
|
'';
|
|
description = ''
|
|
Options passed to udisksd.
|
|
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.
|
|
'';
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
###### implementation
|
|
|
|
config = lib.mkIf config.services.udisks2.enable {
|
|
|
|
environment.systemPackages = [ cfg.package ];
|
|
|
|
environment.etc =
|
|
(lib.mapAttrs' (name: value: lib.nameValuePair "udisks2/${name}" { source = value; }) configFiles)
|
|
// (
|
|
let
|
|
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
|
|
# warnings
|
|
"libblockdev/${majorVer}/conf.d/00-default.cfg".source =
|
|
"${libblockdev}/etc/libblockdev/${majorVer}/conf.d/00-default.cfg";
|
|
"libblockdev/${majorVer}/conf.d/10-lvm-dbus.cfg".source =
|
|
"${libblockdev}/etc/libblockdev/${majorVer}/conf.d/10-lvm-dbus.cfg";
|
|
}
|
|
);
|
|
|
|
security.polkit.enable = true;
|
|
|
|
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 = [ cfg.package ];
|
|
|
|
services.udev.extraRules = lib.optionalString cfg.mountOnMedia ''
|
|
ENV{ID_FS_USAGE}=="filesystem", ENV{UDISKS_FILESYSTEM_SHARED}="1"
|
|
'';
|
|
|
|
systemd.packages = [ cfg.package ];
|
|
};
|
|
|
|
}
|