summary refs log tree commit diff
path: root/pkgs/os-specific/linux/firmware/fwupdate/default.nix
blob: bcafa7f3376d4bfaf94fa77076b00caada0487d4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
{ efivar, fetchurl, gettext, gnu-efi, libsmbios, pkgconfig, popt, stdenv }:

let
  version = "12";

  arch =
    if stdenv.hostPlatform.isx86_32
    then "ia32"
    else stdenv.hostPlatform.parsed.cpu.name;

in stdenv.mkDerivation {
  pname = "fwupdate";
  inherit version;
  src = fetchurl {
    url = "https://github.com/rhinstaller/fwupdate/releases/download/${version}/fwupdate-${version}.tar.bz2";
    sha256 = "00w7jsg7wrlq4cpfz26m9rbv2jwyf0sansf343vfq02fy5lxars1";
  };

  patches = [
    ./do-not-create-sharedstatedir.patch
  ];

  NIX_CFLAGS_COMPILE = builtins.toString [
    "-I${gnu-efi}/include/efi"
    "-I${gnu-efi}/include/efi/${arch}"
    "-Wno-error=address-of-packed-member"
  ];

  # TODO: Just apply the disable to the efi subdir
  hardeningDisable = [ "stackprotector" ];

  makeFlags = [
    "EFIDIR=nixos"
    "prefix=$(out)"
    "LIBDIR=$(out)/lib"
    "GNUEFIDIR=${gnu-efi}/lib"
    "ESPMOUNTPOINT=$(out)/boot"
  ];

  nativeBuildInputs = [
    pkgconfig
    gettext
  ];

  buildInputs = [
    gnu-efi
    libsmbios
    popt
  ];

  propagatedBuildInputs = [
    efivar
  ];

  postInstall = ''
    rm -rf $out/src
    rm -rf $out/lib/debug
  '';

  meta = with stdenv.lib; {
    description = "Tools for using the ESRT and UpdateCapsule() to apply firmware updates";
    maintainers = with maintainers; [ ];
    license = licenses.gpl2;
    platforms = platforms.linux;
  };
}