nixpkgs/pkgs/development/tools/simavr/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

56 lines
1.4 KiB
Nix

{ lib, stdenv, makeSetupHook, fetchFromGitHub, libelf, which, pkg-config, libglut
, avrgcc, avrlibc
, libGLU, libGL
, GLUT }:
let
setupHookDarwin = makeSetupHook {
name = "darwin-avr-gcc-hook";
substitutions = {
darwinSuffixSalt = stdenv.cc.suffixSalt;
avrSuffixSalt = avrgcc.suffixSalt;
};
} ./setup-hook-darwin.sh;
in stdenv.mkDerivation rec {
pname = "simavr";
version = "1.7";
src = fetchFromGitHub {
owner = "buserror";
repo = "simavr";
rev = "v${version}";
sha256 = "0njz03lkw5374x1lxrq08irz4b86lzj2hibx46ssp7zv712pq55q";
};
makeFlags = [
"DESTDIR=$(out)"
"PREFIX="
"AVR_ROOT=${avrlibc}/avr"
"SIMAVR_VERSION=${version}"
"AVR=avr-"
];
nativeBuildInputs = [ which pkg-config avrgcc ]
++ lib.optional stdenv.hostPlatform.isDarwin setupHookDarwin;
buildInputs = [ libelf libglut libGLU libGL ]
++ lib.optional stdenv.hostPlatform.isDarwin GLUT;
# remove forbidden references to $TMPDIR
preFixup = lib.optionalString stdenv.hostPlatform.isLinux ''
patchelf --shrink-rpath --allowed-rpath-prefixes "$NIX_STORE" "$out"/bin/*
'';
doCheck = true;
checkTarget = "-C tests run_tests";
meta = with lib; {
description = "Lean and mean Atmel AVR simulator";
mainProgram = "simavr";
homepage = "https://github.com/buserror/simavr";
license = licenses.gpl3;
platforms = platforms.unix;
maintainers = with maintainers; [ goodrone ];
};
}