Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1# Almost 1:1 copy of idris2's nix/platform.nix. Some work done in their flake.nix 2# we do here instead. 3{ stdenv 4, lib 5, chez 6, chez-racket 7, clang 8, gmp 9, fetchFromGitHub 10, makeWrapper 11, gambit 12, nodejs 13, zsh 14, callPackage 15}: 16 17# NOTICE: An `idris2WithPackages` is available at: https://github.com/claymager/idris2-pkgs 18 19let 20 # Taken from Idris2/idris2/flake.nix. Check if the idris2 project does it this 21 # way, still, every now and then. 22 platformChez = if stdenv.system == "x86_64-linux" then chez else chez-racket; 23# Uses scheme to bootstrap the build of idris2 24in stdenv.mkDerivation rec { 25 pname = "idris2"; 26 version = "0.6.0"; 27 28 src = fetchFromGitHub { 29 owner = "idris-lang"; 30 repo = "Idris2"; 31 rev = "v${version}"; 32 sha256 = "sha256-80MAGM1IEtI09h5aCYfDL4PRrjGq2gT8OUEibOVk8H4="; 33 }; 34 35 strictDeps = true; 36 nativeBuildInputs = [ makeWrapper clang platformChez ] 37 ++ lib.optionals stdenv.isDarwin [ zsh ]; 38 buildInputs = [ platformChez gmp ]; 39 40 prePatch = '' 41 patchShebangs --build tests 42 ''; 43 44 makeFlags = [ "PREFIX=$(out)" ] 45 ++ lib.optional stdenv.isDarwin "OS="; 46 47 # The name of the main executable of pkgs.chez is `scheme` 48 buildFlags = [ "bootstrap" "SCHEME=scheme" ]; 49 50 checkTarget = "test"; 51 nativeCheckInputs = [ gambit nodejs ]; # racket ]; 52 checkFlags = [ "INTERACTIVE=" ]; 53 54 # TODO: Move this into its own derivation, such that this can be changed 55 # without having to recompile idris2 every time. 56 postInstall = let 57 name = "${pname}-${version}"; 58 globalLibraries = [ 59 "\\$HOME/.nix-profile/lib/${name}" 60 "/run/current-system/sw/lib/${name}" 61 "$out/${name}" 62 ]; 63 globalLibrariesPath = builtins.concatStringsSep ":" globalLibraries; 64 in '' 65 # Remove existing idris2 wrapper that sets incorrect LD_LIBRARY_PATH 66 rm $out/bin/idris2 67 # The only thing we need from idris2_app is the actual binary 68 mv $out/bin/idris2_app/idris2.so $out/bin/idris2 69 rm $out/bin/idris2_app/* 70 rmdir $out/bin/idris2_app 71 # idris2 needs to find scheme at runtime to compile 72 # idris2 installs packages with --install into the path given by 73 # IDRIS2_PREFIX. We set that to a default of ~/.idris2, to mirror the 74 # behaviour of the standard Makefile install. 75 # TODO: Make support libraries their own derivation such that 76 # overriding LD_LIBRARY_PATH is unnecessary 77 wrapProgram "$out/bin/idris2" \ 78 --set-default CHEZ "${platformChez}/bin/scheme" \ 79 --run 'export IDRIS2_PREFIX=''${IDRIS2_PREFIX-"$HOME/.idris2"}' \ 80 --suffix IDRIS2_LIBS ':' "$out/${name}/lib" \ 81 --suffix IDRIS2_DATA ':' "$out/${name}/support" \ 82 --suffix IDRIS2_PACKAGE_PATH ':' "${globalLibrariesPath}" \ 83 --suffix DYLD_LIBRARY_PATH ':' "$out/${name}/lib" \ 84 --suffix LD_LIBRARY_PATH ':' "$out/${name}/lib" 85 ''; 86 87 # Run package tests 88 passthru.tests = callPackage ./tests.nix { inherit pname; }; 89 90 meta = { 91 description = "A purely functional programming language with first class types"; 92 homepage = "https://github.com/idris-lang/Idris2"; 93 license = lib.licenses.bsd3; 94 maintainers = with lib.maintainers; [ fabianhjr wchresta ]; 95 inherit (chez.meta) platforms; 96 }; 97}