mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-30 04:28:11 +08:00
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
This commit is contained in:
+15
-14
@@ -28,9 +28,7 @@
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
overlays = [ (import rust-overlay) ];
|
||||
pkgs = import nixpkgs {
|
||||
inherit system overlays;
|
||||
};
|
||||
pkgs = import nixpkgs { inherit system overlays; };
|
||||
|
||||
rustExtensions = [ "rust-src" "rust-analyzer" "clippy" "cargo" ];
|
||||
rust = pkgs.rust-bin.stable.latest.default.override {
|
||||
@@ -54,12 +52,12 @@
|
||||
];
|
||||
|
||||
# Packages needed to build the package
|
||||
buildTools = [
|
||||
buildTools = [
|
||||
rust
|
||||
pkgs.nodejs
|
||||
pkgs.nodePackages.npm
|
||||
pkgs.binaryen
|
||||
pkgs.wasm-bindgen-cli
|
||||
pkgs.wasm-bindgen-cli_0_2_100
|
||||
pkgs.wasm-pack
|
||||
pkgs.pkg-config
|
||||
pkgs.cargo-about
|
||||
@@ -86,29 +84,31 @@
|
||||
rustGPUEnv = import ./rust-gpu.nix { inherit pkgs; };
|
||||
|
||||
libPath = "${pkgs.lib.makeLibraryPath buildInputs}:${cefEnv.CEF_PATH}";
|
||||
in
|
||||
{
|
||||
in {
|
||||
devShells.default = pkgs.mkShell ({
|
||||
packages = buildInputs ++ buildTools ++ devTools;
|
||||
|
||||
LD_LIBRARY_PATH = libPath;
|
||||
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";
|
||||
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";
|
||||
|
||||
shellHook = ''
|
||||
alias cargo='mold --run cargo'
|
||||
'';
|
||||
} // cefEnv // rustGPUEnv);
|
||||
|
||||
packages.default = pkgs.stdenv.mkDerivation(finalAttrs: {
|
||||
packages.default = pkgs.rustPlatform.buildRustPackage (finalAttrs: {
|
||||
pname = "graphite-editor";
|
||||
version = "unstable";
|
||||
src = pkgs.lib.cleanSource ./..;
|
||||
|
||||
cargoDeps = pkgs.rustPlatform.fetchCargoVendor {
|
||||
src = finalAttrs.src;
|
||||
hash = "sha256-BVIQIZbGW19Rof0J7U2r6XFCUC52hb7+uaE1di4bV4A=";
|
||||
cargoLock = {
|
||||
lockFile = ../Cargo.lock;
|
||||
allowBuiltinFetchGit = true;
|
||||
};
|
||||
|
||||
|
||||
# TODO: Remove the need for this hash by using individual package resolutions and hashes from package-lock.json
|
||||
npmDeps = pkgs.fetchNpmDeps {
|
||||
inherit (finalAttrs) pname version;
|
||||
src = "${finalAttrs.src}/frontend";
|
||||
@@ -144,6 +144,8 @@
|
||||
mkdir -p $out/share/icons/hicolor/scalable/apps
|
||||
cp $src/desktop/assets/graphite-icon-color.svg $out/share/icons/hicolor/scalable/apps/
|
||||
'';
|
||||
|
||||
doCheck = false;
|
||||
|
||||
postFixup = ''
|
||||
wrapProgram "$out/bin/graphite-editor" \
|
||||
@@ -151,6 +153,5 @@
|
||||
--set CEF_PATH "${cefEnv.CEF_PATH}"
|
||||
'';
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
+13
-7
@@ -2,7 +2,8 @@
|
||||
|
||||
let
|
||||
toolchainPkg = pkgs.rust-bin.nightly."2025-06-23".default.override {
|
||||
extensions = [ "rust-src" "rust-analyzer" "clippy" "cargo" "rustc-dev" "llvm-tools" ];
|
||||
extensions =
|
||||
[ "rust-src" "rust-analyzer" "clippy" "cargo" "rustc-dev" "llvm-tools" ];
|
||||
};
|
||||
toolchainRustPlatform = pkgs.makeRustPlatform {
|
||||
cargo = toolchainPkg;
|
||||
@@ -12,13 +13,18 @@ let
|
||||
pname = "rustc_codegen_spirv";
|
||||
version = "0-unstable-2025-08-04";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "Rust-GPU";
|
||||
repo = "rust-gpu";
|
||||
owner = "Firestar99";
|
||||
repo = "rust-gpu-new";
|
||||
rev = "c12f216121820580731440ee79ebc7403d6ea04f";
|
||||
hash = "sha256-rG1cZvOV0vYb1dETOzzbJ0asYdE039UZImobXZfKIno=";
|
||||
};
|
||||
cargoHash = "sha256-AEigcEc5wiBd3zLqWN/2HSbkfOVFneAqNvg9HsouZf4=";
|
||||
cargoBuildFlags = [ "-p" "rustc_codegen_spirv" "--features=use-compiled-tools" "--no-default-features" ];
|
||||
cargoBuildFlags = [
|
||||
"-p"
|
||||
"rustc_codegen_spirv"
|
||||
"--features=use-compiled-tools"
|
||||
"--no-default-features"
|
||||
];
|
||||
doCheck = false;
|
||||
});
|
||||
cargoWrapper = pkgs.writeShellScriptBin "cargo" ''
|
||||
@@ -34,8 +40,8 @@ let
|
||||
|
||||
exec ${toolchainPkg}/bin/cargo ${"\${filtered_args[@]}"}
|
||||
'';
|
||||
in
|
||||
{
|
||||
in {
|
||||
RUST_GPU_PATH_OVERRIDE = "${cargoWrapper}/bin:${toolchainPkg}/bin";
|
||||
RUSTC_CODEGEN_SPIRV_PATH = "${rustc_codegen_spirv}/lib/librustc_codegen_spirv.so";
|
||||
RUSTC_CODEGEN_SPIRV_PATH =
|
||||
"${rustc_codegen_spirv}/lib/librustc_codegen_spirv.so";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user