1
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs synced 2024-10-19 03:47:13 -04:00
nixpkgs/pkgs/os-specific/linux/firmware/raspberrypi/armstubs.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

54 lines
1.4 KiB
Nix

{ lib, stdenv, fetchFromGitHub }:
let
inherit (lib) optionals;
in
stdenv.mkDerivation {
pname = "raspberrypi-armstubs";
version = "unstable-2022-07-11";
src = fetchFromGitHub {
owner = "raspberrypi";
repo = "tools";
rev = "439b6198a9b340de5998dd14a26a0d9d38a6bcac";
hash = "sha512-KMHgj73eXHT++IE8DbCsFeJ87ngc9R3XxMUJy4Z3s4/MtMeB9zblADHkyJqz9oyeugeJTrDtuVETPBRo7M4Y8A==";
};
env.NIX_CFLAGS_COMPILE = toString [
"-march=armv8-a+crc"
];
preConfigure = ''
cd armstubs
'';
makeFlags = [
"CC8=${stdenv.cc.targetPrefix}cc"
"LD8=${stdenv.cc.targetPrefix}ld"
"OBJCOPY8=${stdenv.cc.targetPrefix}objcopy"
"OBJDUMP8=${stdenv.cc.targetPrefix}objdump"
"CC7=${stdenv.cc.targetPrefix}cc"
"LD7=${stdenv.cc.targetPrefix}ld"
"OBJCOPY7=${stdenv.cc.targetPrefix}objcopy"
"OBJDUMP7=${stdenv.cc.targetPrefix}objdump"
]
++ optionals (stdenv.hostPlatform.isAarch64) [ "armstub8.bin" "armstub8-gic.bin" ]
++ optionals (stdenv.hostPlatform.isAarch32) [ "armstub7.bin" "armstub8-32.bin" "armstub8-32-gic.bin" ]
;
installPhase = ''
runHook preInstall
mkdir -vp $out/
cp -v *.bin $out/
runHook postInstall
'';
meta = with lib; {
description = "Firmware related ARM stubs for the Raspberry Pi";
homepage = "https://github.com/raspberrypi/tools";
license = licenses.bsd3;
platforms = [ "armv6l-linux" "armv7l-linux" "aarch64-linux" ];
maintainers = [ ];
};
}