···
14
-
# lib = pkg.library { withSource = true; };
14
+
# lib1 = pkg.library { withSource = true; };
16
+
# # implicitly without source:
17
+
# lib2 = pkg.library';
24
+
ipkgName, # ipkg filename without the extension
idrisLibraries, # Other libraries built with buildIdris
···
ipkgFileName = ipkgName + ".ipkg";
idrName = "idris2-${idris2.version}";
libSuffix = "lib/${idrName}";
47
-
propagatedIdrisLibraries = propagate idrisLibraryLibs;
48
-
libDirs = (lib.makeSearchPath libSuffix propagatedIdrisLibraries) + ":${idris2}/${idrName}";
51
+
libDirs = libs: (lib.makeSearchPath libSuffix libs) + ":${idris2}/${idrName}";
supportDir = "${idris2}/${idrName}/lib";
drvAttrs = builtins.removeAttrs attrs [
55
-
derivation = stdenv.mkDerivation (
62
-
nativeBuildInputs = [
65
-
] ++ attrs.nativeBuildInputs or [ ];
66
-
buildInputs = propagatedIdrisLibraries ++ attrs.buildInputs or [ ];
61
+
applyWithSource = lib: if withSource then lib.withSource else lib;
62
+
propagatedIdrisLibraries = map applyWithSource (propagate idrisLibraryLibs);
64
+
stdenv.mkDerivation (
69
+
inherit src version;
70
+
nativeBuildInputs = [
73
+
] ++ attrs.nativeBuildInputs or [ ];
74
+
buildInputs = propagatedIdrisLibraries ++ attrs.buildInputs or [ ];
68
-
env.IDRIS2_PACKAGE_PATH = libDirs;
76
+
env.IDRIS2_PACKAGE_PATH = libDirs propagatedIdrisLibraries;
72
-
idris2 --build ${ipkgFileName}
80
+
idris2 --build ${ipkgFileName}
77
-
inherit propagatedIdrisLibraries;
78
-
} // (attrs.passthru or { });
85
+
inherit propagatedIdrisLibraries;
86
+
} // (attrs.passthru or { });
81
-
export IDRIS2_PACKAGE_PATH="${finalAttrs.env.IDRIS2_PACKAGE_PATH}"
89
+
export IDRIS2_PACKAGE_PATH="${finalAttrs.env.IDRIS2_PACKAGE_PATH}"
97
+
derivation = mkDerivation withSource;
99
+
derivation.overrideAttrs {
103
+
scheme_app="$(find ./build/exec -name '*_app')"
104
+
if [ "$scheme_app" = ''' ]; then
105
+
mv -- build/exec/* $out/bin/
106
+
chmod +x $out/bin/*
107
+
# ^ remove after Idris2 0.8.0 is released. will be superfluous:
108
+
# https://github.com/idris-lang/Idris2/pull/3189
110
+
cd build/exec/*_app
111
+
rm -f ./libidris2_support.{so,dylib}
112
+
for file in *.so; do
113
+
bin_name="''${file%.so}"
114
+
mv -- "$file" "$out/bin/$bin_name"
116
+
wrapProgram "$out/bin/$bin_name" \
117
+
--prefix LD_LIBRARY_PATH : ${supportDir} \
118
+
--prefix DYLD_LIBRARY_PATH : ${supportDir}
121
+
runHook postInstall
88
-
executable = derivation.overrideAttrs {
92
-
scheme_app="$(find ./build/exec -name '*_app')"
93
-
if [ "$scheme_app" = ''' ]; then
94
-
mv -- build/exec/* $out/bin/
96
-
# ^ remove after Idris2 0.8.0 is released. will be superfluous:
97
-
# https://github.com/idris-lang/Idris2/pull/3189
100
-
rm -f ./libidris2_support.so
101
-
for file in *.so; do
102
-
bin_name="''${file%.so}"
103
-
mv -- "$file" "$out/bin/$bin_name"
104
-
wrapProgram "$out/bin/$bin_name" \
105
-
--prefix LD_LIBRARY_PATH : ${supportDir} \
106
-
--prefix DYLD_LIBRARY_PATH : ${supportDir}
109
-
runHook postInstall
124
+
# allow an executable's dependencies to be built with source. this is convenient when
125
+
# building a development shell for the exectuable using `mkShell`'s `inputsFrom`.
126
+
passthru = derivation.passthru // {
127
+
withSource = mkExecutable true;
115
-
withSource ? false,
installCmd = if withSource then "--install-with-src" else "--install";
135
+
derivation = mkDerivation withSource;
derivation.overrideAttrs {
···
idris2 ${installCmd} ${ipkgFileName}
146
+
# allow a library built without source to be changed to one with source
147
+
# via a passthru attribute; i.e. `my-pkg.library'.withSource`.
148
+
# this is convenient because a library derivation can be distributed as
149
+
# without-source by default but downstream projects can still build it
150
+
# with-source. We surface this regardless of whether the original library
151
+
# was built with source because that allows downstream to call this
152
+
# property unconditionally.
153
+
passthru = derivation.passthru // {
154
+
withSource = mkLibrary true;
160
+
executable = mkExecutable false;
164
+
withSource ? false,
166
+
mkLibrary withSource;
168
+
# Make a library without source; you can still use the `withSource` attribute
169
+
# on the resulting derivation to build the library with source at a later time.
170
+
library' = mkLibrary false;