mirror of
https://gitlab.com/nonguix/nonguix.git
synced 2024-11-22 00:18:07 +01:00
nongnu: multiarch-container: Fix missing module on foreign distros.
Fixes #277. See discussion in above issue for details and some education on what went wrong here. In short, we didn't capture the needed (guix build utils) module in the container script. On a Guix System this didn't cause any problems as guix modules are found through set Guile environment variables. But on a foreign distro these weren't set without hacky workarounds. This prevented Steam from launching with a "no code for module" error. * nonguix/multiarch-container.scm (make-container-wrapper)[make-container-wrapper]: Use 'with-imported-modules' for (guix build utils).
This commit is contained in:
parent
a328f6c91f
commit
7dd68696a2
1 changed files with 131 additions and 130 deletions
|
@ -239,136 +239,137 @@ in a sandboxed FHS environment."
|
||||||
in a sandboxed FHS environment."
|
in a sandboxed FHS environment."
|
||||||
(program-file
|
(program-file
|
||||||
(ngc-wrapper-name container)
|
(ngc-wrapper-name container)
|
||||||
#~(begin
|
(with-imported-modules '((guix build utils))
|
||||||
(use-modules (guix build utils))
|
#~(begin
|
||||||
(define (preserve-var var)
|
(use-modules (guix build utils))
|
||||||
(string-append "--preserve=" var))
|
(define (preserve-var var)
|
||||||
(define* (add-path path #:key writable?)
|
(string-append "--preserve=" var))
|
||||||
(let ((opt (if writable?
|
(define* (add-path path #:key writable?)
|
||||||
"--share="
|
(let ((opt (if writable?
|
||||||
"--expose=")))
|
"--share="
|
||||||
(if (pair? path)
|
"--expose=")))
|
||||||
(string-append opt (car path) "=" (cdr path))
|
(if (pair? path)
|
||||||
(string-append opt path))))
|
(string-append opt (car path) "=" (cdr path))
|
||||||
(define (exists-> file)
|
(string-append opt path))))
|
||||||
(if (and file (file-exists? file))
|
(define (exists-> file)
|
||||||
`(,file) '()))
|
(if (and file (file-exists? file))
|
||||||
(let* ((run #$(file-append fhs-internal "/bin/" (ngc-internal-name container)))
|
`(,file) '()))
|
||||||
(manifest-file #$(file-append fhs-manifest))
|
(let* ((run #$(file-append fhs-internal "/bin/" (ngc-internal-name container)))
|
||||||
(xdg-runtime (getenv "XDG_RUNTIME_DIR"))
|
(manifest-file #$(file-append fhs-manifest))
|
||||||
(home (getenv "HOME"))
|
(xdg-runtime (getenv "XDG_RUNTIME_DIR"))
|
||||||
(sandbox-home (or (getenv "GUIX_SANDBOX_HOME")
|
(home (getenv "HOME"))
|
||||||
(string-append home "/" #$(ngc-sandbox-home container))))
|
(sandbox-home (or (getenv "GUIX_SANDBOX_HOME")
|
||||||
(preserved-env '("^DBUS_"
|
(string-append home "/" #$(ngc-sandbox-home container))))
|
||||||
"^DISPLAY$"
|
(preserved-env '("^DBUS_"
|
||||||
"^DRI_PRIME$"
|
"^DISPLAY$"
|
||||||
"^GDK_SCALE$" ; For UI scaling.
|
"^DRI_PRIME$"
|
||||||
"^GUIX_LOCPATH$" ; For pressure-vessel locales.
|
"^GDK_SCALE$" ; For UI scaling.
|
||||||
;; For startup of added non-Steam games as it
|
"^GUIX_LOCPATH$" ; For pressure-vessel locales.
|
||||||
;; seems they start in an early environment
|
;; For startup of added non-Steam games as it
|
||||||
;; before our additional settings. (Likely
|
;; seems they start in an early environment
|
||||||
;; this can be removed when rewritten to use
|
;; before our additional settings. (Likely
|
||||||
;; --emulate-fhs from upstream.) Note that
|
;; this can be removed when rewritten to use
|
||||||
;; this is explicitly set below. We could
|
;; --emulate-fhs from upstream.) Note that
|
||||||
;; preserve what is set before launching the
|
;; this is explicitly set below. We could
|
||||||
;; container, but any such directories would
|
;; preserve what is set before launching the
|
||||||
;; need to be shared with the container as
|
;; container, but any such directories would
|
||||||
;; well; this is not needed currently.
|
;; need to be shared with the container as
|
||||||
"^LD_LIBRARY_PATH$"
|
;; well; this is not needed currently.
|
||||||
"^MANGOHUD" ; For MangoHud configuration.
|
"^LD_LIBRARY_PATH$"
|
||||||
"^PRESSURE_VESSEL_" ; For pressure vessel options.
|
"^MANGOHUD" ; For MangoHud configuration.
|
||||||
"_PROXY$"
|
"^PRESSURE_VESSEL_" ; For pressure vessel options.
|
||||||
"_proxy$"
|
"_PROXY$"
|
||||||
;; To allow workaround for upstream bug
|
"_proxy$"
|
||||||
;; <https://github.com/ValveSoftware/steam-for-linux/issues/9306>
|
;; To allow workaround for upstream bug
|
||||||
;; and tracked on our end as
|
;; <https://github.com/ValveSoftware/steam-for-linux/issues/9306>
|
||||||
;; <https://gitlab.com/nonguix/nonguix/-/issues/267>.
|
;; and tracked on our end as
|
||||||
;; TODO: Remove once upstream fixes this bug.
|
;; <https://gitlab.com/nonguix/nonguix/-/issues/267>.
|
||||||
"^QT_X11_NO_MITSHM$"
|
;; TODO: Remove once upstream fixes this bug.
|
||||||
"^SDL_"
|
"^QT_X11_NO_MITSHM$"
|
||||||
"^STEAM_"
|
"^SDL_"
|
||||||
"^SSL_" ; SSL certificate environment, needed by curl for Heroic.
|
"^STEAM_"
|
||||||
"^VDPAU_DRIVER_PATH$" ; For VDPAU drivers.
|
"^SSL_" ; SSL certificate environment, needed by curl for Heroic.
|
||||||
"^XAUTHORITY$"
|
"^VDPAU_DRIVER_PATH$" ; For VDPAU drivers.
|
||||||
;; Matching all ^XDG_ vars causes issues
|
"^XAUTHORITY$"
|
||||||
;; discussed in 80decf05.
|
;; Matching all ^XDG_ vars causes issues
|
||||||
"^XDG_DATA_HOME$"
|
;; discussed in 80decf05.
|
||||||
"^XDG_RUNTIME_DIR$"
|
"^XDG_DATA_HOME$"
|
||||||
;; The following are useful for debugging.
|
"^XDG_RUNTIME_DIR$"
|
||||||
"^CAPSULE_DEBUG$"
|
;; The following are useful for debugging.
|
||||||
"^G_MESSAGES_DEBUG$"
|
"^CAPSULE_DEBUG$"
|
||||||
"^LD_DEBUG$"
|
"^G_MESSAGES_DEBUG$"
|
||||||
"^LIBGL_DEBUG$"))
|
"^LD_DEBUG$"
|
||||||
(expose `("/dev/bus/usb" ; Needed for libusb.
|
"^LIBGL_DEBUG$"))
|
||||||
"/dev/dri"
|
(expose `("/dev/bus/usb" ; Needed for libusb.
|
||||||
"/dev/input" ; Needed for controller input.
|
"/dev/dri"
|
||||||
"/dev/uinput" ; Needed for Steam Input.
|
"/dev/input" ; Needed for controller input.
|
||||||
,@(exists-> "/dev/nvidia0") ; needed for nvidia proprietary driver
|
"/dev/uinput" ; Needed for Steam Input.
|
||||||
,@(exists-> "/dev/nvidiactl")
|
,@(exists-> "/dev/nvidia0") ; needed for nvidia proprietary driver
|
||||||
,@(exists-> "/dev/nvidia-modeset")
|
,@(exists-> "/dev/nvidiactl")
|
||||||
,@(exists-> "/etc/machine-id")
|
,@(exists-> "/dev/nvidia-modeset")
|
||||||
"/etc/localtime" ; Needed for correct time zone.
|
,@(exists-> "/etc/machine-id")
|
||||||
"/sys/class/drm" ; Needed for hw monitoring like MangoHud.
|
"/etc/localtime" ; Needed for correct time zone.
|
||||||
"/sys/class/hwmon" ; Needed for hw monitoring like MangoHud.
|
"/sys/class/drm" ; Needed for hw monitoring like MangoHud.
|
||||||
"/sys/class/hidraw" ; Needed for devices like the Valve Index.
|
"/sys/class/hwmon" ; Needed for hw monitoring like MangoHud.
|
||||||
"/sys/class/input" ; Needed for controller input.
|
"/sys/class/hidraw" ; Needed for devices like the Valve Index.
|
||||||
,@(exists-> "/sys/class/power_supply") ; Needed for power monitoring like MangoHud.
|
"/sys/class/input" ; Needed for controller input.
|
||||||
,@(exists-> "/sys/class/powercap") ; Needed for power monitoring like MangoHud.
|
,@(exists-> "/sys/class/power_supply") ; Needed for power monitoring like MangoHud.
|
||||||
"/sys/dev"
|
,@(exists-> "/sys/class/powercap") ; Needed for power monitoring like MangoHud.
|
||||||
"/sys/devices"
|
"/sys/dev"
|
||||||
,@(exists-> "/var/run/dbus")
|
"/sys/devices"
|
||||||
#$@(ngc-exposed container)))
|
,@(exists-> "/var/run/dbus")
|
||||||
;; /dev/hidraw is needed for SteamVR to access the HMD, although here we
|
#$@(ngc-exposed container)))
|
||||||
;; share all hidraw devices. Instead we could filter to only share specific
|
;; /dev/hidraw is needed for SteamVR to access the HMD, although here we
|
||||||
;; device. See, for example, this script:
|
;; share all hidraw devices. Instead we could filter to only share specific
|
||||||
;; https://arvchristos.github.io/post/matching-dev-hidraw-devices-with-physical-devices/
|
;; device. See, for example, this script:
|
||||||
(share `(,@(find-files "/dev" "hidraw")
|
;; https://arvchristos.github.io/post/matching-dev-hidraw-devices-with-physical-devices/
|
||||||
"/dev/shm"
|
(share `(,@(find-files "/dev" "hidraw")
|
||||||
;; "/tmp/.X11-unix" is needed for bwrap, and "/tmp" more generally
|
"/dev/shm"
|
||||||
;; for writing things like crash dumps and "steam_chrome_shm".
|
;; "/tmp/.X11-unix" is needed for bwrap, and "/tmp" more generally
|
||||||
"/tmp"
|
;; for writing things like crash dumps and "steam_chrome_shm".
|
||||||
,(string-append sandbox-home "=" home)
|
"/tmp"
|
||||||
,@(exists-> (string-append home "/.config/pulse"))
|
,(string-append sandbox-home "=" home)
|
||||||
,@(exists-> (string-append xdg-runtime "/pulse"))
|
,@(exists-> (string-append home "/.config/pulse"))
|
||||||
,@(exists-> (string-append xdg-runtime "/bus"))
|
,@(exists-> (string-append xdg-runtime "/pulse"))
|
||||||
,@(exists-> (getenv "XAUTHORITY"))
|
,@(exists-> (string-append xdg-runtime "/bus"))
|
||||||
#$@(ngc-shared container)))
|
,@(exists-> (getenv "XAUTHORITY"))
|
||||||
(DEBUG (equal? (getenv "DEBUG") "1"))
|
#$@(ngc-shared container)))
|
||||||
(args (cdr (command-line)))
|
(DEBUG (equal? (getenv "DEBUG") "1"))
|
||||||
(command (if DEBUG '()
|
(args (cdr (command-line)))
|
||||||
`("--" ,run ,@args))))
|
(command (if DEBUG '()
|
||||||
;; Set this so that e.g. non-Steam games added to Steam will launch
|
`("--" ,run ,@args))))
|
||||||
;; properly. It seems otherwise they don't make it to launching
|
;; Set this so that e.g. non-Steam games added to Steam will launch
|
||||||
;; Steam's pressure-vessel container (for Proton games).
|
;; properly. It seems otherwise they don't make it to launching
|
||||||
(setenv "LD_LIBRARY_PATH" "/lib64:/lib")
|
;; Steam's pressure-vessel container (for Proton games).
|
||||||
;; Set this so Steam's pressure-vessel container does not need to
|
(setenv "LD_LIBRARY_PATH" "/lib64:/lib")
|
||||||
;; generate locales, improving startup time. This needs to be set to
|
;; Set this so Steam's pressure-vessel container does not need to
|
||||||
;; the "usual" path, probably so they are included in the
|
;; generate locales, improving startup time. This needs to be set to
|
||||||
;; pressure-vessel container.
|
;; the "usual" path, probably so they are included in the
|
||||||
(setenv "GUIX_LOCPATH" "/usr/lib/locale")
|
;; pressure-vessel container.
|
||||||
;; By default VDPAU drivers are searched for in libvdpau's store
|
(setenv "GUIX_LOCPATH" "/usr/lib/locale")
|
||||||
;; path, so set this path to where the drivers will actually be
|
;; By default VDPAU drivers are searched for in libvdpau's store
|
||||||
;; located in the container.
|
;; path, so set this path to where the drivers will actually be
|
||||||
(setenv "VDPAU_DRIVER_PATH" "/lib64/vdpau")
|
;; located in the container.
|
||||||
(format #t "\n* Launching ~a in sandbox: ~a.\n\n"
|
(setenv "VDPAU_DRIVER_PATH" "/lib64/vdpau")
|
||||||
#$(package-name (ngc-wrap-package container)) sandbox-home)
|
(format #t "\n* Launching ~a in sandbox: ~a.\n\n"
|
||||||
(when DEBUG
|
#$(package-name (ngc-wrap-package container)) sandbox-home)
|
||||||
(format #t "* DEBUG set to 1: Starting shell. Launch application manually with: ~a.\n\n"
|
(when DEBUG
|
||||||
#$(ngc-internal-name container)))
|
(format #t "* DEBUG set to 1: Starting shell. Launch application manually with: ~a.\n\n"
|
||||||
(mkdir-p sandbox-home)
|
#$(ngc-internal-name container)))
|
||||||
(invoke #$(file-append pulseaudio "/bin/pulseaudio")
|
(mkdir-p sandbox-home)
|
||||||
"--start"
|
(invoke #$(file-append pulseaudio "/bin/pulseaudio")
|
||||||
"--exit-idle-time=60")
|
"--start"
|
||||||
(apply invoke
|
"--exit-idle-time=60")
|
||||||
`("guix" "shell"
|
(apply invoke
|
||||||
"--container" "--no-cwd" "--network"
|
`("guix" "shell"
|
||||||
,@(map preserve-var preserved-env)
|
"--container" "--no-cwd" "--network"
|
||||||
,@(map add-path expose)
|
,@(map preserve-var preserved-env)
|
||||||
,@(map (lambda (item)
|
,@(map add-path expose)
|
||||||
(add-path item #:writable? #t))
|
,@(map (lambda (item)
|
||||||
share)
|
(add-path item #:writable? #t))
|
||||||
"-m" ,manifest-file
|
share)
|
||||||
,@command))))))
|
"-m" ,manifest-file
|
||||||
|
,@command)))))))
|
||||||
|
|
||||||
(define (make-container-manifest container fhs-internal)
|
(define (make-container-manifest container fhs-internal)
|
||||||
"Return a scheme file-like object to be used as package manifest for FHS
|
"Return a scheme file-like object to be used as package manifest for FHS
|
||||||
|
|
Loading…
Reference in a new issue