nixpkgs/pkgs/development/compilers/chicken/4/chicken.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

97 lines
3.1 KiB
Nix
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{ lib, stdenv, fetchurl, makeWrapper, darwin, bootstrap-chicken ? null }:
let
version = "4.13.0";
platform = with stdenv;
if isDarwin then "macosx"
else if isCygwin then "cygwin"
else if (isFreeBSD || isOpenBSD) then "bsd"
else if isSunOS then "solaris"
else "linux"; # Should be a sane default
in
stdenv.mkDerivation {
pname = "chicken";
inherit version;
binaryVersion = 8;
src = fetchurl {
url = "https://code.call-cc.org/releases/${version}/chicken-${version}.tar.gz";
sha256 = "0hvckhi5gfny3mlva6d7y9pmx7cbwvq0r7mk11k3sdiik9hlkmdd";
};
postPatch = lib.optionalString stdenv.hostPlatform.isDarwin ''
# There is not enough space in the load command to accomodate a full path to the store,
# so use `@executable_path` to specify a relative path to chickens lib folder.
sed -e '/POSTINSTALL_PROGRAM_FLAGS = /{s|$(LIBDIR)|@executable_path/../lib|}' \
-i Makefile.macosx
'';
setupHook = lib.optional (bootstrap-chicken != null) ./setup-hook.sh;
# -fno-strict-overflow is not a supported argument in clang on darwin
hardeningDisable = lib.optionals stdenv.hostPlatform.isDarwin ["strictoverflow"];
makeFlags = [
"PLATFORM=${platform}" "PREFIX=$(out)"
"VARDIR=$(out)/var/lib"
] ++ (lib.optionals stdenv.hostPlatform.isDarwin [
"XCODE_TOOL_PATH=${darwin.binutils.bintools}/bin"
"C_COMPILER=$(CC)"
"POSTINSTALL_PROGRAM=${stdenv.cc.targetPrefix}install_name_tool"
]);
# We need a bootstrap-chicken to regenerate the c-files after
# applying a patch to add support for CHICKEN_REPOSITORY_EXTRA
patches = lib.optionals (bootstrap-chicken != null) [
./0001-Introduce-CHICKEN_REPOSITORY_EXTRA.patch
];
nativeBuildInputs = [
makeWrapper
] ++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) [
darwin.autoSignDarwinBinariesHook
];
buildInputs = lib.optionals (bootstrap-chicken != null) [
bootstrap-chicken
];
preBuild = lib.optionalString (bootstrap-chicken != null) ''
# Backup the build* files - those are generated from hostname,
# git-tag, etc. and we don't need/want that
mkdir -p build-backup
mv buildid buildbranch buildtag.h build-backup
# Regenerate eval.c after the patch
make spotless $makeFlags
mv build-backup/* .
'';
postInstall = ''
for f in $out/bin/*
do
wrapProgram $f \
--prefix PATH : ${stdenv.cc}/bin
done
'';
# TODO: Assert csi -R files -p '(pathname-file (repository-path))' == binaryVersion
meta = {
homepage = "http://www.call-cc.org/";
license = lib.licenses.bsd3;
maintainers = with lib.maintainers; [ corngood ];
platforms = lib.platforms.linux ++ lib.platforms.darwin; # Maybe other Unix
description = "Portable compiler for the Scheme programming language";
longDescription = ''
CHICKEN is a compiler for the Scheme programming language.
CHICKEN produces portable and efficient C, supports almost all
of the R5RS Scheme language standard, and includes many
enhancements and extensions. CHICKEN runs on Linux, macOS,
Windows, and many Unix flavours.
'';
};
}