Skip to content

Commit

Permalink
overlay
Browse files Browse the repository at this point in the history
  • Loading branch information
icewind1991 committed Jan 3, 2024
1 parent 16d20a5 commit 78abe9b
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 18 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ cgmath = "0.18.0"
bytemuck = { version = "1.14.0", features = ["derive"] }
texpresso = { version = "2.0.1", features = ["rayon"] }
serde = "1.0.193"
ahash = "0.8.6"

url = { version = "2.5.0", optional = true, features = ["serde"] }
toml = { version = "0.8.8", optional = true }
Expand All @@ -45,10 +46,9 @@ reqwest = { version = "0.11.23", optional = true, default-features = false, feat
async-tempfile = { version = "0.5.0", optional = true }
tower-http = { version = "0.5.0", optional = true, features = ["cors"] }
http = { version = "1.0.0", optional = true }
ahash = { version = "0.8.6", optional = true }

[features]
server = ["url", "toml", "axum", "tokio", "reqwest", "async-tempfile", "tower-http", "http", "ahash"]
server = ["url", "toml", "axum", "tokio", "reqwest", "async-tempfile", "tower-http", "http"]

[profile.dev.package."*"]
opt-level = 2
Expand Down
9 changes: 9 additions & 0 deletions assets.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{fetchSteam}:
fetchSteam {
name = "tf2-vpks";
appId = "440";
depotId = "441";
manifestId = "5382461088476630278"; # 22 December 2023 – 00:13:59 UTC
hash = "sha256-p8waSdyFTKSo7CKQAjAGhL4hGiacjU0M59z47VH1NwM=";
fileList = ["regex:(tf2|hl2)_(misc|textures)_.*\.vpk"];
}
28 changes: 13 additions & 15 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
cross-naersk.inputs.nixpkgs.follows = "nixpkgs";
cross-naersk.inputs.naersk.follows = "naersk";
steam-fetcher = {
# url = "github:nix-community/steam-fetcher";
# url = "github:nix-community/steam-fetcher";
url = "github:icewind1991/steam-fetcher/filelist";
inputs.nixpkgs.follows = "nixpkgs";
};
Expand All @@ -30,6 +30,7 @@
overlays = [
steam-fetcher.overlays.default
(import rust-overlay)
(import ./overlay.nix)
];
pkgs = (import nixpkgs) {
inherit system overlays;
Expand Down Expand Up @@ -99,26 +100,20 @@
});
server = naersk'.buildPackage (nearskOpt
// {
pname = "vbsp-server";
preConfigure = ''
pname = "vbsp-server";
preConfigure = ''
cargo_build_options="--features server $cargo_build_options"
'';
GLTFPACK = "${pkgs.meshoptimizer}/bin/gltfpack";
'';
GLTFPACK = "${pkgs.meshoptimizer}/bin/gltfpack";
});
assets = pkgs.fetchSteam {
name = "tf2-vpks";
appId = "440";
depotId = "441";
manifestId = "5382461088476630278"; # 22 December 2023 – 00:13:59 UTC
hash = "sha256-p8waSdyFTKSo7CKQAjAGhL4hGiacjU0M59z47VH1NwM=";
fileList = ["regex:(tf2|hl2)_(misc|textures)_.*\.vpk"];
};
assets = pkgs.vbsp-server-assets;
server-with-assets = server.overrideAttrs (old: {
buildInputs = server.buildInputs ++ [ pkgs.makeWrapper ];
buildInputs = server.buildInputs ++ [pkgs.makeWrapper];
postInstall = ''
wrapProgram "$out/bin/vbsp-server" --set TF_DIR "${assets}"
'';
});
vbsp-server = pkgs.vbsp-server;
default = vbsp-to-gltf;
};

Expand All @@ -142,5 +137,8 @@
nativeBuildInputs = [msrvToolchain] ++ tools;
};
};
});
})
// {
overlays.default = import ./overlay.nix;
};
}
4 changes: 4 additions & 0 deletions overlay.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
prev: final: {
vbsp-server = final.callPackage ./package.nix {};
vbsp-server-assets = final.callPackage ./assets.nix {};
}
19 changes: 19 additions & 0 deletions package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
stdenv,
rustPlatform,
lib,
}: let
inherit (lib.sources) sourceByRegex;
src = sourceByRegex ./. ["Cargo.*" "(src|derive|benches|tests|examples.*)(/.*)?"];
in
rustPlatform.buildRustPackage rec {
name = "vbsp-server";
version = "0.1.0";

inherit src;

cargoLock = {
lockFile = ./Cargo.lock;
};
buildFeatures = [ "server" ];
}
2 changes: 1 addition & 1 deletion src/server/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ fn default_port() -> u16 {
}

#[derive(Debug, Error)]
enum ServerError {
pub enum ServerError {
#[error(transparent)]
Convert(#[from] vbsp_to_gltf::Error),
#[error(transparent)]
Expand Down

0 comments on commit 78abe9b

Please sign in to comment.