flake reorg

This commit is contained in:
Robin Appelman 2025-03-30 16:23:27 +02:00
commit 0eb1875fb4
10 changed files with 88 additions and 363 deletions

View file

@ -4,83 +4,14 @@ on:
push:
jobs:
check:
checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v27
- uses: samueldr/lix-gha-installer-action@v2025-02-26.prerelease
- uses: icewind1991/attic-action@v1
with:
name: ci
instance: https://cache.icewind.me
authToken: '${{ secrets.ATTIC_TOKEN }}'
- run: nix build .#check
clippy:
runs-on: ubuntu-latest
needs: check
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v27
- uses: icewind1991/attic-action@v1
with:
name: ci
instance: https://cache.icewind.me
authToken: '${{ secrets.ATTIC_TOKEN }}'
- run: nix build .#clippy
test:
runs-on: ubuntu-latest
needs: check
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v27
- uses: icewind1991/attic-action@v1
with:
name: ci
instance: https://cache.icewind.me
authToken: '${{ secrets.ATTIC_TOKEN }}'
- run: nix build .#test
msrv:
runs-on: ubuntu-latest
needs: check
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v27
- uses: icewind1991/attic-action@v1
with:
name: ci
instance: https://cache.icewind.me
authToken: '${{ secrets.ATTIC_TOKEN }}'
- run: nix build .#msrv
matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v27
- id: set-matrix
run: echo "matrix=$(nix eval --json ".#matrix.x86_64-linux")" | tee $GITHUB_OUTPUT
build:
runs-on: ubuntu-latest
needs: [ check, matrix ]
strategy:
fail-fast: false
matrix: ${{fromJson(needs.matrix.outputs.matrix)}}
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v27
- uses: icewind1991/attic-action@v1
with:
name: ci
instance: https://cache.icewind.me
authToken: '${{ secrets.ATTIC_TOKEN }}'
- run: nix build .#${{ matrix.target }}
- uses: actions/upload-artifact@v4
with:
name: vbsp-to-gltf-${{ matrix.target }}
path: result/bin/vbsp-to-gltf${{ matrix.artifactSuffix }}
authToken: "${{ secrets.ATTIC_TOKEN }}"
- run: nix flake check --keep-going

View file

@ -1,39 +0,0 @@
name: Release
on:
release:
types: [ created ]
jobs:
matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v27
- id: set-matrix
run: echo "matrix=$(nix eval --json ".#releaseMatrix.x86_64-linux")" | tee $GITHUB_OUTPUT
build:
runs-on: ubuntu-latest
needs: matrix
strategy:
matrix: ${{fromJson(needs.matrix.outputs.matrix)}}
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v27
- uses: icewind1991/attic-action@v1
with:
name: ci
instance: https://cache.icewind.me
authToken: '${{ secrets.ATTIC_TOKEN }}'
- run: nix build .#${{ matrix.target }}
- name: Upload binary to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: result/bin/vbsp-to-gltf${{ matrix.artifactSuffix }}
asset_name: vbsp-to-gltf-${{ matrix.target }}
tag: ${{ github.ref }}

View file

@ -24,4 +24,4 @@ through [gltfpack](https://github.com/zeux/meshoptimizer) before usage.
## Online converter
An online version of the convert can be found at [gltf.demos.tf](https://gltf.demos.tf/).
An online version of the convert can be found at [gltf.demos.tf](https://gltf.demos.tf/).

136
flake.lock generated
View file

@ -1,85 +1,98 @@
{
"nodes": {
"cross-naersk": {
"inputs": {
"naersk": [
"naersk"
],
"nixpkgs": [
"nixpkgs"
]
},
"crane": {
"locked": {
"lastModified": 1717704286,
"narHash": "sha256-zrLB/FTKODEAlJjgO8TwbK7teTseYbjLESp8QJ/FJYc=",
"owner": "icewind1991",
"repo": "cross-naersk",
"rev": "9068daceb8f0d248dcf629944f60e92b81391bdb",
"lastModified": 1742394900,
"narHash": "sha256-vVOAp9ahvnU+fQoKd4SEXB2JG2wbENkpqcwlkIXgUC0=",
"owner": "ipetkov",
"repo": "crane",
"rev": "70947c1908108c0c551ddfd73d4f750ff2ea67cd",
"type": "github"
},
"original": {
"owner": "icewind1991",
"repo": "cross-naersk",
"owner": "ipetkov",
"repo": "crane",
"type": "github"
}
},
"naersk": {
"flakelight": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1721727458,
"narHash": "sha256-r/xppY958gmZ4oTfLiHN0ZGuQ+RSTijDblVgVLFi1mw=",
"lastModified": 1742820300,
"narHash": "sha256-2nQkRoWxyvEhXJQRrX8HL38hjWu6Ra86Dpcl5L1YvCo=",
"owner": "nix-community",
"repo": "naersk",
"rev": "3fb418eaf352498f6b6c30592e3beb63df42ef11",
"repo": "flakelight",
"rev": "0c6e80f747d8324ddfbf9efc93d1e6d24f94477a",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "naersk",
"repo": "flakelight",
"type": "github"
}
},
"mill-scale": {
"inputs": {
"crane": "crane",
"flakelight": [
"flakelight"
],
"rust-overlay": "rust-overlay"
},
"locked": {
"lastModified": 1742759991,
"narHash": "sha256-SjmWydHdBuPS7vrsZWTprCdLY796Dj9YNFd2Rp0w/KE=",
"owner": "icewind1991",
"repo": "mill-scale",
"rev": "8196ca2f6daea4bd48eb86c61264c58ae8635440",
"type": "github"
},
"original": {
"owner": "icewind1991",
"repo": "mill-scale",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1724727824,
"narHash": "sha256-0XH9MJk54imJm+RHOLTUJ7e+ponLW00tw5ke4MTVa1Y=",
"lastModified": 1743231893,
"narHash": "sha256-tpJsHMUPEhEnzySoQxx7+kA+KUtgWqvlcUBqROYNNt0=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "36bae45077667aff5720e5b3f1a5458f51cf0776",
"rev": "c570c1f5304493cafe133b8d843c7c1c4a10d3a6",
"type": "github"
},
"original": {
"id": "nixpkgs",
"ref": "nixos-24.05",
"ref": "nixos-24.11",
"type": "indirect"
}
},
"root": {
"inputs": {
"cross-naersk": "cross-naersk",
"naersk": "naersk",
"nixpkgs": "nixpkgs",
"rust-overlay": "rust-overlay",
"steam-fetcher": "steam-fetcher",
"utils": "utils"
"flakelight": "flakelight",
"mill-scale": "mill-scale",
"nixpkgs": "nixpkgs"
}
},
"rust-overlay": {
"inputs": {
"nixpkgs": [
"mill-scale",
"flakelight",
"nixpkgs"
]
},
"locked": {
"lastModified": 1724898214,
"narHash": "sha256-4yMO9+Lsr3zqTf4clAGGag/bfNTmc/ITOXbJQcOEok4=",
"lastModified": 1742697269,
"narHash": "sha256-Lpp0XyAtIl1oGJzNmTiTGLhTkcUjwSkEb0gOiNzYFGM=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "0bc2c784e3a6ce30a2ab1b9f47325ccbed13039f",
"rev": "01973c84732f9275c50c5f075dd1f54cc04b3316",
"type": "github"
},
"original": {
@ -87,59 +100,6 @@
"repo": "rust-overlay",
"type": "github"
}
},
"steam-fetcher": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1714795926,
"narHash": "sha256-PkgC9jqoN6cJ8XYzTA2PlrWs7aPJkM3BGiTxNqax0cA=",
"owner": "nix-community",
"repo": "steam-fetcher",
"rev": "12f66eafb7862d91b3e30c14035f96a21941bd9c",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "steam-fetcher",
"type": "github"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
}
},
"root": "root",

147
flake.nix
View file

@ -1,144 +1,17 @@
{
inputs = {
nixpkgs.url = "nixpkgs/nixos-24.05";
utils.url = "github:numtide/flake-utils";
naersk.url = "github:nix-community/naersk";
naersk.inputs.nixpkgs.follows = "nixpkgs";
rust-overlay.url = "github:oxalica/rust-overlay";
rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
rust-overlay.inputs.flake-utils.follows = "utils";
cross-naersk.url = "github:icewind1991/cross-naersk";
cross-naersk.inputs.nixpkgs.follows = "nixpkgs";
cross-naersk.inputs.naersk.follows = "naersk";
steam-fetcher = {
url = "github:nix-community/steam-fetcher";
nixpkgs.url = "nixpkgs/nixos-24.11";
flakelight = {
url = "github:nix-community/flakelight";
inputs.nixpkgs.follows = "nixpkgs";
};
mill-scale = {
url = "github:icewind1991/mill-scale";
inputs.flakelight.follows = "flakelight";
};
};
outputs = {
self,
nixpkgs,
utils,
naersk,
rust-overlay,
cross-naersk,
steam-fetcher,
}:
utils.lib.eachDefaultSystem (system: let
overlays = [
steam-fetcher.overlays.default
(import rust-overlay)
(import ./overlay.nix)
];
pkgs = (import nixpkgs) {
inherit system overlays;
};
inherit (pkgs) lib callPackage rust-bin mkShell;
inherit (lib.sources) sourceByRegex;
msrv = (fromTOML (readFile ./Cargo.toml)).package.rust-version;
inherit (builtins) fromTOML readFile;
toolchain = rust-bin.stable.latest.default;
msrvToolchain = rust-bin.stable."${msrv}".default;
hostTarget = pkgs.hostPlatform.config;
targets = [
"x86_64-unknown-linux-musl"
"x86_64-pc-windows-gnu"
hostTarget
];
releaseTargets = lib.lists.remove hostTarget targets;
naersk' = callPackage naersk {
rustc = toolchain;
cargo = toolchain;
};
msrvNaersk = callPackage naersk {
rustc = msrvToolchain;
cargo = msrvToolchain;
};
cross-naersk' = pkgs.callPackage cross-naersk {inherit naersk;};
buildMatrix = targets: {
include =
builtins.map (target: {
inherit target;
artifactSuffix = cross-naersk'.execSufficForTarget target;
})
targets;
};
src = sourceByRegex ./. ["Cargo.*" "(src|derive|benches|tests|examples.*)(/.*)?"];
nearskOpt = {
pname = "vbsp-to-gltf";
root = src;
};
in rec {
packages =
lib.attrsets.genAttrs targets (target:
(cross-naersk'.buildPackage target) nearskOpt)
// rec {
vbsp-to-gltf = packages.${hostTarget};
check = naersk'.buildPackage (nearskOpt
// {
mode = "check";
});
clippy = naersk'.buildPackage (nearskOpt
// {
mode = "clippy";
});
test = naersk'.buildPackage (nearskOpt
// {
release = false;
mode = "test";
});
msrv = msrvNaersk.buildPackage (nearskOpt
// {
mode = "check";
});
server = naersk'.buildPackage (nearskOpt
// {
pname = "vbsp-server";
preConfigure = ''
cargo_build_options="--features server $cargo_build_options"
'';
GLTFPACK = "${pkgs.meshoptimizer}/bin/gltfpack";
});
assets = pkgs.vbsp-server-assets;
viewer = pkgs.vbsp-server-viewer;
server-with-assets = server.overrideAttrs (old: {
buildInputs = server.buildInputs ++ [pkgs.makeWrapper];
postInstall = ''
wrapProgram "$out/bin/vbsp-server" --set TF_DIR "${assets}"
'';
});
vbsp-server = pkgs.vbsp-server;
default = vbsp-to-gltf;
};
matrix = buildMatrix targets;
releaseMatrix = buildMatrix releaseTargets;
devShells = let
tools = with pkgs; [
bacon
cargo-edit
cargo-outdated
cargo-audit
cargo-msrv
meshoptimizer
];
in {
default = mkShell {
nativeBuildInputs = [toolchain] ++ tools;
};
msrv = mkShell {
nativeBuildInputs = [msrvToolchain] ++ tools;
};
};
})
// {
overlays.default = import ./overlay.nix;
outputs = {mill-scale, ...}:
mill-scale ./. {
withOverlays = [(import ./nix/overlay.nix)];
};
}

View file

@ -12,7 +12,7 @@
cargo = toolchain;
};
inherit (lib.sources) sourceByRegex;
src = sourceByRegex ./. ["Cargo.*" "(src|derive|benches|tests|examples.*)(/.*)?"];
src = sourceByRegex ../. ["Cargo.*" "(src|derive|benches|tests|examples.*)(/.*)?"];
in
rustPlatform.buildRustPackage rec {
pname = "vbsp-server";
@ -29,7 +29,7 @@ in
doCheck = false;
cargoLock = {
lockFile = ./Cargo.lock;
lockFile = ../Cargo.lock;
};
buildFeatures = [ "server" ];
buildFeatures = ["server"];
}

View file

@ -3,16 +3,17 @@
importNpmLock,
nodejs_20,
lib,
}: buildNpmPackage rec {
}:
buildNpmPackage rec {
pname = "vbsp-server-viewer";
version = "0.1.0";
src = ./src/server/viewer;
src = ../src/server/viewer;
npmDeps = importNpmLock {
npmRoot = src;
};
npmRoot = src;
};
npmConfigHook = importNpmLock.npmConfigHook;
npmConfigHook = importNpmLock.npmConfigHook;
installPhase = "cp -r dist $out";
}

View file

@ -17,28 +17,27 @@ the [Basis GitHub repository](https://github.com/BinomialLLC/basis_universal).
The folder contains two files required for transcoding `.basis` or `.ktx2` textures:
* `basis_transcoder.js` — JavaScript wrapper for the WebAssembly transcoder.
* `basis_transcoder.wasm` — WebAssembly transcoder.
- `basis_transcoder.js` — JavaScript wrapper for the WebAssembly transcoder.
- `basis_transcoder.wasm` — WebAssembly transcoder.
Both are dependencies of `KTX2Loader`:
```js
const ktx2Loader = new KTX2Loader();
ktx2Loader.setTranscoderPath( 'examples/jsm/libs/basis/' );
ktx2Loader.detectSupport( renderer );
ktx2Loader.load( 'diffuse.ktx2', function ( texture ) {
const material = new THREE.MeshStandardMaterial( { map: texture } );
}, function () {
console.log( 'onProgress' );
}, function ( e ) {
console.error( e );
} );
ktx2Loader.setTranscoderPath("examples/jsm/libs/basis/");
ktx2Loader.detectSupport(renderer);
ktx2Loader.load(
"diffuse.ktx2",
function (texture) {
const material = new THREE.MeshStandardMaterial({ map: texture });
},
function () {
console.log("onProgress");
},
function (e) {
console.error(e);
},
);
```
## License