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:
blue linden
2025-10-18 22:56:26 +00:00
committed by GitHub
parent e8f18b0ac0
commit 5acf50c1ef
5 changed files with 57 additions and 49 deletions
+15 -14
View File
@@ -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}"
'';
});
}
);
});
}