presenterm: 0.9.0 -> 0.10.0 (#378946)
[NixPkgs.git] / pkgs / by-name / li / linuxhw-edid-fetcher / package.nix
blob47ed98ddba2840bc41bfb4f45a72813e7433aecf
2   lib,
3   coreutils,
4   curl,
5   fetchFromGitHub,
6   gawk,
7   gnutar,
8   stdenv,
9   unixtools,
10   writeShellApplication,
11   nix-update-script,
12   displays ? { },
15 # Usage:
16 #   let
17 #     edids = linuxhw-edid-fetcher.override {
18 #       displays.PG278Q_2014 = [ "PG278Q" "2560x1440" "2014" ];
19 #     };
20 #   in
21 #     "${edids}/lib/firmware/edid/PG278Q_2014.bin";
22 stdenv.mkDerivation rec {
23   pname = "linuxhw-edid-fetcher";
24   version = "0-unstable-2025-01-06";
26   src = fetchFromGitHub {
27     owner = "linuxhw";
28     repo = "EDID";
29     rev = "cc83e52221a9a6d98632f00b54be64fd0bee0394";
30     hash = "sha256-qwTHQOEeFG7SOM2JG9mNpJEoPI8M7GHuwYPWWfU/ID4=";
31   };
33   fetch = lib.getExe (writeShellApplication {
34     name = "linuxhw-edid-fetch";
35     runtimeInputs = [
36       gawk
37       coreutils
38       unixtools.xxd
39       curl
40       gnutar
41     ];
42     text = ''
43       repo="''${repo:-"${src}"}"
44       ${builtins.readFile ./linuxhw-edid-fetch.sh}
45     '';
46   });
48   configurePhase = lib.pipe displays [
49     (lib.mapAttrsToList (
50       name: patterns: ''
51         "$fetch" ${lib.escapeShellArgs patterns} > "${name}.bin"
52       ''
53     ))
54     (builtins.concatStringsSep "\n")
55   ];
57   installPhase = ''
58     mkdir -p "$out/bin"
59     ln -s "$fetch" "$out/bin/"
60     ${lib.optionalString (displays != { }) ''
61       install -D --mode=444 --target-directory="$out/lib/firmware/edid" *.bin
62     ''}
63   '';
65   passthru.updateScript = nix-update-script { extraArgs = [ "--version=branch=master" ]; };
67   meta = {
68     description = "Fetcher for EDID binaries from Linux Hardware Project's EDID repository";
69     homepage = "https://github.com/linuxhw/EDID";
70     license = lib.licenses.cc-by-40;
71     maintainers = with lib.maintainers; [ nazarewk ];
72     platforms = lib.platforms.all;
73     mainProgram = "linuxhw-edid-fetch";
74   };