btrbk: add mainProgram
[NixPkgs.git] / pkgs / by-name / sh / shim-unsigned / package.nix
blobe4220cf5cc8ecfe47ccaa888cfbf8b2138545e83
1 { stdenv, fetchFromGitHub, lib, elfutils, vendorCertFile ? null
2 , defaultLoader ? null }:
4 let
6   inherit (stdenv.hostPlatform) system;
7   throwSystem = throw "Unsupported system: ${system}";
9   archSuffix = {
10     x86_64-linux = "x64";
11     aarch64-linux = "aa64";
12   }.${system} or throwSystem;
13 in stdenv.mkDerivation rec {
14   pname = "shim";
15   version = "15.8";
17   src = fetchFromGitHub {
18     owner = "rhboot";
19     repo = pname;
20     rev = version;
21     hash = "sha256-xnr9HBfYP035C7p2YTRZasx5SF4a2ZkOl9IpsVduNm4=";
22     fetchSubmodules = true;
23   };
25   buildInputs = [ elfutils ];
27   env.NIX_CFLAGS_COMPILE = toString [ "-I${toString elfutils.dev}/include" ];
29   makeFlags =
30     lib.optional (vendorCertFile != null) "VENDOR_CERT_FILE=${vendorCertFile}"
31     ++ lib.optional (defaultLoader != null) "DEFAULT_LOADER=${defaultLoader}";
33   installTargets = ["install-as-data"];
34   installFlags = [
35     "DATATARGETDIR=$(out)/share/shim"
36   ];
38   passthru = {
39     # Expose the arch suffix and target file names so that consumers
40     # (e.g. infrastructure for signing this shim) don't need to
41     # duplicate the logic from here
42     inherit archSuffix;
43     target = "shim${archSuffix}.efi";
44     mokManagerTarget = "mm${archSuffix}.efi";
45     fallbackTarget = "fb${archSuffix}.efi";
46   };
48   meta = with lib; {
49     description = "UEFI shim loader";
50     homepage = "https://github.com/rhboot/shim";
51     license = licenses.bsd1;
52     platforms = [ "x86_64-linux" "aarch64-linux" ];
53     maintainers = with maintainers; [ baloo raitobezarius ];
54   };