nixpkgs/pkgs/tools/misc/edid-generator/default.nix
Artturin e0464e4788 treewide: replace stdenv.is with stdenv.hostPlatform.is
In preparation for the deprecation of `stdenv.isX`.

These shorthands are not conducive to cross-compilation because they
hide the platforms.

Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way

One example of why this is bad and especially affects compiler packages
https://www.github.com/NixOS/nixpkgs/pull/343059

There are too many files to go through manually but a treewide should
get users thinking when they see a `hostPlatform.isX` in a place where it
doesn't make sense.

```
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is"
fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is"
```
2024-09-25 00:04:37 +03:00

80 lines
1.9 KiB
Nix

{ lib
, stdenv
, fetchFromGitHub
, dos2unix
, edid-decode
, hexdump
, zsh
}:
# Usage:
# hardware.firmware = [(edid-generator.overrideAttrs {
# clean = true;
# modelines = ''
# Modeline "PG278Q_60" 241.50 2560 2608 2640 2720 1440 1443 1448 1481 -hsync +vsync
# Modeline "PG278Q_120" 497.75 2560 2608 2640 2720 1440 1443 1448 1525 +hsync -vsync
# Modeline "U2711_60" 241.50 2560 2600 2632 2720 1440 1443 1448 1481 -hsync +vsync
# '';
# })];
stdenv.mkDerivation {
pname = "edid-generator";
version = "master-2023-11-20";
# so `hardware.firmware` doesn't compress it
compressFirmware = false;
src = fetchFromGitHub {
owner = "akatrevorjay";
repo = "edid-generator";
rev = "476a016d8b488df749bf6d6efbf7b9fbfb2e3cb8";
sha256 = "sha256-UGxze273VB5cQDWrv9X/Lam6WbOu9U3bro8GcVbEvws=";
};
nativeBuildInputs = [ dos2unix edid-decode hexdump zsh ];
postPatch = ''
patchShebangs modeline2edid
'';
passAsFile = [ "modelines" ];
clean = false;
modelines = "";
configurePhase = ''
test "$clean" != 1 || rm *x*.S
./modeline2edid - <"$modelinesPath"
for file in *.S ; do
echo "--- generated file: $file"
cat "$file"
done
make clean
'';
buildPhase = ''
make all
'';
doCheck = true;
checkPhase = ''
for file in *.bin ; do
echo "validating $file"
edid-decode <"$file"
done
'';
installPhase = ''
install -Dm 444 *.bin -t "$out/lib/firmware/edid"
'';
meta = {
description = "Hackerswork to generate an EDID blob from given Xorg Modelines";
homepage = "https://github.com/akatrevorjay/edid-generator";
license = lib.licenses.gpl3;
maintainers = with lib.maintainers; [ flokli nazarewk ];
platforms = lib.platforms.all;
broken = stdenv.hostPlatform.isDarwin; # never built on Hydra https://hydra.nixos.org/job/nixpkgs/trunk/edid-generator.x86_64-darwin
};
}