2017-10-09 14:35:52 +01:00
|
|
|
# fwupd daemon.
|
|
|
|
|
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.fwupd;
|
2020-06-16 09:41:57 +01:00
|
|
|
|
|
|
|
customEtc = {
|
|
|
|
"fwupd/daemon.conf" = {
|
|
|
|
source = pkgs.writeText "daemon.conf" ''
|
|
|
|
[fwupd]
|
2020-10-27 06:29:44 +00:00
|
|
|
DisabledDevices=${lib.concatStringsSep ";" cfg.disabledDevices}
|
|
|
|
DisabledPlugins=${lib.concatStringsSep ";" cfg.disabledPlugins}
|
2020-06-16 09:41:57 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
"fwupd/uefi.conf" = {
|
|
|
|
source = pkgs.writeText "uefi.conf" ''
|
|
|
|
[uefi]
|
|
|
|
OverrideESPMountPoint=${config.boot.loader.efi.efiSysMountPoint}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2017-10-09 14:35:52 +01:00
|
|
|
originalEtc =
|
|
|
|
let
|
2019-08-29 16:22:24 +01:00
|
|
|
mkEtcFile = n: nameValuePair n { source = "${cfg.package}/etc/${n}"; };
|
|
|
|
in listToAttrs (map mkEtcFile cfg.package.filesInstalledToEtc);
|
2017-11-07 18:03:10 +00:00
|
|
|
extraTrustedKeys =
|
|
|
|
let
|
|
|
|
mkName = p: "pki/fwupd/${baseNameOf (toString p)}";
|
|
|
|
mkEtcFile = p: nameValuePair (mkName p) { source = p; };
|
|
|
|
in listToAttrs (map mkEtcFile cfg.extraTrustedKeys);
|
2019-01-27 23:15:00 +00:00
|
|
|
|
|
|
|
# We cannot include the file in $out and rely on filesInstalledToEtc
|
|
|
|
# to install it because it would create a cyclic dependency between
|
|
|
|
# the outputs. We also need to enable the remote,
|
|
|
|
# which should not be done by default.
|
|
|
|
testRemote = if cfg.enableTestRemote then {
|
|
|
|
"fwupd/remotes.d/fwupd-tests.conf" = {
|
|
|
|
source = pkgs.runCommand "fwupd-tests-enabled.conf" {} ''
|
|
|
|
sed "s,^Enabled=false,Enabled=true," \
|
2019-08-29 16:22:24 +01:00
|
|
|
"${cfg.package.installedTests}/etc/fwupd/remotes.d/fwupd-tests.conf" > "$out"
|
2019-01-27 23:15:00 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
} else {};
|
2017-10-09 14:35:52 +01:00
|
|
|
in {
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
options = {
|
|
|
|
services.fwupd = {
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
2017-11-25 06:44:14 +00:00
|
|
|
default = false;
|
2017-10-09 14:35:52 +01:00
|
|
|
description = ''
|
|
|
|
Whether to enable fwupd, a DBus service that allows
|
|
|
|
applications to update firmware.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2020-10-27 06:29:44 +00:00
|
|
|
disabledDevices = mkOption {
|
2019-08-08 21:48:27 +01:00
|
|
|
type = types.listOf types.str;
|
2017-10-09 14:35:52 +01:00
|
|
|
default = [];
|
|
|
|
example = [ "2082b5e0-7a64-478a-b1b2-e3404fab6dad" ];
|
|
|
|
description = ''
|
2020-10-27 06:29:44 +00:00
|
|
|
Allow disabling specific devices by their GUID
|
2017-10-09 14:35:52 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2020-10-27 06:29:44 +00:00
|
|
|
disabledPlugins = mkOption {
|
2019-08-08 21:48:27 +01:00
|
|
|
type = types.listOf types.str;
|
2020-02-06 18:31:59 +00:00
|
|
|
default = [];
|
2017-10-09 14:35:52 +01:00
|
|
|
example = [ "udev" ];
|
|
|
|
description = ''
|
2020-10-27 06:29:44 +00:00
|
|
|
Allow disabling specific plugins
|
2017-10-09 14:35:52 +01:00
|
|
|
'';
|
|
|
|
};
|
2017-11-07 18:03:10 +00:00
|
|
|
|
|
|
|
extraTrustedKeys = mkOption {
|
|
|
|
type = types.listOf types.path;
|
|
|
|
default = [];
|
2021-10-03 17:06:03 +01:00
|
|
|
example = literalExpression "[ /etc/nixos/fwupd/myfirmware.pem ]";
|
2017-11-07 18:03:10 +00:00
|
|
|
description = ''
|
|
|
|
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.
|
|
|
|
'';
|
|
|
|
};
|
2019-01-27 23:15:00 +00:00
|
|
|
|
|
|
|
enableTestRemote = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Whether to enable test remote. This is used by
|
2019-11-18 17:44:54 +00:00
|
|
|
<link xlink:href="https://github.com/fwupd/fwupd/blob/master/data/installed-tests/README.md">installed tests</link>.
|
2019-01-27 23:15:00 +00:00
|
|
|
'';
|
|
|
|
};
|
2019-08-29 16:22:24 +01:00
|
|
|
|
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.fwupd;
|
2021-10-03 17:06:03 +01:00
|
|
|
defaultText = literalExpression "pkgs.fwupd";
|
2019-08-29 16:22:24 +01:00
|
|
|
description = ''
|
|
|
|
Which fwupd package to use.
|
|
|
|
'';
|
|
|
|
};
|
2017-10-09 14:35:52 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-10-27 06:29:44 +00:00
|
|
|
imports = [
|
|
|
|
(mkRenamedOptionModule [ "services" "fwupd" "blacklistDevices"] [ "services" "fwupd" "disabledDevices" ])
|
|
|
|
(mkRenamedOptionModule [ "services" "fwupd" "blacklistPlugins"] [ "services" "fwupd" "disabledPlugins" ])
|
|
|
|
];
|
2017-10-09 14:35:52 +01:00
|
|
|
|
|
|
|
###### implementation
|
|
|
|
config = mkIf cfg.enable {
|
2020-02-06 18:31:59 +00:00
|
|
|
# Disable test related plug-ins implicitly so that users do not have to care about them.
|
2020-10-27 06:29:44 +00:00
|
|
|
services.fwupd.disabledPlugins = cfg.package.defaultDisabledPlugins;
|
2020-02-06 18:31:59 +00:00
|
|
|
|
2019-08-29 16:22:24 +01:00
|
|
|
environment.systemPackages = [ cfg.package ];
|
2017-10-09 14:35:52 +01:00
|
|
|
|
2020-06-16 09:41:57 +01:00
|
|
|
# customEtc overrides some files from the package
|
|
|
|
environment.etc = originalEtc // customEtc // extraTrustedKeys // testRemote;
|
2017-10-09 14:35:52 +01:00
|
|
|
|
2019-08-29 16:22:24 +01:00
|
|
|
services.dbus.packages = [ cfg.package ];
|
2017-10-09 14:35:52 +01:00
|
|
|
|
2019-08-29 16:22:24 +01:00
|
|
|
services.udev.packages = [ cfg.package ];
|
2017-10-09 14:35:52 +01:00
|
|
|
|
2019-08-29 16:22:24 +01:00
|
|
|
systemd.packages = [ cfg.package ];
|
2017-10-09 14:35:52 +01:00
|
|
|
};
|
2018-02-14 01:10:12 +00:00
|
|
|
|
|
|
|
meta = {
|
2018-06-30 14:49:44 +01:00
|
|
|
maintainers = pkgs.fwupd.meta.maintainers;
|
2018-02-14 01:10:12 +00:00
|
|
|
};
|
2017-10-09 14:35:52 +01:00
|
|
|
}
|