1 { pkgs ? import <nixpkgs> {} }:
4 mkClangShell = mkShell.override { stdenv = clangStdenv; };
5 runtimeLibs = with xorg; [
16 udis86 # available since NixOS 19.09
22 runtimeLibPath = "/run/opengl-driver/lib:" + lib.makeLibraryPath runtimeLibs;
25 name = "factor-shell-env";
26 LD_LIBRARY_PATH = runtimeLibPath ;
27 buildInputs = runtimeLibs ++ [
34 # Set Gdk pixbuf loaders file to the one from the build dependencies here
35 unset GDK_PIXBUF_MODULE_FILE
36 # Defined in gdk-pixbuf setup hook
37 findGdkPixbufLoaders "${pkgs.librsvg}"
40 [ -n "$1" ] || { printf "Usage: wrapFactor <factor-root>" ; return; }
41 local root="$(realpath $1)"
42 local binary="''${root}/factor"
43 local wrapped="''${root}/.factor-wrapped"
44 # Remove the wrapped binary if a new VM has been compiled
45 ${lib.getBin file}/bin/file "$binary" |grep ELF >/dev/null && rm -f "$wrapped"
46 # Restore the factor binary if it was already wrapped
47 [ -e "$wrapped" ] && { mv "$wrapped" "$binary" ; }
48 wrapProgram "$binary" --prefix LD_LIBRARY_PATH : ${runtimeLibPath} \
49 --set GDK_PIXBUF_MODULE_FILE "$GDK_PIXBUF_MODULE_FILE" \
51 ln -sf "''${root}/factor.image" "''${root}/.factor-wrapped.image"