···11-#!/usr/bin/env nu
22-# SPDX-License-Identifier: AGPL-3.0-only
33-# SPDX-FileCopyrightText: MatrixFurry <matrix@matrixfurry.com>
44-55-const axr = path self ..
66-const registry = "registry.gitlab.com"
77-const project = "matrixfurry/xr-packages"
88-99-def main [
1010- image: string # name of the image to build
1111- --username (-u): string
1212- --token (-t): string
1313- --no-login (-l) # Use this if the machine is already authenticated with the container registry
1414-] {
1515- let username = $username | default $env.CI_REGISTRY_USERNAME?
1616- let token = $token | default $env.CI_REGISTRY_PASSWORD?
1717- let registry_image = [$registry $project $image] | str join '/'
1818-1919- if ($username | is-empty) and not $no_login {
2020- error make {
2121- msg: "Username not provided"
2222- help: "Please provide a username with --username or $env.CI_REGISTRY_USERNAME"
2323- }
2424- }
2525- if ($token | is-empty) and not $no_login {
2626- error make {
2727- msg: "Token not provided"
2828- help: "Please provide a deployment token with --token or $env.CI_REGISTRY_PASSWORD"
2929- }
3030- }
3131-3232- if not $no_login {podman login $registry -u $username -p $token}
3333- podman build -t $registry_image ($axr | path join "oci" $image)
3434- podman push $registry_image
3535-}
-36
envision-oci/pkg-install.nu
···11-#!/usr/bin/env nu
22-# SPDX-License-Identifier: AGPL-3.0-only
33-# SPDX-FileCopyrightText: MatrixFurry <matrix@matrixfurry.com>
44-55-use std log
66-77-def main [
88- --uninstall (-u)
99- staged_path?: string
1010-] {
1111- if not $uninstall {
1212- if ($staged_path | is-empty) {
1313- error make {msg: "please provide a path to the extracted archive"}
1414- }
1515-1616- cd $staged_path
1717- log info $"Installing from (pwd)"
1818-1919- chmod +x ./Envision-x86_64.AppImage
2020- ./Envision-x86_64.AppImage --appimage-extract
2121-2222- open squashfs-root/org.gabmus.envision.Devel.desktop
2323- | str replace "Exec=envision" "Exec=sh -c 'export PATH=$HOME/.local/bin/envision-oci-shim:$PATH; exec envision --skip-dependency-check'"
2424- | save -f ~/.local/share/applications/org.gabmus.envision.Devel.desktop
2525-2626- rm -rf ~/.local/bin/envision-oci-shim
2727- cp -r oci-shim ~/.local/bin/envision-oci-shim
2828- chmod 744 ~/.local/bin/envision-oci-shim/*
2929-3030- cp -f squashfs-root/org.gabmus.envision.Devel.svg ~/.local/share/icons/hicolor/scalable/apps/org.gabmus.envision.Devel.svg
3131- } else {
3232- rm -f ~/.local/share/icons/hicolor/scalable/apps/org.gabmus.envision.Devel.svg
3333- rm -f ~/.local/share/applications/org.gabmus.envision.Devel.desktop
3434- rm -rf ~/.local/bin/envision-oci-shim
3535- }
3636-}
-41
envision-oci/pkg.nu
···11-#!/usr/bin/env nu
22-# SPDX-License-Identifier: AGPL-3.0-only
33-# SPDX-FileCopyrightText: MatrixFurry <matrix@matrixfurry.com>
44-55-const axr = path self ..
66-77-# Upload envision-oci package to GitLab for AtomicXR Homebrew
88-def main [
99- job: int # envision GitLab job ID
1010- version: int # envision-oci package version
1111- token?: string # GitLab deploy token
1212-] {
1313- cd (mktemp -dt)
1414-1515- let token = $token | default $env.DEPLOY_TOKEN?
1616- if ($token | is-empty) {
1717- error make {
1818- msg: "Either --token or $env.DEPLOY_TOKEN is required"
1919- }
2020- }
2121-2222- mkdir pkg
2323- cp ($axr | path join "envision-oci/pkg-install.nu") pkg/install.nu
2424- chmod 744 pkg/install.nu
2525-2626- mkdir pkg/oci-shim
2727- cp ($axr | path join "envision-oci/shim.nu") pkg/oci-shim/cmake
2828- cp ($axr | path join "envision-oci/shim.nu") pkg/oci-shim/cargo
2929- chmod 744 pkg/oci-shim/*
3030-3131- http get $"https://gitlab.com/gabmus/envision/-/jobs/($job)/artifacts/raw/Envision-x86_64.AppImage"
3232- | save -p pkg/Envision-x86_64.AppImage
3333-3434- {envision_version: $job} | to json | save -p pkg/meta.json
3535-3636- tar -C pkg -zcvf envision-oci.tar.gz .
3737-3838- open --raw $"envision-oci.tar.gz"
3939- | into binary
4040- | http put --content-type application/gzip $"https://gitlab.com/api/v4/projects/75293878/packages/generic/envision-oci/($version)/envision-oci.tar.gz" -H {DEPLOY-TOKEN: $token}
4141-}
-42
envision-oci/shim.nu
···11-#!/usr/bin/env nu
22-# SPDX-License-Identifier: AGPL-3.0-only
33-# SPDX-FileCopyrightText: MatrixFurry <matrix@matrixfurry.com>
44-55-# The purpose of this shim is to make Envision build software in a OCI container, with preinstalled build dependencies.
66-# Just rename this script to the desired build tool, then prepend it to Envision's PATH environment variable. It will
77-# run instead of the system build tool.
88-99-use std log
1010-1111-const cmd = path self | path basename
1212-const image = "registry.gitlab.com/matrixfurry/xr-packages/xr-multi:latest"
1313-1414-def main --wrapped [...args] {
1515- let args = $args | where ($it | is-not-empty)
1616-1717- # HACK: I don't exactly know why the source path gets appended to the command line
1818- let last_as_workdir = $cmd == "cmake" and $args.0 == "-B"
1919- let workdir = if $last_as_workdir {
2020- $args | last
2121- } else {
2222- pwd
2323- }
2424- let args = if $last_as_workdir {
2525- $args | drop 1
2626- } else {
2727- $args
2828- }
2929-3030- log info $"Working directory: ($workdir)"
3131- log info $"Running in OCI container via shim: ($cmd) ($args | str join ' ')"
3232-3333- # TODO: Use image from AtomicXR container registry
3434- podman run ...[
3535- --security-opt label=disable
3636- --security-opt apparmor=unconfined
3737- -v $"($env.HOME):($env.HOME)"
3838- --workdir $workdir
3939- --env=PWD=$workdir
4040- --rm
4141- ] $image $cmd ...$args
4242-}
-18
oci/xr-multi/Containerfile
···11-# SPDX-License-Identifier: AGPL-3.0-only
22-# SPDX-FileCopyrightText: MatrixFurry <matrix@matrixfurry.com>
33-44-# OCI Container with pre-installed dependencies for building common XR apps
55-# TODO: consider adding runtime stage for running built applications inside the container
66-77-FROM fedora:latest AS builder
88-99-# TODO WiVRn
1010-# TODO WiVRn Dashboard
1111-1212-RUN dnf group install -y development-tools
1313-RUN dnf install -y \
1414- envision-monado \
1515- envision-xrizer \
1616- onnxruntime-devel \
1717- fmt-devel git-lfs glew-devel gtest-devel jq lz4-devel tbb-devel
1818-RUN dnf builddep -y opencomposite