nix: refactor
- Remove unnecessary fenix input - Remove unnecessary arguments to buildRustPackage - Remove obsolete/unnecessary hacks - Minimize code duplication and maximize re-use by using flake.parts - Split out stardust-xr-server derivation into its own nix file in nix/stardust-xr-server - Automatically get name of package from Cargo.toml - Advertise support for riscv64-linux in flake outputs
This commit is contained in:
96
flake.lock
generated
96
flake.lock
generated
@@ -1,33 +1,12 @@
|
|||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"fenix": {
|
"fenix": {
|
||||||
"inputs": {
|
|
||||||
"nixpkgs": [
|
|
||||||
"nixpkgs"
|
|
||||||
],
|
|
||||||
"rust-analyzer-src": "rust-analyzer-src"
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1691389274,
|
|
||||||
"narHash": "sha256-0lISOvDDoqOfauZctSKb6EvW1Mg1aPI0869Tx3xtEyw=",
|
|
||||||
"owner": "nix-community",
|
|
||||||
"repo": "fenix",
|
|
||||||
"rev": "bd0c7ee0836a814751c3fcf66eaadfbe1a35b715",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nix-community",
|
|
||||||
"repo": "fenix",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"fenix_2": {
|
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
"flatland",
|
"flatland",
|
||||||
"nixpkgs"
|
"nixpkgs"
|
||||||
],
|
],
|
||||||
"rust-analyzer-src": "rust-analyzer-src_2"
|
"rust-analyzer-src": "rust-analyzer-src"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1678775037,
|
"lastModified": 1678775037,
|
||||||
@@ -47,6 +26,24 @@
|
|||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs-lib": "nixpkgs-lib"
|
"nixpkgs-lib": "nixpkgs-lib"
|
||||||
},
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1690933134,
|
||||||
|
"narHash": "sha256-ab989mN63fQZBFrkk4Q8bYxQCktuHmBIBqUG1jl6/FQ=",
|
||||||
|
"owner": "hercules-ci",
|
||||||
|
"repo": "flake-parts",
|
||||||
|
"rev": "59cf3f1447cfc75087e7273b04b31e689a8599fb",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "hercules-ci",
|
||||||
|
"repo": "flake-parts",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"flake-parts_2": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs-lib": "nixpkgs-lib_2"
|
||||||
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1688466019,
|
"lastModified": 1688466019,
|
||||||
"narHash": "sha256-VeM2akYrBYMsb4W/MmBo1zmaMfgbL4cH3Pu8PGyIwJ0=",
|
"narHash": "sha256-VeM2akYrBYMsb4W/MmBo1zmaMfgbL4cH3Pu8PGyIwJ0=",
|
||||||
@@ -60,7 +57,7 @@
|
|||||||
"type": "indirect"
|
"type": "indirect"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"flake-parts_2": {
|
"flake-parts_3": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs-lib": [
|
"nixpkgs-lib": [
|
||||||
"hercules-ci-effects",
|
"hercules-ci-effects",
|
||||||
@@ -84,7 +81,7 @@
|
|||||||
},
|
},
|
||||||
"flatland": {
|
"flatland": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"fenix": "fenix_2",
|
"fenix": "fenix",
|
||||||
"nixpkgs": "nixpkgs"
|
"nixpkgs": "nixpkgs"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
@@ -119,7 +116,7 @@
|
|||||||
},
|
},
|
||||||
"hercules-ci-agent": {
|
"hercules-ci-agent": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-parts": "flake-parts_2",
|
"flake-parts": "flake-parts_3",
|
||||||
"haskell-flake": "haskell-flake",
|
"haskell-flake": "haskell-flake",
|
||||||
"nixpkgs": "nixpkgs_2"
|
"nixpkgs": "nixpkgs_2"
|
||||||
},
|
},
|
||||||
@@ -138,7 +135,7 @@
|
|||||||
},
|
},
|
||||||
"hercules-ci-effects": {
|
"hercules-ci-effects": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-parts": "flake-parts",
|
"flake-parts": "flake-parts_2",
|
||||||
"hercules-ci-agent": "hercules-ci-agent",
|
"hercules-ci-agent": "hercules-ci-agent",
|
||||||
"nixpkgs": "nixpkgs_3"
|
"nixpkgs": "nixpkgs_3"
|
||||||
},
|
},
|
||||||
@@ -173,6 +170,24 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nixpkgs-lib": {
|
"nixpkgs-lib": {
|
||||||
|
"locked": {
|
||||||
|
"dir": "lib",
|
||||||
|
"lastModified": 1690881714,
|
||||||
|
"narHash": "sha256-h/nXluEqdiQHs1oSgkOOWF+j8gcJMWhwnZ9PFabN6q0=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "9e1960bc196baf6881340d53dccb203a951745a2",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"dir": "lib",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixos-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs-lib_2": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"dir": "lib",
|
"dir": "lib",
|
||||||
"lastModified": 1688049487,
|
"lastModified": 1688049487,
|
||||||
@@ -223,15 +238,15 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs_4": {
|
"nixpkgs_4": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1691368598,
|
"lastModified": 1692734709,
|
||||||
"narHash": "sha256-ia7li22keBBbj02tEdqjVeLtc7ZlSBuhUk+7XTUFr14=",
|
"narHash": "sha256-SCFnyHCyYjwEmgUsHDDuU0TsbVMKeU1vwkR+r7uS2Rg=",
|
||||||
"owner": "NixOS",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "5a8e9243812ba528000995b294292d3b5e120947",
|
"rev": "b85ed9dcbf187b909ef7964774f8847d554fab3b",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "NixOS",
|
"owner": "nixos",
|
||||||
"ref": "nixos-unstable",
|
"ref": "nixos-unstable",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
@@ -239,30 +254,13 @@
|
|||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"fenix": "fenix",
|
"flake-parts": "flake-parts",
|
||||||
"flatland": "flatland",
|
"flatland": "flatland",
|
||||||
"hercules-ci-effects": "hercules-ci-effects",
|
"hercules-ci-effects": "hercules-ci-effects",
|
||||||
"nixpkgs": "nixpkgs_4"
|
"nixpkgs": "nixpkgs_4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"rust-analyzer-src": {
|
"rust-analyzer-src": {
|
||||||
"flake": false,
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1691346609,
|
|
||||||
"narHash": "sha256-npJ8zOZ/CQoZu+0kN5NU9iC5JbmbsucyK1DayPmHWPs=",
|
|
||||||
"owner": "rust-lang",
|
|
||||||
"repo": "rust-analyzer",
|
|
||||||
"rev": "baee6b338b0ea076cd7a9f18d47f175dd2ba0e5d",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "rust-lang",
|
|
||||||
"ref": "nightly",
|
|
||||||
"repo": "rust-analyzer",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"rust-analyzer-src_2": {
|
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1678695923,
|
"lastModified": 1678695923,
|
||||||
|
|||||||
188
flake.nix
188
flake.nix
@@ -3,135 +3,77 @@
|
|||||||
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 = {
|
||||||
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||||
|
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||||
|
hercules-ci-effects.url = "github:hercules-ci/hercules-ci-effects";
|
||||||
|
|
||||||
# 22.11 does not include PR #218472, hence we use the unstable version
|
# Since we do not have a monorepo, we have to fetch Flatland in order to use
|
||||||
inputs.nixpkgs.url = github:NixOS/nixpkgs/nixos-unstable;
|
# it to create VM Tests
|
||||||
|
flatland.url = "github:StardustXR/flatland";
|
||||||
# Since we do not have a monorepo, we have to fetch Flatland in order to use
|
};
|
||||||
# it to create VM Tests
|
outputs = inputs@{ self, flake-parts, nixpkgs, hercules-ci-effects, flatland, ... }:
|
||||||
inputs.flatland.url = "github:StardustXR/flatland";
|
|
||||||
|
|
||||||
inputs.fenix.url = github:nix-community/fenix;
|
|
||||||
inputs.fenix.inputs.nixpkgs.follows = "nixpkgs";
|
|
||||||
|
|
||||||
inputs.hercules-ci-effects.url = "github:hercules-ci/hercules-ci-effects";
|
|
||||||
|
|
||||||
outputs = { self, nixpkgs, fenix, hercules-ci-effects, flatland, ... }:
|
|
||||||
let
|
let
|
||||||
name = "server";
|
name = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).package.name;
|
||||||
pkgs = system: import nixpkgs {
|
src = builtins.path {
|
||||||
inherit system;
|
name = "${name}-source";
|
||||||
|
path = toString ./.;
|
||||||
|
filter = path: type:
|
||||||
|
nixpkgs.lib.all
|
||||||
|
(n: builtins.baseNameOf path != n)
|
||||||
|
[
|
||||||
|
"flake.nix"
|
||||||
|
"flake.lock"
|
||||||
|
"nix"
|
||||||
|
"README.md"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
shell = pkgs: pkgs.mkShell {
|
|
||||||
inputsFrom = [ self.packages.${pkgs.system}.default ];
|
|
||||||
|
|
||||||
# ---- START package specific dev settings ----
|
|
||||||
LIBCLANG_PATH = "${pkgs.libclang.lib}/lib";
|
|
||||||
# ---- END package specific dev settings ----
|
|
||||||
};
|
|
||||||
package = pkgs:
|
|
||||||
let
|
|
||||||
toolchain = fenix.packages.${pkgs.system}.minimal.toolchain;
|
|
||||||
in
|
|
||||||
(pkgs.makeRustPlatform {
|
|
||||||
cargo = toolchain;
|
|
||||||
rustc = toolchain;
|
|
||||||
}).buildRustPackage rec {
|
|
||||||
pname = "stardust-xr-${name}";
|
|
||||||
src = builtins.path {
|
|
||||||
name = "stardust-xr-source";
|
|
||||||
path = toString ./.;
|
|
||||||
filter = path: type:
|
|
||||||
nixpkgs.lib.all
|
|
||||||
(n: builtins.baseNameOf path != n)
|
|
||||||
[
|
|
||||||
"flake.nix"
|
|
||||||
"flake.lock"
|
|
||||||
"nix"
|
|
||||||
"README.md"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
# ---- START package specific settings ----
|
|
||||||
version = "0.10.2";
|
|
||||||
|
|
||||||
cargoLock = {
|
|
||||||
lockFile = ./Cargo.lock;
|
|
||||||
allowBuiltinFetchGit = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
postPatch = ''
|
|
||||||
sk=$(echo $cargoDepsCopy/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
|
|
||||||
'';
|
|
||||||
|
|
||||||
postFixup = ''
|
|
||||||
wrapProgram $out/bin/${pname} \
|
|
||||||
--prefix PATH : ${pkgs.lib.makeBinPath (with pkgs; [ xwayland bash ])}
|
|
||||||
'';
|
|
||||||
|
|
||||||
CPM_SOURCE_CACHE = "./build";
|
|
||||||
|
|
||||||
nativeBuildInputs = with pkgs; [
|
|
||||||
cmake pkg-config llvmPackages.libcxxClang makeWrapper
|
|
||||||
];
|
|
||||||
|
|
||||||
buildInputs = with pkgs; [
|
|
||||||
openxr-loader libGL mesa xorg.libX11 fontconfig libxkbcommon
|
|
||||||
];
|
|
||||||
|
|
||||||
LIBCLANG_PATH = "${pkgs.libclang.lib}/lib";
|
|
||||||
# ---- END package specific settings ----
|
|
||||||
};
|
|
||||||
in
|
in
|
||||||
{
|
flake-parts.lib.mkFlake { inherit inputs; } {
|
||||||
overlays.default = final: prev: {
|
imports = [
|
||||||
stardust-xr = (prev.stardust-xr or {}) // {
|
flake-parts.flakeModules.easyOverlay
|
||||||
${name} = package final;
|
];
|
||||||
|
systems = [ "aarch64-linux" "x86_64-linux" "riscv64-linux" ];
|
||||||
|
perSystem = { config, self', inputs', pkgs, system, ... }: {
|
||||||
|
_module.args.pkgs = import inputs.nixpkgs { inherit system; overlays = [ inputs.self.overlays.default ]; };
|
||||||
|
overlayAttrs = config.packages;
|
||||||
|
packages = {
|
||||||
|
default = self'.packages.${name};
|
||||||
|
gnome-graphical-test = self'.checks.gnome-graphical-test;
|
||||||
|
"${name}" = pkgs.callPackage ./nix/stardust-xr-server.nix { inherit name src; };
|
||||||
|
};
|
||||||
|
checks.gnome-graphical-test = pkgs.nixosTest (import ./nix/gnome-graphical-test.nix { inherit pkgs self; });
|
||||||
|
devShells.default = pkgs.mkShell {
|
||||||
|
inputsFrom = [ self'.packages.default ];
|
||||||
|
LIBCLANG_PATH = "${pkgs.libclang.lib}/lib";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
flake = {
|
||||||
packages."x86_64-linux".default = package (pkgs "x86_64-linux");
|
herculesCI.ciSystems = [ "x86_64-linux" ];
|
||||||
packages."aarch64-linux".default = package (pkgs "aarch64-linux");
|
effects = let
|
||||||
|
pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
||||||
packages."x86_64-linux".gnome-graphical-test = self.checks.x86_64-linux.gnome-graphical-test;
|
hci-effects = hercules-ci-effects.lib.withPkgs pkgs;
|
||||||
packages."aarch64-linux".gnome-graphical-test = self.checks.aarch64-linux.gnome-graphical-test;
|
in { branch, rev, ... }: {
|
||||||
|
gnome-graphical-test = hci-effects.mkEffect {
|
||||||
checks."x86_64-linux".gnome-graphical-test = (pkgs "x86_64-linux").nixosTest (import ./nix/gnome-graphical-test.nix { pkgs = (pkgs "x86_64-linux"); inherit self; });
|
secretsMap."stardustxrDiscord" = "stardustxrDiscord";
|
||||||
checks."aarch64-linux".gnome-graphical-test = (pkgs "aarch64-linux").nixosTest (import ./nix/gnome-graphical-test.nix { pkgs = (pkgs "aarch64-linux"); inherit self; });
|
secretsMap."stardustxrIpfs" = "stardustxrIpfs";
|
||||||
|
effectScript = ''
|
||||||
devShells."x86_64-linux".default = shell (pkgs "x86_64-linux");
|
readSecretString stardustxrDiscord .webhook > .webhook
|
||||||
devShells."aarch64-linux".default = shell (pkgs "aarch64-linux");
|
readSecretString stardustxrIpfs .basicauth > .basicauth
|
||||||
|
set -x
|
||||||
herculesCI.ciSystems = [ "x86_64-linux" ];
|
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)
|
||||||
effects = let
|
set +x
|
||||||
pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
export ADDRESS="https://ipfs.stardustxr.org/ipfs/$CID"
|
||||||
hci-effects = hercules-ci-effects.lib.withPkgs pkgs;
|
${pkgs.discord-sh}/bin/discord.sh \
|
||||||
in { branch, rev, ... }: {
|
--description "\`stardustxr/server\` has been modified, here's how it renders \`weston-cliptest\` on \`flatland\` via \`monado-service\` inside of the \`gnome-graphical-test\`" \
|
||||||
gnome-graphical-test = hci-effects.mkEffect {
|
--field "Branch;${branch}" \
|
||||||
secretsMap."stardustxrDiscord" = "stardustxrDiscord";
|
--field "Commit ID;${rev}" \
|
||||||
secretsMap."stardustxrIpfs" = "stardustxrIpfs";
|
--field "Flatland Revision;${flatland.rev}" \
|
||||||
effectScript = ''
|
--field "Reproducer;\`nix build github:stardustxr/server/${rev}#gnome-graphical-test\`" \
|
||||||
readSecretString stardustxrDiscord .webhook > .webhook
|
--image "$ADDRESS"
|
||||||
readSecretString stardustxrIpfs .basicauth > .basicauth
|
'';
|
||||||
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 CID=$(echo "$RESPONSE" | ${pkgs.jq}/bin/jq -r .Hash)
|
|
||||||
set +x
|
|
||||||
export ADDRESS="https://ipfs.stardustxr.org/ipfs/$CID"
|
|
||||||
${pkgs.discord-sh}/bin/discord.sh \
|
|
||||||
--description "\`stardustxr/server\` has been modified, here's how it renders \`weston-cliptest\` on \`flatland\` via \`monado-service\` inside of the \`gnome-graphical-test\`" \
|
|
||||||
--field "Branch;${branch}" \
|
|
||||||
--field "Commit ID;${rev}" \
|
|
||||||
--field "Flatland Revision;${flatland.rev}" \
|
|
||||||
--field "Reproducer;\`nix build github:stardustxr/server/${rev}#gnome-graphical-test\`" \
|
|
||||||
--image "$ADDRESS"
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
40
nix/stardust-xr-server.nix
Normal file
40
nix/stardust-xr-server.nix
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
{ rustPlatform
|
||||||
|
, src
|
||||||
|
, name
|
||||||
|
, openxr-loader
|
||||||
|
, libGL
|
||||||
|
, mesa
|
||||||
|
, xorg
|
||||||
|
, fontconfig
|
||||||
|
, libxkbcommon
|
||||||
|
, libclang
|
||||||
|
, cmake
|
||||||
|
, cpm-cmake
|
||||||
|
, pkg-config
|
||||||
|
, llvmPackages
|
||||||
|
}:
|
||||||
|
|
||||||
|
rustPlatform.buildRustPackage rec {
|
||||||
|
inherit src name;
|
||||||
|
cargoLock = {
|
||||||
|
lockFile = (src + "/Cargo.lock");
|
||||||
|
allowBuiltinFetchGit = true;
|
||||||
|
};
|
||||||
|
CPM_SOURCE_CACHE = "./build";
|
||||||
|
postPatch = ''
|
||||||
|
sk=$(echo $cargoDepsCopy/stereokit-sys-*/StereoKit)
|
||||||
|
mkdir -p $sk/build/cpm
|
||||||
|
|
||||||
|
# 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
|
||||||
|
cp ${cpm-cmake}/share/cpm/CPM.cmake $sk/build/cpm/CPM_0.32.2.cmake
|
||||||
|
'';
|
||||||
|
nativeBuildInputs = [
|
||||||
|
cmake pkg-config llvmPackages.libcxxClang
|
||||||
|
];
|
||||||
|
buildInputs = [
|
||||||
|
openxr-loader libGL mesa xorg.libX11 fontconfig libxkbcommon
|
||||||
|
];
|
||||||
|
LIBCLANG_PATH = "${libclang.lib}/lib";
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user