2020-02-06 18:31:59 +00:00
|
|
|
# Updating? Keep $out/etc synchronized with passthru keys
|
2019-01-27 23:15:00 +00:00
|
|
|
|
2021-01-11 07:54:33 +00:00
|
|
|
{ lib, stdenv
|
2019-08-28 13:05:09 +00:00
|
|
|
, fetchurl
|
2020-10-27 06:29:44 +00:00
|
|
|
, fetchFromGitHub
|
2019-08-28 13:05:09 +00:00
|
|
|
, substituteAll
|
|
|
|
, gtk-doc
|
2020-09-12 11:12:14 +00:00
|
|
|
, pkg-config
|
2019-08-28 13:05:09 +00:00
|
|
|
, gobject-introspection
|
2020-09-12 11:26:44 +00:00
|
|
|
, gettext
|
2019-08-28 13:05:09 +00:00
|
|
|
, libgudev
|
|
|
|
, polkit
|
|
|
|
, libxmlb
|
|
|
|
, gusb
|
|
|
|
, sqlite
|
|
|
|
, libarchive
|
2020-12-08 14:05:15 +00:00
|
|
|
, curl
|
2019-08-28 13:05:09 +00:00
|
|
|
, help2man
|
2020-04-15 19:22:43 +00:00
|
|
|
, libjcat
|
2019-08-28 13:05:09 +00:00
|
|
|
, libxslt
|
|
|
|
, elfutils
|
|
|
|
, libsmbios
|
|
|
|
, efivar
|
|
|
|
, gnu-efi
|
|
|
|
, valgrind
|
|
|
|
, meson
|
|
|
|
, libuuid
|
|
|
|
, colord
|
|
|
|
, docbook_xml_dtd_43
|
2020-09-12 11:12:14 +00:00
|
|
|
, docbook-xsl-nons
|
2019-08-28 13:05:09 +00:00
|
|
|
, ninja
|
|
|
|
, gcab
|
2021-02-01 20:21:41 +00:00
|
|
|
, gnutls
|
2019-08-28 13:05:09 +00:00
|
|
|
, python3
|
|
|
|
, wrapGAppsHook
|
|
|
|
, json-glib
|
|
|
|
, bash-completion
|
|
|
|
, shared-mime-info
|
|
|
|
, umockdev
|
|
|
|
, vala
|
|
|
|
, makeFontsConf
|
|
|
|
, freefont_ttf
|
|
|
|
, cairo
|
|
|
|
, freetype
|
|
|
|
, fontconfig
|
|
|
|
, pango
|
2019-11-18 17:44:54 +00:00
|
|
|
, tpm2-tss
|
2019-08-28 13:05:09 +00:00
|
|
|
, bubblewrap
|
|
|
|
, efibootmgr
|
|
|
|
, flashrom
|
|
|
|
, tpm2-tools
|
2019-08-28 12:37:44 +00:00
|
|
|
, nixosTests
|
2020-06-16 08:41:57 +00:00
|
|
|
, runCommand
|
2019-08-28 13:05:09 +00:00
|
|
|
}:
|
|
|
|
|
2017-09-18 13:14:21 +00:00
|
|
|
let
|
2019-08-28 13:05:09 +00:00
|
|
|
python = python3.withPackages (p: with p; [
|
|
|
|
pygobject3
|
|
|
|
pycairo
|
|
|
|
pillow
|
2019-09-09 20:09:05 +00:00
|
|
|
setuptools
|
2019-08-28 13:05:09 +00:00
|
|
|
]);
|
|
|
|
|
|
|
|
installedTestsPython = python3.withPackages (p: with p; [
|
|
|
|
pygobject3
|
|
|
|
requests
|
|
|
|
]);
|
2018-06-02 15:47:34 +00:00
|
|
|
|
2019-08-07 02:00:45 +00:00
|
|
|
isx86 = stdenv.isx86_64 || stdenv.isi686;
|
|
|
|
|
|
|
|
# Dell isn't supported on Aarch64
|
|
|
|
haveDell = isx86;
|
|
|
|
|
|
|
|
# only redfish for x86_64
|
|
|
|
haveRedfish = stdenv.isx86_64;
|
|
|
|
|
2021-02-16 01:50:46 +00:00
|
|
|
# only use msr if x86 (requires cpuid)
|
|
|
|
haveMSR = isx86;
|
|
|
|
|
2019-08-28 12:37:44 +00:00
|
|
|
# # Currently broken on Aarch64
|
|
|
|
# haveFlashrom = isx86;
|
2019-11-18 17:44:54 +00:00
|
|
|
# Experimental
|
2019-08-28 12:37:44 +00:00
|
|
|
haveFlashrom = false;
|
2019-08-07 02:00:45 +00:00
|
|
|
|
2020-06-16 08:41:57 +00:00
|
|
|
runPythonCommand = name: buildCommandPython: runCommand name {
|
|
|
|
nativeBuildInputs = [ python3 ];
|
|
|
|
inherit buildCommandPython;
|
|
|
|
} ''
|
|
|
|
exec python3 -c "$buildCommandPython"
|
|
|
|
'';
|
2019-08-28 13:05:09 +00:00
|
|
|
|
2020-06-16 08:41:57 +00:00
|
|
|
self = stdenv.mkDerivation rec {
|
|
|
|
pname = "fwupd";
|
2021-03-15 06:22:42 +00:00
|
|
|
version = "1.5.7";
|
2019-01-27 23:15:00 +00:00
|
|
|
|
2020-09-12 11:12:14 +00:00
|
|
|
# libfwupd goes to lib
|
|
|
|
# daemon, plug-ins and libfwupdplugin go to out
|
|
|
|
# CLI programs go to out
|
|
|
|
outputs = [ "out" "lib" "dev" "devdoc" "man" "installedTests" ];
|
|
|
|
|
2020-06-16 08:41:57 +00:00
|
|
|
src = fetchurl {
|
|
|
|
url = "https://people.freedesktop.org/~hughsient/releases/fwupd-${version}.tar.xz";
|
2021-03-15 06:22:42 +00:00
|
|
|
sha256 = "16isrrv6zhdgccbfnz7km5g1cnvfnip7aiidkfhf5dlnrnyb2sxh";
|
2020-06-16 08:41:57 +00:00
|
|
|
};
|
2017-09-18 13:14:21 +00:00
|
|
|
|
2020-09-12 11:12:14 +00:00
|
|
|
patches = [
|
|
|
|
# Do not try to create useless paths in /var.
|
|
|
|
./fix-paths.patch
|
|
|
|
|
|
|
|
# Allow installing
|
|
|
|
./add-option-for-installation-sysconfdir.patch
|
|
|
|
|
|
|
|
# Install plug-ins and libfwupdplugin to out,
|
|
|
|
# they are not really part of the library.
|
|
|
|
./install-fwupdplugin-to-out.patch
|
|
|
|
|
|
|
|
# Installed tests are installed to different output
|
|
|
|
# we also cannot have fwupd-tests.conf in $out/etc since it would form a cycle.
|
|
|
|
(substituteAll {
|
|
|
|
src = ./installed-tests-path.patch;
|
|
|
|
# Needs a different set of modules than po/make-images.
|
|
|
|
inherit installedTestsPython;
|
|
|
|
})
|
|
|
|
];
|
2017-09-18 13:14:21 +00:00
|
|
|
|
2020-06-16 08:41:57 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
meson
|
|
|
|
ninja
|
|
|
|
gtk-doc
|
2020-09-12 11:12:14 +00:00
|
|
|
pkg-config
|
2020-06-16 08:41:57 +00:00
|
|
|
gobject-introspection
|
2020-09-12 11:26:44 +00:00
|
|
|
gettext
|
2020-06-16 08:41:57 +00:00
|
|
|
shared-mime-info
|
|
|
|
valgrind
|
|
|
|
gcab
|
2021-02-01 20:21:41 +00:00
|
|
|
gnutls
|
2020-06-16 08:41:57 +00:00
|
|
|
docbook_xml_dtd_43
|
2020-09-12 11:12:14 +00:00
|
|
|
docbook-xsl-nons
|
2020-06-16 08:41:57 +00:00
|
|
|
help2man
|
|
|
|
libxslt
|
|
|
|
python
|
|
|
|
wrapGAppsHook
|
|
|
|
vala
|
|
|
|
];
|
2018-02-10 04:23:17 +00:00
|
|
|
|
2020-06-16 08:41:57 +00:00
|
|
|
buildInputs = [
|
|
|
|
polkit
|
|
|
|
libxmlb
|
|
|
|
gusb
|
|
|
|
sqlite
|
|
|
|
libarchive
|
2020-12-08 14:05:15 +00:00
|
|
|
curl
|
2020-06-16 08:41:57 +00:00
|
|
|
elfutils
|
|
|
|
gnu-efi
|
|
|
|
libgudev
|
|
|
|
colord
|
|
|
|
libjcat
|
|
|
|
libuuid
|
|
|
|
json-glib
|
|
|
|
umockdev
|
|
|
|
bash-completion
|
|
|
|
cairo
|
|
|
|
freetype
|
|
|
|
fontconfig
|
|
|
|
pango
|
|
|
|
tpm2-tss
|
|
|
|
efivar
|
2021-01-15 14:45:37 +00:00
|
|
|
] ++ lib.optionals haveDell [
|
2020-06-16 08:41:57 +00:00
|
|
|
libsmbios
|
|
|
|
];
|
2020-04-15 19:22:43 +00:00
|
|
|
|
2020-06-16 08:41:57 +00:00
|
|
|
mesonFlags = [
|
|
|
|
"-Dgtkdoc=true"
|
|
|
|
"-Dplugin_dummy=true"
|
2020-12-08 14:05:15 +00:00
|
|
|
# We are building the official releases.
|
|
|
|
"-Dsupported_build=true"
|
|
|
|
# Would dlopen libsoup to preserve compatibility with clients linking against older fwupd.
|
|
|
|
# https://github.com/fwupd/fwupd/commit/173d389fa59d8db152a5b9da7cc1171586639c97
|
|
|
|
"-Dsoup_session_compat=false"
|
2020-06-16 08:41:57 +00:00
|
|
|
"-Dudevdir=lib/udev"
|
|
|
|
"-Dsystemd_root_prefix=${placeholder "out"}"
|
|
|
|
"-Dinstalled_test_prefix=${placeholder "installedTests"}"
|
|
|
|
"-Defi-libdir=${gnu-efi}/lib"
|
|
|
|
"-Defi-ldsdir=${gnu-efi}/lib"
|
|
|
|
"-Defi-includedir=${gnu-efi}/include/efi"
|
2021-03-15 06:22:42 +00:00
|
|
|
"-Defi_sbat_distro_id=nixos"
|
|
|
|
"-Defi_sbat_distro_summary=NixOS"
|
|
|
|
"-Defi_sbat_distro_pkgname=fwupd"
|
|
|
|
"-Defi_sbat_distro_version=${version}"
|
|
|
|
"-Defi_sbat_distro_url=https://search.nixos.org/packages?channel=unstable&show=fwupd&from=0&size=50&sort=relevance&query=fwupd"
|
2020-06-16 08:41:57 +00:00
|
|
|
"--localstatedir=/var"
|
|
|
|
"--sysconfdir=/etc"
|
|
|
|
"-Dsysconfdir_install=${placeholder "out"}/etc"
|
|
|
|
|
|
|
|
# We do not want to place the daemon into lib (cyclic reference)
|
|
|
|
"--libexecdir=${placeholder "out"}/libexec"
|
|
|
|
# Our builder only adds $lib/lib to rpath but some things link
|
|
|
|
# against libfwupdplugin which is in $out/lib.
|
|
|
|
"-Dc_link_args=-Wl,-rpath,${placeholder "out"}/lib"
|
2021-01-15 14:45:37 +00:00
|
|
|
] ++ lib.optionals (!haveDell) [
|
2020-06-16 08:41:57 +00:00
|
|
|
"-Dplugin_dell=false"
|
|
|
|
"-Dplugin_synaptics=false"
|
2021-01-15 14:45:37 +00:00
|
|
|
] ++ lib.optionals (!haveRedfish) [
|
2020-06-16 08:41:57 +00:00
|
|
|
"-Dplugin_redfish=false"
|
2021-01-15 14:45:37 +00:00
|
|
|
] ++ lib.optionals haveFlashrom [
|
2020-06-16 08:41:57 +00:00
|
|
|
"-Dplugin_flashrom=true"
|
2021-02-16 01:50:46 +00:00
|
|
|
] ++ lib.optionals (!haveMSR) [
|
|
|
|
"-Dplugin_msr=false"
|
2020-02-06 18:31:59 +00:00
|
|
|
];
|
|
|
|
|
2020-09-12 11:12:14 +00:00
|
|
|
# TODO: wrapGAppsHook wraps efi capsule even though it is not ELF
|
|
|
|
dontWrapGApps = true;
|
|
|
|
|
|
|
|
# /etc/os-release not available in sandbox
|
|
|
|
# doCheck = true;
|
|
|
|
|
|
|
|
# Environment variables
|
|
|
|
|
|
|
|
# Fontconfig error: Cannot load default config file
|
|
|
|
FONTCONFIG_FILE =
|
|
|
|
let
|
|
|
|
fontsConf = makeFontsConf {
|
|
|
|
fontDirectories = [ freefont_ttf ];
|
|
|
|
};
|
|
|
|
in fontsConf;
|
2020-06-16 08:41:57 +00:00
|
|
|
|
|
|
|
# error: “PolicyKit files are missing”
|
|
|
|
# https://github.com/NixOS/nixpkgs/pull/67625#issuecomment-525788428
|
|
|
|
PKG_CONFIG_POLKIT_GOBJECT_1_ACTIONDIR = "/run/current-system/sw/share/polkit-1/actions";
|
|
|
|
|
2020-09-12 11:12:14 +00:00
|
|
|
# Phase hooks
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
patchShebangs \
|
|
|
|
contrib/get-version.py \
|
|
|
|
contrib/generate-version-script.py \
|
|
|
|
meson_post_install.sh \
|
2021-03-15 06:22:42 +00:00
|
|
|
plugins/uefi-capsule/efi/generate_sbat.py \
|
|
|
|
plugins/uefi-capsule/efi/generate_binary.py \
|
2020-09-12 11:12:14 +00:00
|
|
|
po/make-images \
|
|
|
|
po/make-images.sh \
|
|
|
|
po/test-deps
|
|
|
|
'';
|
2020-06-16 08:41:57 +00:00
|
|
|
|
|
|
|
preCheck = ''
|
|
|
|
addToSearchPath XDG_DATA_DIRS "${shared-mime-info}/share"
|
|
|
|
'';
|
|
|
|
|
2020-10-27 06:29:44 +00:00
|
|
|
postInstall =
|
|
|
|
let
|
|
|
|
testFw = fetchFromGitHub {
|
|
|
|
owner = "fwupd";
|
|
|
|
repo = "fwupd-test-firmware";
|
2021-03-15 06:22:42 +00:00
|
|
|
rev = "c13bfb26cae5f4f115dd4e08f9f00b3cb9acc25e";
|
|
|
|
sha256 = "US81i7mtLEe85KdWz5r+fQTk61IhqjVkzykBaBPuKL4=";
|
2020-10-27 06:29:44 +00:00
|
|
|
};
|
|
|
|
in ''
|
|
|
|
# These files have weird licenses so they are shipped separately.
|
|
|
|
cp --recursive --dereference "${testFw}/installed-tests/tests" "$installedTests/libexec/installed-tests/fwupd"
|
|
|
|
'';
|
|
|
|
|
2020-09-12 11:12:14 +00:00
|
|
|
preFixup = let
|
|
|
|
binPath = [
|
|
|
|
efibootmgr
|
|
|
|
bubblewrap
|
|
|
|
tpm2-tools
|
2021-01-15 14:45:37 +00:00
|
|
|
] ++ lib.optional haveFlashrom flashrom;
|
2020-09-12 11:12:14 +00:00
|
|
|
in ''
|
|
|
|
gappsWrapperArgs+=(
|
|
|
|
--prefix XDG_DATA_DIRS : "${shared-mime-info}/share"
|
|
|
|
# See programs reached with fu_common_find_program_in_path in source
|
2021-01-15 14:45:37 +00:00
|
|
|
--prefix PATH : "${lib.makeBinPath binPath}"
|
2020-09-12 11:12:14 +00:00
|
|
|
)
|
|
|
|
'';
|
|
|
|
|
|
|
|
# Since we had to disable wrapGAppsHook, we need to wrap the executables manually.
|
2020-06-16 08:41:57 +00:00
|
|
|
postFixup = ''
|
|
|
|
find -L "$out/bin" "$out/libexec" -type f -executable -print0 \
|
|
|
|
| while IFS= read -r -d ''' file; do
|
|
|
|
if [[ "$file" != *.efi ]]; then
|
|
|
|
echo "Wrapping program $file"
|
|
|
|
wrapGApp "$file"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
|
2020-10-27 06:29:44 +00:00
|
|
|
separateDebugInfo = true;
|
|
|
|
|
2020-06-16 08:41:57 +00:00
|
|
|
passthru = {
|
|
|
|
filesInstalledToEtc = [
|
|
|
|
"fwupd/daemon.conf"
|
|
|
|
"fwupd/remotes.d/lvfs-testing.conf"
|
|
|
|
"fwupd/remotes.d/lvfs.conf"
|
|
|
|
"fwupd/remotes.d/vendor.conf"
|
|
|
|
"fwupd/remotes.d/vendor-directory.conf"
|
|
|
|
"fwupd/thunderbolt.conf"
|
|
|
|
"fwupd/upower.conf"
|
2021-02-01 20:21:41 +00:00
|
|
|
"fwupd/uefi_capsule.conf"
|
2020-06-16 08:41:57 +00:00
|
|
|
"pki/fwupd/GPG-KEY-Hughski-Limited"
|
|
|
|
"pki/fwupd/GPG-KEY-Linux-Foundation-Firmware"
|
|
|
|
"pki/fwupd/GPG-KEY-Linux-Vendor-Firmware-Service"
|
|
|
|
"pki/fwupd/LVFS-CA.pem"
|
|
|
|
"pki/fwupd-metadata/GPG-KEY-Linux-Foundation-Metadata"
|
|
|
|
"pki/fwupd-metadata/GPG-KEY-Linux-Vendor-Firmware-Service"
|
|
|
|
"pki/fwupd-metadata/LVFS-CA.pem"
|
2021-01-15 14:45:37 +00:00
|
|
|
] ++ lib.optionals haveDell [
|
2020-06-16 08:41:57 +00:00
|
|
|
"fwupd/remotes.d/dell-esrt.conf"
|
2021-02-16 01:50:46 +00:00
|
|
|
] ++ lib.optionals haveRedfish [
|
|
|
|
"fwupd/redfish.conf"
|
2020-06-16 08:41:57 +00:00
|
|
|
];
|
|
|
|
|
2020-10-27 06:29:44 +00:00
|
|
|
# DisabledPlugins key in fwupd/daemon.conf
|
|
|
|
defaultDisabledPlugins = [
|
2020-06-16 08:41:57 +00:00
|
|
|
"test"
|
2021-03-15 06:22:42 +00:00
|
|
|
"test_ble"
|
2020-06-16 08:41:57 +00:00
|
|
|
"invalid"
|
|
|
|
];
|
|
|
|
|
|
|
|
tests = let
|
2021-01-15 14:45:37 +00:00
|
|
|
listToPy = list: "[${lib.concatMapStringsSep ", " (f: "'${f}'") list}]";
|
2020-06-16 08:41:57 +00:00
|
|
|
in {
|
|
|
|
installedTests = nixosTests.installed-tests.fwupd;
|
|
|
|
|
|
|
|
passthruMatches = runPythonCommand "fwupd-test-passthru-matches" ''
|
|
|
|
import itertools
|
|
|
|
import configparser
|
|
|
|
import os
|
|
|
|
import pathlib
|
|
|
|
|
|
|
|
etc = '${self}/etc'
|
|
|
|
package_etc = set(itertools.chain.from_iterable([[os.path.relpath(os.path.join(prefix, file), etc) for file in files] for (prefix, dirs, files) in os.walk(etc)]))
|
|
|
|
passthru_etc = set(${listToPy passthru.filesInstalledToEtc})
|
|
|
|
assert len(package_etc - passthru_etc) == 0, f'fwupd package contains the following paths in /etc that are not listed in passthru.filesInstalledToEtc: {package_etc - passthru_etc}'
|
|
|
|
assert len(passthru_etc - package_etc) == 0, f'fwupd package lists the following paths in passthru.filesInstalledToEtc that are not contained in /etc: {passthru_etc - package_etc}'
|
|
|
|
|
|
|
|
config = configparser.RawConfigParser()
|
|
|
|
config.read('${self}/etc/fwupd/daemon.conf')
|
2020-10-27 06:29:44 +00:00
|
|
|
package_disabled_plugins = config.get('fwupd', 'DisabledPlugins').rstrip(';').split(';')
|
|
|
|
passthru_disabled_plugins = ${listToPy passthru.defaultDisabledPlugins}
|
|
|
|
assert package_disabled_plugins == passthru_disabled_plugins, f'Default disabled plug-ins in the package {package_disabled_plugins} do not match those listed in passthru.defaultDisabledPlugins {passthru_disabled_plugins}'
|
2020-06-16 08:41:57 +00:00
|
|
|
|
|
|
|
pathlib.Path(os.getenv('out')).touch()
|
|
|
|
'';
|
|
|
|
};
|
2019-08-28 12:37:44 +00:00
|
|
|
};
|
2018-02-17 03:06:24 +00:00
|
|
|
|
2021-01-11 07:54:33 +00:00
|
|
|
meta = with lib; {
|
2020-06-16 08:41:57 +00:00
|
|
|
homepage = "https://fwupd.org/";
|
|
|
|
maintainers = with maintainers; [ jtojnar ];
|
2020-09-12 11:12:14 +00:00
|
|
|
license = licenses.lgpl21Plus;
|
2020-06-16 08:41:57 +00:00
|
|
|
platforms = platforms.linux;
|
|
|
|
};
|
2017-09-18 13:14:21 +00:00
|
|
|
};
|
2020-06-16 08:41:57 +00:00
|
|
|
|
|
|
|
in self
|