fix(nix): fixes nix build (#21)
This commit was merged in pull request #21.
This commit is contained in:
@@ -107,9 +107,10 @@ optional = true
|
|||||||
|
|
||||||
[dependencies.stereokit-rust]
|
[dependencies.stereokit-rust]
|
||||||
# path = "../StereoKit-rust"
|
# path = "../StereoKit-rust"
|
||||||
git = "https://github.com/mvvvv/StereoKit-rust.git"
|
# git = "https://github.com/mvvvv/StereoKit-rust.git"
|
||||||
# git = "https://github.com/technobaboo/StereoKit-rust.git"
|
# features = ["no-event-loop"]
|
||||||
features = ["no-event-loop"]
|
git = "https://github.com/technobaboo/StereoKit-rust.git"
|
||||||
|
# features = ["force-local-deps"]
|
||||||
default-features = false
|
default-features = false
|
||||||
|
|
||||||
[dependencies.stardust-xr]
|
[dependencies.stardust-xr]
|
||||||
|
|||||||
6
flake.lock
generated
6
flake.lock
generated
@@ -143,11 +143,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs_3": {
|
"nixpkgs_3": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1722813957,
|
"lastModified": 1723991338,
|
||||||
"narHash": "sha256-IAoYyYnED7P8zrBFMnmp7ydaJfwTnwcnqxUElC1I26Y=",
|
"narHash": "sha256-Grh5PF0+gootJfOJFenTTxDTYPidA3V28dqJ/WV7iis=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "cb9a96f23c491c081b38eab96d22fa958043c9fa",
|
"rev": "8a3354191c0d7144db9756a74755672387b702ba",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|||||||
37
flake.nix
37
flake.nix
@@ -1,7 +1,9 @@
|
|||||||
{
|
{
|
||||||
nixConfig = {
|
nixConfig = {
|
||||||
extra-substituters = [ "https://stardustxr.cachix.org" ];
|
extra-substituters = [ "https://stardustxr.cachix.org" ];
|
||||||
extra-trusted-public-keys = [ "stardustxr.cachix.org-1:mWSn8Ap2RLsIWT/8gsj+VfbJB6xoOkPaZpbjO+r9HBo=" ];
|
extra-trusted-public-keys = [
|
||||||
|
"stardustxr.cachix.org-1:mWSn8Ap2RLsIWT/8gsj+VfbJB6xoOkPaZpbjO+r9HBo="
|
||||||
|
];
|
||||||
};
|
};
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||||
@@ -12,43 +14,44 @@
|
|||||||
# it to create VM Tests
|
# it to create VM Tests
|
||||||
flatland.url = "github:StardustXR/flatland";
|
flatland.url = "github:StardustXR/flatland";
|
||||||
};
|
};
|
||||||
outputs = inputs@{ self, flake-parts, nixpkgs, hercules-ci-effects, flatland, ... }:
|
outputs =
|
||||||
|
inputs@{ self, flake-parts, nixpkgs, hercules-ci-effects, flatland, ... }:
|
||||||
let
|
let
|
||||||
name = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).package.name;
|
name = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).package.name;
|
||||||
src = builtins.path {
|
src = builtins.path {
|
||||||
name = "${name}-source";
|
name = "${name}-source";
|
||||||
path = toString ./.;
|
path = toString ./.;
|
||||||
filter = path: type:
|
filter = path: type:
|
||||||
nixpkgs.lib.all
|
nixpkgs.lib.all (n: builtins.baseNameOf path != n) [
|
||||||
(n: builtins.baseNameOf path != n)
|
|
||||||
[
|
|
||||||
"flake.nix"
|
"flake.nix"
|
||||||
"flake.lock"
|
"flake.lock"
|
||||||
"nix"
|
"nix"
|
||||||
"README.md"
|
"README.md"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
in
|
in flake-parts.lib.mkFlake { inherit inputs; } {
|
||||||
flake-parts.lib.mkFlake { inherit inputs; } {
|
imports = [ flake-parts.flakeModules.easyOverlay ];
|
||||||
imports = [
|
|
||||||
flake-parts.flakeModules.easyOverlay
|
|
||||||
];
|
|
||||||
systems = [ "aarch64-linux" "x86_64-linux" "riscv64-linux" ];
|
systems = [ "aarch64-linux" "x86_64-linux" "riscv64-linux" ];
|
||||||
perSystem = { config, self', inputs', pkgs, system, ... }: {
|
perSystem = { config, self', inputs', pkgs, system, ... }: {
|
||||||
_module.args.pkgs = import inputs.nixpkgs { inherit system; overlays = [ inputs.self.overlays.default ]; };
|
_module.args.pkgs = import inputs.nixpkgs {
|
||||||
|
inherit system;
|
||||||
|
overlays = [ inputs.self.overlays.default ];
|
||||||
|
};
|
||||||
overlayAttrs = config.packages;
|
overlayAttrs = config.packages;
|
||||||
packages = let
|
packages = let sk_gpu = pkgs.callPackage ./nix/sk_gpu.nix { };
|
||||||
meshoptimizer = pkgs.callPackage ./nix/meshoptimizer.nix {};
|
|
||||||
in {
|
in {
|
||||||
default = self'.packages.${name};
|
default = self'.packages.${name};
|
||||||
gnome-graphical-test = self'.checks.gnome-graphical-test;
|
gnome-graphical-test = self'.checks.gnome-graphical-test;
|
||||||
"${name}" = pkgs.callPackage ./nix/stardust-xr-server.nix { inherit name src meshoptimizer; };
|
"${name}" = pkgs.callPackage ./nix/stardust-xr-server.nix {
|
||||||
|
inherit name src sk_gpu;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
apps.default = {
|
apps.default = {
|
||||||
type = "app";
|
type = "app";
|
||||||
program = self'.packages.${name} + "/bin/stardust-xr-server";
|
program = self'.packages.${name} + "/bin/stardust-xr-server";
|
||||||
};
|
};
|
||||||
checks.gnome-graphical-test = pkgs.nixosTest (import ./nix/gnome-graphical-test.nix { inherit pkgs self; });
|
checks.gnome-graphical-test = pkgs.nixosTest
|
||||||
|
(import ./nix/gnome-graphical-test.nix { inherit pkgs self; });
|
||||||
devShells.default = pkgs.mkShell {
|
devShells.default = pkgs.mkShell {
|
||||||
inputsFrom = [ self'.packages.default ];
|
inputsFrom = [ self'.packages.default ];
|
||||||
LIBCLANG_PATH = "${pkgs.libclang.lib}/lib";
|
LIBCLANG_PATH = "${pkgs.libclang.lib}/lib";
|
||||||
@@ -67,7 +70,9 @@
|
|||||||
readSecretString stardustxrDiscord .webhook > .webhook
|
readSecretString stardustxrDiscord .webhook > .webhook
|
||||||
readSecretString stardustxrIpfs .basicauth > .basicauth
|
readSecretString stardustxrIpfs .basicauth > .basicauth
|
||||||
set -x
|
set -x
|
||||||
export RESPONSE=$(curl -H @.basicauth -F file=@${self.packages."x86_64-linux".gnome-graphical-test}/screen.png https://ipfs-api.stardustxr.org/api/v0/add)
|
export RESPONSE=$(curl -H @.basicauth -F file=@${
|
||||||
|
self.packages."x86_64-linux".gnome-graphical-test
|
||||||
|
}/screen.png https://ipfs-api.stardustxr.org/api/v0/add)
|
||||||
export CID=$(echo "$RESPONSE" | ${pkgs.jq}/bin/jq -r .Hash)
|
export CID=$(echo "$RESPONSE" | ${pkgs.jq}/bin/jq -r .Hash)
|
||||||
set +x
|
set +x
|
||||||
export ADDRESS="https://ipfs.stardustxr.org/ipfs/$CID"
|
export ADDRESS="https://ipfs.stardustxr.org/ipfs/$CID"
|
||||||
|
|||||||
16
nix/sk_gpu.nix
Normal file
16
nix/sk_gpu.nix
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
{ stdenv, fetchurl, unzip }:
|
||||||
|
|
||||||
|
let
|
||||||
|
sk_gpu_zip = fetchurl {
|
||||||
|
url =
|
||||||
|
"https://github.com/StereoKit/sk_gpu/releases/download/v2024.8.12/sk_gpu.v2024.8.12.zip";
|
||||||
|
sha256 = "sha256-NPjOFzu7AlpQKJ8PZYeUuegrR6TXtRyg+Hm2BxIAMLI=";
|
||||||
|
};
|
||||||
|
in stdenv.mkDerivation rec {
|
||||||
|
name = "sk_gpu";
|
||||||
|
src = sk_gpu_zip;
|
||||||
|
unpackPhase = ''
|
||||||
|
unzip -d $out ${sk_gpu_zip}
|
||||||
|
'';
|
||||||
|
nativeBuildInputs = [ unzip ];
|
||||||
|
}
|
||||||
@@ -1,19 +1,6 @@
|
|||||||
{ rustPlatform
|
{ rustPlatform, src, name, libGL, mesa, xorg, fontconfig, libxkbcommon, libclang
|
||||||
, src
|
, cmake, cpm-cmake, pkg-config, llvmPackages, fetchFromGitHub, sk_gpu, libXau
|
||||||
, name
|
, libXdmcp, stdenv, lib }:
|
||||||
, openxr-loader
|
|
||||||
, libGL
|
|
||||||
, mesa
|
|
||||||
, xorg
|
|
||||||
, fontconfig
|
|
||||||
, libxkbcommon
|
|
||||||
, libclang
|
|
||||||
, cmake
|
|
||||||
, cpm-cmake
|
|
||||||
, pkg-config
|
|
||||||
, llvmPackages
|
|
||||||
, meshoptimizer
|
|
||||||
}:
|
|
||||||
|
|
||||||
rustPlatform.buildRustPackage rec {
|
rustPlatform.buildRustPackage rec {
|
||||||
inherit src name;
|
inherit src name;
|
||||||
@@ -21,20 +8,63 @@ rustPlatform.buildRustPackage rec {
|
|||||||
lockFile = (src + "/Cargo.lock");
|
lockFile = (src + "/Cargo.lock");
|
||||||
allowBuiltinFetchGit = true;
|
allowBuiltinFetchGit = true;
|
||||||
};
|
};
|
||||||
|
FORCE_LOCAL_DEPS = true;
|
||||||
|
CPM_LOCAL_PACKAGES_ONLY = true;
|
||||||
CPM_SOURCE_CACHE = "./build";
|
CPM_SOURCE_CACHE = "./build";
|
||||||
postPatch = ''
|
CPM_USE_LOCAL_PACKAGES = true;
|
||||||
|
CPM_DOWNLOAD_ALL = false;
|
||||||
|
|
||||||
|
openxr_loader = fetchFromGitHub {
|
||||||
|
owner = "KhronosGroup";
|
||||||
|
repo = "OpenXR-SDK";
|
||||||
|
rev = "288d3a7ebc1ad959f62d51da75baa3d27438c499";
|
||||||
|
sha256 = "sha256-RdmnBe26hqPmqwCHIJolF6bSmZRmIKVlGF+TXAY35ig=";
|
||||||
|
};
|
||||||
|
meshoptimizer = fetchFromGitHub {
|
||||||
|
owner = "zeux";
|
||||||
|
repo = "meshoptimizer";
|
||||||
|
rev = "c21d3be6ddf627f8ca852ba4b6db9903b0557858";
|
||||||
|
sha256 = "sha256-QCxpM2g8WtYSZHkBzLTJNQ/oHb5j/n9rjaVmZJcCZIA=";
|
||||||
|
};
|
||||||
|
basis_universal = fetchFromGitHub {
|
||||||
|
owner = "BinomialLLC";
|
||||||
|
repo = "basis_universal";
|
||||||
|
rev = "900e40fb5d2502927360fe2f31762bdbb624455f";
|
||||||
|
sha256 = "sha256-zBRAXgG5Fi6+5uPQCI/RCGatY6O4ELuYBoKrPNn4K+8=";
|
||||||
|
};
|
||||||
|
|
||||||
|
DEP_OPENXR_LOADER_SOURCE = "${openxr_loader}";
|
||||||
|
DEP_MESHOPTIMIZER_SOURCE = "${meshoptimizer}";
|
||||||
|
DEP_BASIS_UNIVERSAL_SOURCE = "${basis_universal}";
|
||||||
|
|
||||||
|
postPatch = let libPath = lib.makeLibraryPath [ stdenv.cc.cc.lib ];
|
||||||
|
in ''
|
||||||
sk=$(echo $cargoDepsCopy/stereokit-rust-*/StereoKit)
|
sk=$(echo $cargoDepsCopy/stereokit-rust-*/StereoKit)
|
||||||
mkdir -p $sk/build/cpm
|
mkdir -p $sk/build/cpm
|
||||||
|
|
||||||
# This is not ideal, the original approach was to fetch the exact cmake
|
# This is not ideal, the original approach was to fetch the exact cmake
|
||||||
# file version that was wanted from GitHub directly, but at least this way it comes from Nixpkgs.. so meh
|
# file version that was wanted from GitHub directly, but at least this way it comes from Nixpkgs.. so meh
|
||||||
cp ${cpm-cmake}/share/cpm/CPM.cmake $sk/build/cpm/CPM_0.38.7.cmake
|
cp ${cpm-cmake}/share/cpm/CPM.cmake $sk/build/cpm/CPM_0.38.7.cmake
|
||||||
|
mkdir -p $sk/sk_gpu
|
||||||
|
cp -R ${sk_gpu}/* $sk/sk_gpu
|
||||||
|
chmod -R 755 $sk/sk_gpu/tools/linux_x64/*
|
||||||
|
export DEP_SK_GPU_SOURCE=$sk/sk_gpu
|
||||||
|
export LD_LIBRARY_PATH="${stdenv.cc.cc.lib}/lib";
|
||||||
|
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
||||||
|
--set-rpath "${libPath}" \
|
||||||
|
$sk/sk_gpu/tools/linux_x64/skshaderc
|
||||||
'';
|
'';
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [ cmake pkg-config llvmPackages.libcxxClang ];
|
||||||
cmake pkg-config llvmPackages.libcxxClang
|
|
||||||
];
|
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
openxr-loader libGL mesa xorg.libX11 fontconfig libxkbcommon meshoptimizer
|
libGL
|
||||||
|
mesa
|
||||||
|
xorg.libX11.dev
|
||||||
|
xorg.libXft
|
||||||
|
xorg.libXfixes
|
||||||
|
fontconfig
|
||||||
|
libxkbcommon
|
||||||
|
libXau
|
||||||
|
libXdmcp
|
||||||
];
|
];
|
||||||
LIBCLANG_PATH = "${libclang.lib}/lib";
|
LIBCLANG_PATH = "${libclang.lib}/lib";
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user