Skip to content

Commit 5acf50c

Browse files
authored
Reduce Nix flake maintanace by eliminating need for cargoHash bumps (#3292)
* prepare nix for hashless cargo builds, update rust-gpu to non-orphaned commit * match commit hashes to repos, update packages to make nix flake build properly * add nix build dir to gitignore * Add npm TODO to flake.nix * Update Cargo.lock * Update TODO comment
1 parent e8f18b0 commit 5acf50c

File tree

5 files changed

+57
-49
lines changed

5 files changed

+57
-49
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
target/
2+
result/
23
*.spv
34
*.exrc
45
perf.data*

.nix/flake.nix

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@
2828
flake-utils.lib.eachDefaultSystem (system:
2929
let
3030
overlays = [ (import rust-overlay) ];
31-
pkgs = import nixpkgs {
32-
inherit system overlays;
33-
};
31+
pkgs = import nixpkgs { inherit system overlays; };
3432

3533
rustExtensions = [ "rust-src" "rust-analyzer" "clippy" "cargo" ];
3634
rust = pkgs.rust-bin.stable.latest.default.override {
@@ -54,12 +52,12 @@
5452
];
5553

5654
# Packages needed to build the package
57-
buildTools = [
55+
buildTools = [
5856
rust
5957
pkgs.nodejs
6058
pkgs.nodePackages.npm
6159
pkgs.binaryen
62-
pkgs.wasm-bindgen-cli
60+
pkgs.wasm-bindgen-cli_0_2_100
6361
pkgs.wasm-pack
6462
pkgs.pkg-config
6563
pkgs.cargo-about
@@ -86,29 +84,31 @@
8684
rustGPUEnv = import ./rust-gpu.nix { inherit pkgs; };
8785

8886
libPath = "${pkgs.lib.makeLibraryPath buildInputs}:${cefEnv.CEF_PATH}";
89-
in
90-
{
87+
in {
9188
devShells.default = pkgs.mkShell ({
9289
packages = buildInputs ++ buildTools ++ devTools;
9390

9491
LD_LIBRARY_PATH = libPath;
95-
XDG_DATA_DIRS = "${pkgs.gsettings-desktop-schemas}/share/gsettings-schemas/${pkgs.gsettings-desktop-schemas.name}:${pkgs.gtk3}/share/gsettings-schemas/${pkgs.gtk3.name}:$XDG_DATA_DIRS";
92+
XDG_DATA_DIRS =
93+
"${pkgs.gsettings-desktop-schemas}/share/gsettings-schemas/${pkgs.gsettings-desktop-schemas.name}:${pkgs.gtk3}/share/gsettings-schemas/${pkgs.gtk3.name}:$XDG_DATA_DIRS";
9694

9795
shellHook = ''
9896
alias cargo='mold --run cargo'
9997
'';
10098
} // cefEnv // rustGPUEnv);
10199

102-
packages.default = pkgs.stdenv.mkDerivation(finalAttrs: {
100+
packages.default = pkgs.rustPlatform.buildRustPackage (finalAttrs: {
103101
pname = "graphite-editor";
104102
version = "unstable";
105103
src = pkgs.lib.cleanSource ./..;
106104

107-
cargoDeps = pkgs.rustPlatform.fetchCargoVendor {
108-
src = finalAttrs.src;
109-
hash = "sha256-BVIQIZbGW19Rof0J7U2r6XFCUC52hb7+uaE1di4bV4A=";
105+
cargoLock = {
106+
lockFile = ../Cargo.lock;
107+
allowBuiltinFetchGit = true;
110108
};
111109

110+
111+
# TODO: Remove the need for this hash by using individual package resolutions and hashes from package-lock.json
112112
npmDeps = pkgs.fetchNpmDeps {
113113
inherit (finalAttrs) pname version;
114114
src = "${finalAttrs.src}/frontend";
@@ -144,13 +144,14 @@
144144
mkdir -p $out/share/icons/hicolor/scalable/apps
145145
cp $src/desktop/assets/graphite-icon-color.svg $out/share/icons/hicolor/scalable/apps/
146146
'';
147+
148+
doCheck = false;
147149

148150
postFixup = ''
149151
wrapProgram "$out/bin/graphite-editor" \
150152
--prefix LD_LIBRARY_PATH : "${libPath}" \
151153
--set CEF_PATH "${cefEnv.CEF_PATH}"
152154
'';
153155
});
154-
}
155-
);
156+
});
156157
}

.nix/rust-gpu.nix

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
let
44
toolchainPkg = pkgs.rust-bin.nightly."2025-06-23".default.override {
5-
extensions = [ "rust-src" "rust-analyzer" "clippy" "cargo" "rustc-dev" "llvm-tools" ];
5+
extensions =
6+
[ "rust-src" "rust-analyzer" "clippy" "cargo" "rustc-dev" "llvm-tools" ];
67
};
78
toolchainRustPlatform = pkgs.makeRustPlatform {
89
cargo = toolchainPkg;
@@ -12,13 +13,18 @@ let
1213
pname = "rustc_codegen_spirv";
1314
version = "0-unstable-2025-08-04";
1415
src = pkgs.fetchFromGitHub {
15-
owner = "Rust-GPU";
16-
repo = "rust-gpu";
16+
owner = "Firestar99";
17+
repo = "rust-gpu-new";
1718
rev = "c12f216121820580731440ee79ebc7403d6ea04f";
1819
hash = "sha256-rG1cZvOV0vYb1dETOzzbJ0asYdE039UZImobXZfKIno=";
1920
};
2021
cargoHash = "sha256-AEigcEc5wiBd3zLqWN/2HSbkfOVFneAqNvg9HsouZf4=";
21-
cargoBuildFlags = [ "-p" "rustc_codegen_spirv" "--features=use-compiled-tools" "--no-default-features" ];
22+
cargoBuildFlags = [
23+
"-p"
24+
"rustc_codegen_spirv"
25+
"--features=use-compiled-tools"
26+
"--no-default-features"
27+
];
2228
doCheck = false;
2329
});
2430
cargoWrapper = pkgs.writeShellScriptBin "cargo" ''
@@ -34,8 +40,8 @@ let
3440
3541
exec ${toolchainPkg}/bin/cargo ${"\${filtered_args[@]}"}
3642
'';
37-
in
38-
{
43+
in {
3944
RUST_GPU_PATH_OVERRIDE = "${cargoWrapper}/bin:${toolchainPkg}/bin";
40-
RUSTC_CODEGEN_SPIRV_PATH = "${rustc_codegen_spirv}/lib/librustc_codegen_spirv.so";
45+
RUSTC_CODEGEN_SPIRV_PATH =
46+
"${rustc_codegen_spirv}/lib/librustc_codegen_spirv.so";
4147
}

Cargo.lock

Lines changed: 25 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ web-sys = { version = "=0.3.77", features = [
132132
"HtmlImageElement",
133133
"ImageBitmapRenderingContext",
134134
] }
135-
winit = { git = "https://github.com/rust-windowing/winit.git", rev = "37221c7192ef1deec022a2278e54429331c01bad" }
135+
winit = { git = "https://github.com/timon-schelling/winit.git", rev = "37221c7192ef1deec022a2278e54429331c01bad" }
136136
url = "2.5"
137137
tokio = { version = "1.29", features = ["fs", "macros", "io-std", "rt"] }
138138
vello = { git = "https://github.com/linebender/vello.git", rev = "87cc5bee6d3a34d15017dbbb58634ddc7f33ff9b" } # TODO switch back to stable when a release is made
@@ -195,8 +195,8 @@ open = "5.3"
195195
poly-cool = "0.3"
196196
spin = "0.10"
197197
clap = "4.5"
198-
spirv-std = { git = "https://github.com/rust-gpu/rust-gpu", rev = "c12f216121820580731440ee79ebc7403d6ea04f", features = ["bytemuck"] }
199-
cargo-gpu = { git = "https://github.com/rust-gpu/cargo-gpu", rev = "3952a22d16edbd38689f3a876e417899f21e1fe7", default-features = false }
198+
spirv-std = { git = "https://github.com/Firestar99/rust-gpu-new", rev = "c12f216121820580731440ee79ebc7403d6ea04f", features = ["bytemuck"] }
199+
cargo-gpu = { git = "https://github.com/Firestar99/cargo-gpu", rev = "3952a22d16edbd38689f3a876e417899f21e1fe7", default-features = false }
200200

201201
[workspace.lints.rust]
202202
unexpected_cfgs = { level = "allow", check-cfg = ['cfg(target_arch, values("spirv"))'] }

0 commit comments

Comments
 (0)