mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-01-14 00:43:24 +00:00
e0464e4788
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" ```
69 lines
1.9 KiB
Nix
69 lines
1.9 KiB
Nix
{ lib
|
|
, stdenv
|
|
, fetchurl
|
|
, autoPatchelfHook
|
|
, gcc-unwrapped
|
|
, zlib
|
|
}:
|
|
|
|
let
|
|
system = stdenv.hostPlatform.system;
|
|
|
|
platform = {
|
|
x86_64-linux = "linux-amd64";
|
|
aarch64-linux = "linux-aarch64";
|
|
x86_64-darwin = "macos-amd64";
|
|
aarch64-darwin = "macos-aarch64";
|
|
}.${system} or (throw "Unsupported system: ${system}");
|
|
|
|
# TODO: It'd be nice to write an update script that would update all of these
|
|
# hashes together.
|
|
packageHash = {
|
|
x86_64-linux = "sha256-gYHIfvgofT9tKYCchZoRYvioLCtp2wfaOtuVWxTyujM=";
|
|
aarch64-linux = "sha256-zW+aeUc67pa6mQQkfazShHKAvGeucswLK1eRCxzXOJM=";
|
|
x86_64-darwin = "sha256-ph+SrrxOIyG9rRS098duhvDFiNGuh0o2uemm++J+zKw=";
|
|
aarch64-darwin = "sha256-eOpRaivRhk841/TCxC4ygw27UrPkqQCMH2mme2qo8V8=";
|
|
}.${system} or (throw "Unsupported system: ${system}");
|
|
|
|
in stdenv.mkDerivation rec {
|
|
pname = "fermyon-spin";
|
|
version = "2.5.1";
|
|
|
|
# Use fetchurl rather than fetchzip as these tarballs are built by the project
|
|
# and not by GitHub (and thus are stable) - this simplifies the update script
|
|
# by allowing it to use the output of `nix store prefetch-file`.
|
|
src = fetchurl {
|
|
url = "https://github.com/fermyon/spin/releases/download/v${version}/spin-v${version}-${platform}.tar.gz";
|
|
hash = packageHash;
|
|
};
|
|
|
|
sourceRoot = ".";
|
|
|
|
nativeBuildInputs = lib.optionals stdenv.hostPlatform.isLinux [
|
|
autoPatchelfHook
|
|
];
|
|
|
|
buildInputs = [
|
|
gcc-unwrapped.lib
|
|
zlib
|
|
];
|
|
|
|
installPhase = ''
|
|
runHook preInstall
|
|
|
|
mkdir -p $out/bin
|
|
cp ./spin $out/bin
|
|
|
|
runHook postInstall
|
|
'';
|
|
|
|
meta = with lib; {
|
|
description = "Framework for building, deploying, and running fast, secure, and composable cloud microservices with WebAssembly";
|
|
homepage = "https://github.com/fermyon/spin";
|
|
license = with licenses; [ asl20 ];
|
|
mainProgram = "spin";
|
|
maintainers = with maintainers; [ mglolenstine ];
|
|
platforms = platforms.linux ++ platforms.darwin;
|
|
};
|
|
}
|