3 { config, lib, pkgs, ... }:
8 cfg = config.services.fwupd;
11 "fwupd/daemon.conf" = {
12 source = pkgs.writeText "daemon.conf" ''
14 DisabledDevices=${lib.concatStringsSep ";" cfg.disabledDevices}
15 DisabledPlugins=${lib.concatStringsSep ";" cfg.disabledPlugins}
18 "fwupd/uefi_capsule.conf" = {
19 source = pkgs.writeText "uefi_capsule.conf" ''
21 OverrideESPMountPoint=${config.boot.loader.efi.efiSysMountPoint}
28 mkEtcFile = n: nameValuePair n { source = "${cfg.package}/etc/${n}"; };
29 in listToAttrs (map mkEtcFile cfg.package.filesInstalledToEtc);
32 mkName = p: "pki/fwupd/${baseNameOf (toString p)}";
33 mkEtcFile = p: nameValuePair (mkName p) { source = p; };
34 in listToAttrs (map mkEtcFile cfg.extraTrustedKeys);
36 enableRemote = base: remote: {
37 "fwupd/remotes.d/${remote}.conf" = {
38 source = pkgs.runCommand "${remote}-enabled.conf" {} ''
39 sed "s,^Enabled=false,Enabled=true," \
40 "${base}/etc/fwupd/remotes.d/${remote}.conf" > "$out"
45 (configFiles: remote: configFiles // (enableRemote cfg.package remote))
49 # We cannot include the file in $out and rely on filesInstalledToEtc
50 # to install it because it would create a cyclic dependency between
51 # the outputs. We also need to enable the remote,
52 # which should not be done by default.
53 if cfg.enableTestRemote then (enableRemote cfg.package.installedTests "fwupd-tests") else {}
64 description = lib.mdDoc ''
65 Whether to enable fwupd, a DBus service that allows
66 applications to update firmware.
70 disabledDevices = mkOption {
71 type = types.listOf types.str;
73 example = [ "2082b5e0-7a64-478a-b1b2-e3404fab6dad" ];
74 description = lib.mdDoc ''
75 Allow disabling specific devices by their GUID
79 disabledPlugins = mkOption {
80 type = types.listOf types.str;
83 description = lib.mdDoc ''
84 Allow disabling specific plugins
88 extraTrustedKeys = mkOption {
89 type = types.listOf types.path;
91 example = literalExpression "[ /etc/nixos/fwupd/myfirmware.pem ]";
92 description = lib.mdDoc ''
93 Installing a public key allows firmware signed with a matching private key to be recognized as trusted, which may require less authentication to install than for untrusted files. By default trusted firmware can be upgraded (but not downgraded) without the user or administrator password. Only very few keys are installed by default.
97 extraRemotes = mkOption {
98 type = with types; listOf str;
100 example = [ "lvfs-testing" ];
101 description = lib.mdDoc ''
102 Enables extra remotes in fwupd. See `/etc/fwupd/remotes.d`.
106 enableTestRemote = mkOption {
109 description = lib.mdDoc ''
110 Whether to enable test remote. This is used by
111 [installed tests](https://github.com/fwupd/fwupd/blob/master/data/installed-tests/README.md).
116 type = types.package;
117 default = pkgs.fwupd;
118 defaultText = literalExpression "pkgs.fwupd";
119 description = lib.mdDoc ''
120 Which fwupd package to use.
127 (mkRenamedOptionModule [ "services" "fwupd" "blacklistDevices"] [ "services" "fwupd" "disabledDevices" ])
128 (mkRenamedOptionModule [ "services" "fwupd" "blacklistPlugins"] [ "services" "fwupd" "disabledPlugins" ])
131 ###### implementation
132 config = mkIf cfg.enable {
133 # Disable test related plug-ins implicitly so that users do not have to care about them.
134 services.fwupd.disabledPlugins = cfg.package.defaultDisabledPlugins;
136 environment.systemPackages = [ cfg.package ];
138 # customEtc overrides some files from the package
139 environment.etc = originalEtc // customEtc // extraTrustedKeys // remotes;
141 services.dbus.packages = [ cfg.package ];
143 services.udev.packages = [ cfg.package ];
145 systemd.packages = [ cfg.package ];
147 security.polkit.enable = true;
151 maintainers = pkgs.fwupd.meta.maintainers;