lol
at 22.05-pre 92 lines 3.3 kB view raw
1{ lib 2, stdenv 3, fetchFromGitHub 4, makeWrapper 5, clang 6, chez 7, gmp 8, zsh 9}: 10 11# NOTICE: An `idris2WithPackages` is available at: https://github.com/claymager/idris2-pkgs 12 13# Uses scheme to bootstrap the build of idris2 14stdenv.mkDerivation rec { 15 pname = "idris2"; 16 version = "0.5.1"; 17 18 src = fetchFromGitHub { 19 owner = "idris-lang"; 20 repo = "Idris2"; 21 rev = "v${version}"; 22 sha256 = "sha256-6CTn8o5geWSesXO7vTrrV/2EOQ3f+nPQ2M5cem13ZSY="; 23 }; 24 25 # We do not add any propagatedNativeBuildInputs because we do not want the 26 # executables idris2 produces to depend on the nix-store. As such, it is left 27 # to the user to guarantee chez (or any other codgen dependency) is available 28 # in the path during compilation of programs with idris2. 29 strictDeps = true; 30 nativeBuildInputs = [ makeWrapper clang chez ] 31 ++ lib.optional stdenv.isDarwin [ zsh ]; 32 buildInputs = [ gmp ]; 33 34 prePatch = '' 35 patchShebangs --build tests 36 ''; 37 38 makeFlags = [ "PREFIX=$(out)" ] 39 ++ lib.optional stdenv.isDarwin "OS="; 40 41 # The name of the main executable of pkgs.chez is `scheme` 42 buildFlags = [ "bootstrap" "SCHEME=scheme" ]; 43 44 checkTarget = "test"; 45 46 # TODO: Move this into its own derivation, such that this can be changed 47 # without having to recompile idris2 every time. 48 postInstall = let 49 includedLibs = [ "base" "contrib" "network" "prelude" ]; 50 name = "${pname}-${version}"; 51 packagePaths = 52 builtins.map (l: "$out/${name}/${l}-${version}") includedLibs; 53 additionalIdris2Paths = builtins.concatStringsSep ":" packagePaths; 54 in '' 55 # Remove existing idris2 wrapper that sets incorrect LD_LIBRARY_PATH 56 rm $out/bin/idris2 57 # Move actual idris2 binary 58 mv $out/bin/idris2_app/idris2.so $out/bin/idris2 59 60 # After moving the binary, there is nothing left in idris2_app that isn't 61 # either contained in lib/ or is useless to us. 62 rm $out/bin/idris2_app/* 63 rmdir $out/bin/idris2_app 64 65 # idris2 needs to find scheme at runtime to compile 66 # idris2 installs packages with --install into the path given by PREFIX. 67 # Since PREFIX is in nix-store, it is immutable so --install does not work. 68 # If the user redefines PREFIX to be able to install packages, idris2 will 69 # not find the libraries and packages since all paths are relative to 70 # PREFIX by default. 71 # We explicitly make all paths to point to nix-store, such that they are 72 # independent of what IDRIS2_PREFIX is. This allows the user to redefine 73 # IDRIS2_PREFIX and use --install as expected. 74 # TODO: Make support libraries their own derivation such that 75 # overriding LD_LIBRARY_PATH is unnecessary 76 # TODO: Maybe set IDRIS2_PREFIX to the users home directory 77 wrapProgram "$out/bin/idris2" \ 78 --set-default CHEZ "${chez}/bin/scheme" \ 79 --suffix IDRIS2_LIBS ':' "$out/${name}/lib" \ 80 --suffix IDRIS2_DATA ':' "$out/${name}/support" \ 81 --suffix IDRIS2_PATH ':' "${additionalIdris2Paths}" \ 82 --suffix LD_LIBRARY_PATH ':' "$out/${name}/lib" 83 ''; 84 85 meta = { 86 description = "A purely functional programming language with first class types"; 87 homepage = "https://github.com/idris-lang/Idris2"; 88 license = lib.licenses.bsd3; 89 maintainers = with lib.maintainers; [ fabianhjr wchresta ]; 90 inherit (chez.meta) platforms; 91 }; 92}