From 561b7d28eafdc2bbe17175fec0776f8228ac9e9b Mon Sep 17 00:00:00 2001 From: Astavie Date: Tue, 14 Mar 2023 19:39:35 +0100 Subject: [PATCH] nix flake --- flake.lock | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 64 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 146 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..1385534 --- /dev/null +++ b/flake.lock @@ -0,0 +1,82 @@ +{ + "nodes": { + "fenix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1678775037, + "narHash": "sha256-chx0tWnXKpcayPkPY3Qh+2hNwptvX8XE3o+fYZ+GNzg=", + "owner": "nix-community", + "repo": "fenix", + "rev": "ee59e1c769657b1e27e608f8b981fa8f6b715583", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1676283394, + "narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "3db36a8b464d0c4532ba1c7dda728f4576d6d073", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1678703398, + "narHash": "sha256-Y1mW3dBsoWLHpYm+UIHb5VZ7rx024NNHaF16oZBx++o=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "67f26c1cfc5d5783628231e776a81c1ade623e0b", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-22.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "fenix": "fenix", + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1678695923, + "narHash": "sha256-rDhiiU8P6sf6mgj5IKgCuTRN9uYeqWr6xl4XLkKnMWg=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "95497533524537b1cc7a2870ce94b0b14503be8b", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..6a307ca --- /dev/null +++ b/flake.nix @@ -0,0 +1,64 @@ +{ + inputs.nixpkgs.url = github:NixOS/nixpkgs/nixos-22.11; + + inputs.fenix.url = github:nix-community/fenix; + inputs.fenix.inputs.nixpkgs.follows = "nixpkgs"; + + inputs.flake-utils.url = github:numtide/flake-utils; + + outputs = { self, nixpkgs, fenix, flake-utils }: + flake-utils.lib.simpleFlake { + inherit self nixpkgs; + name = "stardust-xr"; + overlay = pkgs: prev: + let + toolchain = fenix.packages.${pkgs.system}.minimal.toolchain; + + name = "server"; + pkg = (pkgs.makeRustPlatform { + cargo = toolchain; + rustc = toolchain; + }).buildRustPackage rec { + pname = "stardust-xr-${name}"; + src = ./.; + + # ---- START package specific settings ---- + version = "20230314"; + cargoSha256 = "sha256-H6qhpvm6Dqn6EETCtgAcT/iof9ZZHm0ahTkX9cChows="; + + postPatch = '' + sk=/build/${pname}-${version}-vendor.tar.gz/stereokit-sys/StereoKit + mkdir -p $sk/build/cpm + cp ${pkgs.fetchurl { + url = "https://github.com/cpm-cmake/CPM.cmake/releases/download/v0.32.2/CPM.cmake"; + hash = "sha256-yDHlpqmpAE8CWiwJRoWyaqbuBAg0090G8WJIC2KLHp8="; + }} $sk/build/cpm/CPM_0.32.2.cmake + ''; + + CPM_SOURCE_CACHE = "./build"; + + nativeBuildInputs = with pkgs; [ + cmake pkg-config llvmPackages.libcxxClang + ]; + + buildInputs = with pkgs; [ + openxr-loader libGL mesa xorg.libX11 fontconfig libxkbcommon + ]; + + LIBCLANG_PATH = "${pkgs.libclang.lib}/lib"; + # ---- END package specific settings ---- + }; + in + { + stardust-xr.${name} = pkg; + stardust-xr.defaultPackage = pkg; + }; + shell = { pkgs }: pkgs.mkShell { + inputsFrom = [ pkgs.stardust-xr.defaultPackage ]; + + # ---- START package specific dev settings ---- + LIBCLANG_PATH = "${pkgs.libclang.lib}/lib"; + # ---- END package specific dev settings ---- + }; + }; +}