1 # Build an idris package
2 { stdenv, lib, gmp, prelude, base, with-packages, idris }:
9 , extraBuildInputs ? []
10 , idrisBuildOptions ? []
11 , idrisTestOptions ? []
12 , idrisInstallOptions ? []
13 , idrisDocOptions ? []
17 allIdrisDeps = idrisDeps
18 ++ lib.optional (!noPrelude) prelude
19 ++ lib.optional (!noBase) base;
20 idris-with-packages = with-packages allIdrisDeps;
21 newAttrs = builtins.removeAttrs attrs [
22 "idrisDeps" "noPrelude" "noBase"
23 "pname" "version" "ipkgName" "extraBuildInputs"
25 meta = attrs.meta // {
26 platforms = attrs.meta.platforms or idris.meta.platforms;
30 stdenv.mkDerivation ({
31 pname = "idris-${pname}";
34 buildInputs = [ idris-with-packages gmp ] ++ extraBuildInputs;
35 propagatedBuildInputs = allIdrisDeps;
37 # Some packages use the style
38 # opts = -i ../../path/to/package
39 # rather than the declarative pkgs attribute so we have to rewrite the path.
42 sed -i ${ipkgName}.ipkg -e "/^opts/ s|-i \\.\\./|-i ${idris-with-packages}/libs/|g"
48 idris --build ${ipkgName}.ipkg ${lib.escapeShellArgs idrisBuildOptions}
54 if grep -q tests ${ipkgName}.ipkg; then
55 idris --testpkg ${ipkgName}.ipkg ${lib.escapeShellArgs idrisTestOptions}
63 idris --install ${ipkgName}.ipkg --ibcsubdir $out/libs ${lib.escapeShellArgs idrisInstallOptions}
65 IDRIS_DOC_PATH=$out/doc idris --installdoc ${ipkgName}.ipkg ${lib.escapeShellArgs idrisDocOptions} || true
67 # If the ipkg file defines an executable, install that
68 executable=$(grep -Po '^executable = \K.*' ${ipkgName}.ipkg || true)
69 # $executable intentionally not quoted because it must be quoted correctly
70 # in the ipkg file already
71 if [ ! -z "$executable" ] && [ -f $executable ]; then
73 mv $executable $out/bin/$executable