shell.nix: supply `wrapFactor` helper to make standalone factor binary
This adds the shell function `wrapFactor`. This function is intended to wrap the result of calling `build.sh` in the shell environment so it can be executed outside of the nix shell. Example: ``` $ nix-shell [nix-shell] $ ./build.sh bootstrap ...build factor vm and image... [nix-shell] $ wrapFactor . exit $ ./factor ``` `wrapFactor` takes the path to the factor root dir as argument, and expects the binary `factor` and the image file `factor.image` there and uses Nixpkgs' `makeWrapper` to wrap the `factor` executable in-place with the correct `LD_LIBRARY_PATH`. Afterwards, the factor executable can be called outside of the nix-shell environment.master
parent
802bb073b0
commit
655f54af19
14
shell.nix
14
shell.nix
|
@ -15,13 +15,25 @@ let
|
||||||
udis86 # available since NixOS 19.09
|
udis86 # available since NixOS 19.09
|
||||||
openal
|
openal
|
||||||
];
|
];
|
||||||
|
runtimeLibPath = lib.makeLibraryPath runtimeLibs;
|
||||||
in
|
in
|
||||||
(mkClangShell {
|
(mkClangShell {
|
||||||
name = "factor-shell-env";
|
name = "factor-shell-env";
|
||||||
LD_LIBRARY_PATH = "/run/opengl-driver/lib:${lib.makeLibraryPath runtimeLibs}" ;
|
LD_LIBRARY_PATH = "/run/opengl-driver/lib:${runtimeLibPath}" ;
|
||||||
buildInputs = runtimeLibs ++ [
|
buildInputs = runtimeLibs ++ [
|
||||||
# for building factor
|
# for building factor
|
||||||
git
|
git
|
||||||
curl
|
curl
|
||||||
|
makeWrapper
|
||||||
];
|
];
|
||||||
|
shellHook = ''
|
||||||
|
wrapFactor () {
|
||||||
|
[ -n "$1" ] || { printf "Usage: wrapFactor <factor-root>" ; return; }
|
||||||
|
local root="$(realpath $1)"
|
||||||
|
local binary="''${root}/factor"
|
||||||
|
wrapProgram "$binary" --prefix LD_LIBRARY_PATH : ${runtimeLibPath} \
|
||||||
|
--argv0 factor
|
||||||
|
ln -sf "''${root}/factor.image" "''${root}/.factor-wrapped.image"
|
||||||
|
}
|
||||||
|
'';
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue