about summary refs log tree commit diff
path: root/pkgs/development/compilers/chicken/5/eggDerivation.nix
blob: 8a558a605bfb911457e975b53a78b05a42abf30b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
{ callPackage, lib, stdenv, chicken, makeWrapper }:
{ name, src
, buildInputs ? []
, chickenInstallFlags ? []
, cscOptions          ? []
, ...} @ args:

let
  overrides = callPackage ./overrides.nix { };
  baseName = lib.getName name;
  override = if builtins.hasAttr baseName overrides
   then
     builtins.getAttr baseName overrides
   else
     lib.id;
in
(stdenv.mkDerivation ({
  name = "chicken-${name}";
  propagatedBuildInputs = buildInputs;
  nativeBuildInputs = [ makeWrapper ];
  buildInputs = [ chicken ];

  CSC_OPTIONS = lib.concatStringsSep " " cscOptions;

  installPhase = ''
    runHook preInstall

    export CHICKEN_INSTALL_PREFIX=$out
    export CHICKEN_INSTALL_REPOSITORY=$out/lib/chicken/${toString chicken.binaryVersion}
    chicken-install -cached ${lib.concatStringsSep " " chickenInstallFlags}

    for f in $out/bin/*
    do
      wrapProgram $f \
        --prefix CHICKEN_REPOSITORY_PATH : "$out/lib/chicken/${toString chicken.binaryVersion}" \
        --suffix CHICKEN_INCLUDE_PATH : "$out/share" \
        --prefix PATH : "$out/bin:${chicken}/bin:$CHICKEN_REPOSITORY_PATH"
    done

    runHook postInstall
  '';

  dontBuild = true;
  dontConfigure = true;

  meta = {
    inherit (chicken.meta) platforms;
  } // args.meta or {};
} // builtins.removeAttrs args ["name" "buildInputs" "meta"]) ).overrideAttrs override