add support for nix-shell (nix-shell '<nixpkgs>' -A gintro-test)
This commit is contained in:
parent
156006da2a
commit
170e650e53
|
@ -10,10 +10,29 @@ let
|
||||||
optionals (deps != []) ((getInputsFn (head deps)) ++
|
optionals (deps != []) ((getInputsFn (head deps)) ++
|
||||||
(getRecursiveInputs getInputsFn (head deps).nimDeps) ++
|
(getRecursiveInputs getInputsFn (head deps).nimDeps) ++
|
||||||
(getRecursiveInputs getInputsFn (tail deps)));
|
(getRecursiveInputs getInputsFn (tail deps)));
|
||||||
|
|
||||||
rNativeBuildInputs =
|
rNativeBuildInputs =
|
||||||
nativeBuildInputs ++ (getRecursiveInputs (i: i.nativeBuildInputs) nimDeps);
|
nativeBuildInputs ++ (getRecursiveInputs (i: i.nativeBuildInputs) nimDeps);
|
||||||
|
|
||||||
rBuildInputs =
|
rBuildInputs =
|
||||||
buildInputs ++ (getRecursiveInputs (i: i.buildInputs) nimDeps);
|
buildInputs ++ (getRecursiveInputs (i: i.buildInputs) nimDeps);
|
||||||
|
|
||||||
|
copyNimDeps = ''
|
||||||
|
mkdir -p $NIMBLE_DIR/pkgs
|
||||||
|
if [ ! -f $NIMBLE_DIR/packages_official.json ]; then
|
||||||
|
echo "[]" > $NIMBLE_DIR/packages_official.json
|
||||||
|
fi
|
||||||
|
'' + toString (map (dep: ''
|
||||||
|
if [ -d ${dep}/.nimble ]; then
|
||||||
|
cp -R ${dep}/.nimble/pkgs $NIMBLE_DIR
|
||||||
|
else
|
||||||
|
cp -R ${dep} $NIMBLE_DIR/pkgs/${dep.name}
|
||||||
|
fi
|
||||||
|
''
|
||||||
|
) nimDeps) + ''
|
||||||
|
# nimble >= 0.20.0 wants to store nimblemeta.json here
|
||||||
|
chmod -R u+w $NIMBLE_DIR/pkgs
|
||||||
|
'';
|
||||||
in
|
in
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
name = name;
|
name = name;
|
||||||
|
@ -24,34 +43,29 @@ stdenv.mkDerivation {
|
||||||
nimDeps = nimDeps;
|
nimDeps = nimDeps;
|
||||||
patchPhase = patchPhase;
|
patchPhase = patchPhase;
|
||||||
LD_LIBRARY_PATH = makeLibraryPath (rBuildInputs ++ rNativeBuildInputs);
|
LD_LIBRARY_PATH = makeLibraryPath (rBuildInputs ++ rNativeBuildInputs);
|
||||||
|
|
||||||
buildPhase = ''
|
buildPhase = ''
|
||||||
HOME=$TMPDIR
|
HOME=$TMPDIR
|
||||||
mkdir -p $HOME/.nimble/pkgs
|
NIMBLE_DIR=$HOME/.nimble
|
||||||
echo "[]" > $HOME/.nimble/packages_official.json
|
'' + copyNimDeps + ''
|
||||||
'' + toString (map (dep: ''
|
|
||||||
if [ -d ${dep}/.nimble ]; then
|
|
||||||
cp -R ${dep}/.nimble/pkgs $HOME/.nimble/
|
|
||||||
else
|
|
||||||
cp -R ${dep} $HOME/.nimble/pkgs/${dep.name}
|
|
||||||
fi
|
|
||||||
# nimble >= 0.20.0 wants to store a nimblemeta.json here
|
|
||||||
chmod u+w $HOME/.nimble/pkgs/${dep.name}
|
|
||||||
''
|
|
||||||
) nimDeps) + ''
|
|
||||||
nimble install
|
nimble install
|
||||||
'';
|
'';
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
mkdir $out
|
mkdir $out
|
||||||
nimbleDir=$TMPDIR/.nimble
|
if [ -d $NIMBLE_DIR/bin ]; then
|
||||||
if [ -d $nimbleDir/bin ]; then
|
cp -RL $NIMBLE_DIR/bin $out
|
||||||
cp -RL $nimbleDir/bin $out
|
|
||||||
fi
|
fi
|
||||||
numberNimFiles=$(find $nimbleDir/pkgs/${name} -type f -name "*.nim" | wc -l)
|
numberNimFiles=$(find $NIMBLE_DIR/pkgs/${name} -type f -name "*.nim" | wc -l)
|
||||||
numberDirectories=$(find $nimbleDir/pkgs/${name} -mindepth 1 -type d | wc -l)
|
numberDirectories=$(find $NIMBLE_DIR/pkgs/${name} -mindepth 1 -type d | wc -l)
|
||||||
if [ $numberNimFiles -gt 0 ] || [ $numberDirectories -gt 0 ]; then
|
if [ $numberNimFiles -gt 0 ] || [ $numberDirectories -gt 0 ]; then
|
||||||
mkdir -p $out/.nimble
|
mkdir -p $out/.nimble
|
||||||
cp -R $nimbleDir/pkgs $out/.nimble
|
cp -R $NIMBLE_DIR/pkgs $out/.nimble
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
shellHook = ''
|
||||||
|
export NIMBLE_DIR=$PWD/.nimble
|
||||||
|
'' + copyNimDeps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue