Skip to content

Instantly share code, notes, and snippets.

@lboklin
Last active February 15, 2018 18:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lboklin/1cac90d5262ce0217cc2f9c5e769f3d7 to your computer and use it in GitHub Desktop.
Save lboklin/1cac90d5262ce0217cc2f9c5e769f3d7 to your computer and use it in GitHub Desktop.
Running Simula on NixOS

Running Simula on NixOS

Table of Contents

Tips

Using SteamVR’s dummy driver

A dummy driver is useful for launching SteamVR for testing without any actual VR equipment.

The dummy driver is defined in /home/<user>/.local/share/Steam/config/steamvr.vrsettings. Here is an example of a working dummy driver configuration:

{
  "jsonid" : "vrsettings",
  "steamvr" : {
    // "ipd": 0.0635,
    // "forcedDriver": "null",
    // "forcedHmd": "",
    // "requireHmd": false,
    // "displayDebug": false,
    // "enableDistortion": true,
    // "displayDebugX": 0,
    // "displayDebugY": 0,
    // "sendSystemButtonToAllApps": false,
    // "loglevel": 3,
    // "background": "backgrounds/image_%d.png", (now requires fully qualified path)
    // "backgroundCameraHeight": 1.6,
    // "backgroundDomeRadius": 10.0, (0.0 == Infinite)
    // "directMode": false,
    // "usingSpeakers": true, (only works in some Unity games current)
    // "speakersForwardYawOffsetDegrees": 90.0,
    // "renderTargetMultiplier": 1.0
    // ^ Make sure your last entry does not include a trailing comma (use jslint when in doubt to verify format).
  },
  "driver_lighthouse": {
    // "disableimu": false,
    // "usedisambiguation": "tdm",
    // "disambiguationdebug": 0,
    // "primarybasestation": 0,
    // "lighthousename": "",
    // "maxincidenceangledegrees": 60.0,
    // "uselighthousedirect": true,
    // "dbhistory": false
  },
  "driver_null" : {
    // drivers are searched in alphabetical order, so you may need steamvr.forcedDriver="null" as well
    "enable": true,
    "id": "Null Driver",
    "serialNumber": "Null 4711",
    "modelNumber": "Null Model Number",
    "windowX": 100,
    "windowY": 100,
    "windowWidth": 1920,
    "windowHeight": 1080,
    "renderWidth": 1344,
    "renderHeight": 1512,
    "secondsFromVsyncToPhotons": 0.1,
    "displayFrequency": 90
  },
  "version" : "1"
}

Valve notes:

If you have other steamvr plugins intalled, e.g. the osvr plugin in /usr/lib/openvr/osvr/, remove it temporarily to avoid with annoying behavior like slow osvr startup:

~/.local/share/Steam/SteamApps/common/SteamVR/bin/linux64/vrpathreg removedriver /usr/lib/openvr/osvr
  

If you do want to use it later, enable it again:

~/.local/share/Steam/SteamApps/common/SteamVR/bin/linux64/vrpathreg adddriver /usr/lib/openvr/osvr
  

Christoph Haag warns:

Do NOT follow the comment and uncomment =”forcedDriver”: “null”=. It will result in error 126 for some reason.

Troubleshooting

Building Simula

Missing libopenvr_api.so

Problem:

Log files have been written to: /data/src/haskell/Simula/.stack-work/logs/

--  While building custom Setup.hs for package Simula-0.0.0 using:
      /data/.stack/setup-exe-cache/x86_64-linux-nix/Cabal-simple_mPHDZzAJ_2.0.1.0_ghc-8.2.2 --builddir=.stack-work/dist/x86_64-linux-nix/Cabal-2.0.1.0 build lib:Simula exe:simulavr --ghc-options " -ddump-hi -ddump-to-file -fdiagnostics-color=always"
    Process exited with code: ExitFailure 1
    Logs have been written to: /data/src/haskell/Simula/.stack-work/logs/Simula-0.0.0.log

    Configuring Simula-0.0.0...
    Preprocessing library for Simula-0.0.0..
    Building library for Simula-0.0.0..
    [ 1 of 20] Compiling Paths_Simula     ( .stack-work/dist/x86_64-linux-nix/Cabal-2.0.1.0/build/autogen/Paths_Simula.hs, .stack-work/dist/x86_64-linux-nix/Cabal-2.0.1.0/build/Paths_Simula.o ) [flags changed]
    [ 2 of 20] Compiling Simula.BaseCompositor.Event[boot] ( src/Simula/BaseCompositor/Event.hs-boot, .stack-work/dist/x86_64-linux-nix/Cabal-2.0.1.0/build/Simula/BaseCompositor/Event.o-boot ) [flags changed]
    [ 3 of 20] Compiling Simula.BaseCompositor.SceneGraph[boot] ( src/Simula/BaseCompositor/SceneGraph.hs-boot, .stack-work/dist/x86_64-linux-nix/Cabal-2.0.1.0/build/Simula/BaseCompositor/SceneGraph.o-boot ) [flags changed]
    [ 4 of 20] Compiling Simula.BaseCompositor.Types ( src/Simula/BaseCompositor/Types.hs, .stack-work/dist/x86_64-linux-nix/Cabal-2.0.1.0/build/Simula/BaseCompositor/Types.o ) [flags changed]
    [ 5 of 20] Compiling Simula.BaseCompositor.SceneGraph.Wayland[boot] ( src/Simula/BaseCompositor/SceneGraph/Wayland.hs-boot, .stack-work/dist/x86_64-linux-nix/Cabal-2.0.1.0/build/Simula/BaseCompositor/SceneGraph/Wayland.o-boot ) [flags changed]
    [ 6 of 20] Compiling Simula.BaseCompositor.Geometry ( src/Simula/BaseCompositor/Geometry.hs, .stack-work/dist/x86_64-linux-nix/Cabal-2.0.1.0/build/Simula/BaseCompositor/Geometry.o ) [flags changed]
    <command line>: can't load .so/.DLL for: libopenvr_api.so (libopenvr_api.so: cannot open shared object file: No such file or directory)

Solution:

export NIXPKGS_ALLOW_UNFREE=1
find . -name ".stack-work" -type d -exec rm -r {} + 2>/dev/null
stack --nix clean
stack --nix-pure build

Running SteamVR

VR Path Registry node (config|log) is not an array

Problem:

Error output:

VR Path Registry node config is not an array
VR Path Registry node log is not an array

Solution:

In your /home/<user>/.config/openvr/openvrpaths.vrpath file you will find something like this:

{
  "config" : null, (ref:config)
  "external_drivers" : null,
  "jsonid" : "vrpathreg",
  "log" : null, (ref:log)
  "runtime" : [ "/home/<user>/.local/share/Steam/steamapps/common/SteamVR/" ],
  "version" : 1
}

There you’ll need to change =”config”= to

"config" : [ "/home/<user>/.steam/steam/config" ],

and =”log”= to

"log" : [ "/home/<user>/.steam/steam/logs" ],

Missing libopenvr_api.so

Problem:

Error output:

/home/<user>/.local/share/Steam/steamapps/common/SteamVR/bin/linux64/vrstartup: error while loading shared libraries: libopenvr_api.so: cannot open shared object file: No such file or directory

Solution:

N/A. The cause of this is uncertain.

The issue was resolved later on for mysterious reasons.

Unable to read VR Path Registry

Problem:

Error output:

Unable to read VR Path Registry from /home/<user>/.config/openvr/openvrpaths.vrpath

Solution:

N/A. Reason for error is unknown. Disappeared later on for me.

Missing libsteam_api.so

Problem:

Error output:

/home/ludvig/.local/share/Steam/steamapps/common/SteamVR/bin/linux32/vrserver: error while loading shared libraries: libsteam_api.so: cannot open shared object file: No such file or directory
sh: pidof: command not found
Failed to execute process '/home/ludvig/.local/share/Steam/steamapps/common/SteamVR/bin/vrcompositor': 2

Solution:

~/.steam/steam/ubuntu12_32/steam-runtime/run.sh is missing on NixOS and should contain:

#!/bin/bash
#
# This is a script which runs programs in the Steam runtime

# The top level of the runtime tree
TOP=$(cd "${0%/*}" && echo ${PWD})

# Make sure we have something to run
if [ "$1" = "" ]; then
    echo "Usage: $0 program [args]"
    exit 1
fi

# Note that we put the Steam runtime first
# If ldd on a program shows any library in the system path, then that program
# may not run in the Steam runtime.
export STEAM_RUNTIME="${TOP}"

host_library_paths=

if [ "${STEAM_RUNTIME_PREFER_HOST_LIBRARIES-}" != "0" ]; then
    while read -r line; do
        # If line starts with a leading / and contains :, it's a new path prefix
        if [[ "$line" =~ ^/.*: ]]
        then
            library_path_prefix=`echo $line | cut -d: -f1`

            host_library_paths=$host_library_paths$library_path_prefix:
        fi
    done <<< "$(/sbin/ldconfig -XNv 2> /dev/null)"

    host_library_paths="$STEAM_RUNTIME/pinned_libs_32:$STEAM_RUNTIME/pinned_libs_64:$host_library_paths"
fi

steam_runtime_library_paths="$host_library_paths$STEAM_RUNTIME/i386/lib/i386-linux-gnu:$STEAM_RUNTIME/i386/lib:$STEAM_RUNTIME/i386/usr/lib/i386-linux-gnu:$STEAM_RUNTIME/i386/usr/lib:$STEAM_RUNTIME/amd64/lib/x86_64-linux-gnu:$STEAM_RUNTIME/amd64/lib:$STEAM_RUNTIME/amd64/usr/lib/x86_64-linux-gnu:$STEAM_RUNTIME/amd64/usr/lib"

if [ "$1" = "--print-steam-runtime-library-paths" ]; then
    echo "$steam_runtime_library_paths"
    exit 0
fi

export LD_LIBRARY_PATH="$steam_runtime_library_paths:${LD_LIBRARY_PATH-}"

exec "$@"

# vi: ts=4 sw=4 expandtab

Lots of missing commands

Solution:

nix-shell -p bash lsb-release usbutils procps --run 'steam-run bash -c "export PATH=$PATH ; ~/.local/share/Steam/steamapps/common/SteamVR/bin/vrmonitor.sh"'

Running Simula

Can’t find swrast in even after running ./swrast.sh

Problem:

Error output:

Loading module '/nix/store/by05skki8asv19dqd4q5nawcl29sxsm2-weston-3.0.0/lib/libweston-3/x11-backend.so'
Loading module '/nix/store/by05skki8asv19dqd4q5nawcl29sxsm2-weston-3.0.0/lib/libweston-3/gl-renderer.so'
EGL client extensions: EGL_EXT_client_extensions EGL_EXT_platform_base
EGL_KHR_client_get_all_proc_addresses EGL_KHR_debug
EGL_EXT_platform_wayland EGL_EXT_platform_x11
EGL_MESA_platform_gbm
libEGL warning: DRI2: failed to authenticate
libEGL warning: DRI2: failed to open swrast (search paths /run/opengl-driver/lib/dri)
libEGL warning: DRI2: failed to open swrast (search paths /run/opengl-driver/lib/dri)
failed to initialize display
EGL error state: EGL_NOT_INITIALIZED (0x3001)
sh: lsusb: command not found
sh: lsusb: command not found
sh: lsusb: command not found
sh: lsusb: command not found
sh: lsusb: command not found
sh: lsusb: command not found
sh: lsusb: command not found
sh: pidof: command not found
Failed to execute process '/home/<user>/.local/share/Steam/steamapps/common/SteamVR/bin/linux64/vrserver': 2
sh: pidof: command not found
Failed to execute process '/home/<user>/.local/share/Steam/steamapps/common/SteamVR/bin/linux64/vrmonitor': 2
simulavr: VRInitError_IPC_ConnectFailedAfterMultipleAttempts
CallStack (from HasCallStack):
error, called at src/Simula/ViveCompositor/ViveCompositor.hs:416:41 in Simula-0.0.0-9QaZeZwgKYRCbbXYyycaaz:Simula.ViveCompositor.ViveCompositor

Solution:

Good solution TBD. A hacky and risky way of solving this is running:

sudo rm -r /run/opengl-driver
./swrast.sh

This solution may ruin your system (until reebot?)

Mysterious error

Problem:

Error output:

Loading module '/nix/store/by05skki8asv19dqd4q5nawcl29sxsm2-weston-3.0.0/lib/libweston-3/x11-backend.so'
Loading module '/nix/store/by05skki8asv19dqd4q5nawcl29sxsm2-weston-3.0.0/lib/libweston-3/gl-renderer.so'
EGL client extensions: EGL_EXT_client_extensions EGL_EXT_platform_base
               EGL_KHR_client_get_all_proc_addresses EGL_KHR_debug
               EGL_EXT_platform_wayland EGL_EXT_platform_x11
               EGL_MESA_platform_gbm
libEGL warning: DRI2: failed to authenticate
warning: EGL_EXT_buffer_age not supported. Performance could be affected.
warning: neither EGL_EXT_swap_buffers_with_damage or EGL_KHR_swap_buffers_with_damage is supported. Performance could be affected.
EGL_KHR_surfaceless_context available
EGL version: 1.4 (DRI2)
EGL vendor: Mesa Project
EGL client APIs: OpenGL OpenGL_ES
EGL extensions: EGL_KHR_cl_event2 EGL_KHR_config_attribs EGL_KHR_create_context
               EGL_KHR_create_context_no_error EGL_KHR_fence_sync
               EGL_KHR_get_all_proc_addresses EGL_KHR_gl_colorspace
               EGL_KHR_gl_renderbuffer_image EGL_KHR_gl_texture_2D_image
               EGL_KHR_gl_texture_3D_image EGL_KHR_gl_texture_cubemap_image
               EGL_KHR_image_base EGL_KHR_no_config_context
               EGL_KHR_reusable_sync EGL_KHR_surfaceless_context
               EGL_KHR_wait_sync EGL_MESA_configless_context
               EGL_MESA_drm_image
GL version: OpenGL ES 3.0 Mesa 17.3.3
GLSL version: OpenGL ES GLSL ES 3.00
GL vendor: VMware, Inc.
GL renderer: llvmpipe (LLVM 5.0, 128 bits)
GL extensions: GL_EXT_blend_minmax GL_EXT_multi_draw_arrays
               GL_EXT_texture_compression_dxt1 GL_EXT_texture_format_BGRA8888
               GL_OES_compressed_ETC1_RGB8_texture GL_OES_depth24
               GL_OES_element_index_uint GL_OES_fbo_render_mipmap
               GL_OES_mapbuffer GL_OES_rgb8_rgba8 GL_OES_standard_derivatives
               GL_OES_stencil8 GL_OES_texture_3D GL_OES_texture_float
               GL_OES_texture_float_linear GL_OES_texture_half_float
               GL_OES_texture_half_float_linear GL_OES_texture_npot
               GL_OES_vertex_half_float GL_EXT_texture_sRGB_decode
               GL_OES_EGL_image GL_OES_depth_texture
               GL_OES_packed_depth_stencil GL_EXT_texture_type_2_10_10_10_REV
               GL_OES_get_program_binary GL_APPLE_texture_max_level
               GL_EXT_discard_framebuffer GL_EXT_read_format_bgra
               GL_EXT_frag_depth GL_NV_fbo_color_attachments
               GL_OES_EGL_image_external GL_OES_EGL_sync
               GL_OES_vertex_array_object GL_ANGLE_texture_compression_dxt3
               GL_ANGLE_texture_compression_dxt5 GL_EXT_texture_rg
               GL_EXT_unpack_subimage GL_NV_draw_buffers GL_NV_read_buffer
               GL_NV_read_depth GL_NV_read_depth_stencil GL_NV_read_stencil
               GL_EXT_draw_buffers GL_EXT_map_buffer_range GL_KHR_debug
               GL_OES_depth_texture_cube_map GL_OES_required_internalformat
               GL_OES_surfaceless_context GL_EXT_color_buffer_float
               GL_EXT_separate_shader_objects GL_EXT_shader_integer_mix
               GL_EXT_base_instance GL_EXT_compressed_ETC1_RGB8_sub_texture
               GL_EXT_copy_image GL_EXT_draw_buffers_indexed
               GL_EXT_draw_elements_base_vertex GL_EXT_polygon_offset_clamp
               GL_EXT_texture_border_clamp GL_KHR_context_flush_control
               GL_OES_copy_image GL_OES_draw_buffers_indexed
               GL_OES_draw_elements_base_vertex GL_OES_texture_border_clamp
               GL_OES_texture_stencil8 GL_EXT_blend_func_extended
               GL_KHR_no_error GL_EXT_clip_cull_distance
               GL_MESA_shader_integer_functions
GL ES 2 renderer features:
               read-back format: BGRA
               wl_shm sub-image to texture: yes
               EGL Wayland extension: no
Using gl renderer
creating a keymap file for 55494 bytes failed: No such file or directory
Failed to create X11 input
sh: lsusb: command not found
sh: lsusb: command not found
sh: lsusb: command not found
sh: lsusb: command not found
sh: lsusb: command not found
sh: lsusb: command not found
sh: lsusb: command not found
sh: pidof: command not found
Failed to execute process '/home/<user>/.local/share/Steam/steamapps/common/SteamVR/bin/linux64/vrserver': 2
sh: pidof: command not found
Failed to execute process '/home/<user>/.local/share/Steam/steamapps/common/SteamVR/bin/linux64/vrmonitor': 2
simulavr: VRInitError_IPC_ConnectFailedAfterMultipleAttempts
CallStack (from HasCallStack):
 error, called at src/Simula/ViveCompositor/ViveCompositor.hs:416:41 in Simula-0.0.0-9QaZeZwgKYRCbbXYyycaaz:Simula.ViveCompositor.ViveCompositor

Solution:

WIP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment