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