1{
2 lib,
3 fetchFromGitHub,
4 inkscape,
5 meson,
6 mkDerivation,
7 ninja,
8 # We will resolve pkexec from the path because it has a setuid wrapper on
9 # NixOS meaning that we cannot just use the path from the nix store.
10 # Using the path to the wrapper here would make the package incompatible
11 # with non-NixOS systems.
12 pkexecPath ? "pkexec",
13 pkg-config,
14 yaml-cpp,
15 nvramtool,
16 systemd,
17 qtbase,
18 qtsvg,
19 wrapQtAppsHook,
20}:
21
22mkDerivation {
23 pname = "coreboot-configurator";
24 version = "unstable-2023-01-17";
25
26 src = fetchFromGitHub {
27 owner = "StarLabsLtd";
28 repo = "coreboot-configurator";
29 rev = "944b575dc873c78627c352f9c1a1493981431a58";
30 sha256 = "sha256-ReWQNzeoyTF66hVnevf6Kkrnt0/PqRHd3oyyPYtx+0M=";
31 };
32
33 nativeBuildInputs = [
34 inkscape
35 meson
36 ninja
37 pkg-config
38 wrapQtAppsHook
39 ];
40 buildInputs = [
41 yaml-cpp
42 qtbase
43 qtsvg
44 ];
45
46 postPatch = ''
47 substituteInPlace src/application/*.cpp \
48 --replace '/usr/bin/pkexec' '${pkexecPath}' \
49 --replace '/usr/bin/systemctl' '${lib.getBin systemd}/systemctl' \
50 --replace '/usr/sbin/nvramtool' '${lib.getExe nvramtool}'
51
52 substituteInPlace src/resources/org.coreboot.nvramtool.policy \
53 --replace '/usr/sbin/nvramtool' '${lib.getExe nvramtool}'
54
55 substituteInPlace src/resources/org.coreboot.reboot.policy \
56 --replace '/usr/sbin/reboot' '${lib.getBin systemd}/reboot'
57 '';
58
59 postFixup = ''
60 substituteInPlace $out/share/applications/coreboot-configurator.desktop \
61 --replace '/usr/bin/coreboot-configurator' 'coreboot-configurator'
62 '';
63
64 meta = with lib; {
65 description = "Simple GUI to change settings in Coreboot's CBFS";
66 homepage = "https://support.starlabs.systems/kb/guides/coreboot-configurator";
67 license = licenses.gpl2Only;
68 platforms = platforms.linux;
69 maintainers = with maintainers; [ danth ];
70 mainProgram = "coreboot-configurator";
71 };
72}