mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-10-02 22:28:11 +08:00
Desktop: Add nix package to flake (#3258)
* update cargo-gpu, remove legacy-target-specs to fix nix builds * add nix package to flake * update cargo hash * fix merge --------- Co-authored-by: firestar99 <firestar99@sydow.cloud>
This commit is contained in:
@@ -0,0 +1,26 @@
|
|||||||
|
{ pkgs }:
|
||||||
|
|
||||||
|
let
|
||||||
|
libcef = pkgs.libcef.overrideAttrs (_: _: {
|
||||||
|
postInstall = ''
|
||||||
|
strip $out/lib/*
|
||||||
|
'';
|
||||||
|
});
|
||||||
|
cefPath = pkgs.runCommand "cef-path" {} ''
|
||||||
|
mkdir -p $out
|
||||||
|
|
||||||
|
ln -s ${libcef}/include $out/include
|
||||||
|
find ${libcef}/lib -type f -name "*" -exec ln -s {} $out/ \;
|
||||||
|
find ${libcef}/libexec -type f -name "*" -exec ln -s {} $out/ \;
|
||||||
|
cp -r ${libcef}/share/cef/* $out/
|
||||||
|
|
||||||
|
echo '${builtins.toJSON {
|
||||||
|
type = "minimal";
|
||||||
|
name = builtins.baseNameOf libcef.src.url;
|
||||||
|
sha1 = "";
|
||||||
|
}}' > $out/archive.json
|
||||||
|
'';
|
||||||
|
in
|
||||||
|
{
|
||||||
|
CEF_PATH = cefPath;
|
||||||
|
}
|
||||||
+86
-89
@@ -12,8 +12,6 @@
|
|||||||
# - Development shell: `nix develop .nix` from the project root
|
# - Development shell: `nix develop .nix` from the project root
|
||||||
# - Run in dev shell with direnv: add `use flake` to .envrc
|
# - Run in dev shell with direnv: add `use flake` to .envrc
|
||||||
{
|
{
|
||||||
description = "Development environment and build configuration";
|
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||||
rust-overlay = {
|
rust-overlay = {
|
||||||
@@ -40,78 +38,22 @@
|
|||||||
extensions = rustExtensions;
|
extensions = rustExtensions;
|
||||||
};
|
};
|
||||||
|
|
||||||
rustGPUToolchainPkg = pkgs.rust-bin.nightly."2025-06-23".default.override {
|
# Shared build inputs; libraries that need to be in LD_LIBRARY_PATH
|
||||||
extensions = rustExtensions ++ [ "rustc-dev" "llvm-tools" ];
|
buildInputs = [
|
||||||
};
|
pkgs.wayland
|
||||||
rustGPUToolchainRustPlatform = pkgs.makeRustPlatform {
|
pkgs.openssl
|
||||||
cargo = rustGPUToolchainPkg;
|
pkgs.vulkan-loader
|
||||||
rustc = rustGPUToolchainPkg;
|
pkgs.libraw
|
||||||
};
|
pkgs.libGL
|
||||||
rustc_codegen_spirv = rustGPUToolchainRustPlatform.buildRustPackage (finalAttrs: {
|
|
||||||
pname = "rustc_codegen_spirv";
|
|
||||||
version = "0-unstable-2025-08-04";
|
|
||||||
src = pkgs.fetchFromGitHub {
|
|
||||||
owner = "Rust-GPU";
|
|
||||||
repo = "rust-gpu";
|
|
||||||
rev = "c12f216121820580731440ee79ebc7403d6ea04f";
|
|
||||||
hash = "sha256-rG1cZvOV0vYb1dETOzzbJ0asYdE039UZImobXZfKIno=";
|
|
||||||
};
|
|
||||||
cargoHash = "sha256-AEigcEc5wiBd3zLqWN/2HSbkfOVFneAqNvg9HsouZf4=";
|
|
||||||
cargoBuildFlags = [ "-p" "rustc_codegen_spirv" "--features=use-compiled-tools" "--no-default-features" ];
|
|
||||||
doCheck = false;
|
|
||||||
});
|
|
||||||
rustGpuCargo = pkgs.writeShellScriptBin "cargo" ''
|
|
||||||
#!${pkgs.lib.getExe pkgs.bash}
|
|
||||||
|
|
||||||
filtered_args=()
|
|
||||||
for arg in "$@"; do
|
|
||||||
case "$arg" in
|
|
||||||
+nightly|+nightly-*) ;;
|
|
||||||
*) filtered_args+=("$arg") ;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
exec ${rustGPUToolchainPkg}/bin/cargo ${"\${filtered_args[@]}"}
|
|
||||||
'';
|
|
||||||
rustGpuPathOverride = "${rustGpuCargo}/bin:${rustGPUToolchainPkg}/bin";
|
|
||||||
|
|
||||||
libcef = pkgs.libcef.overrideAttrs (_: _: {
|
|
||||||
postInstall = ''
|
|
||||||
strip $out/lib/*
|
|
||||||
'';
|
|
||||||
});
|
|
||||||
libcefPath = pkgs.runCommand "libcef-path" {} ''
|
|
||||||
mkdir -p $out
|
|
||||||
|
|
||||||
ln -s ${libcef}/include $out/include
|
|
||||||
find ${libcef}/lib -type f -name "*" -exec ln -s {} $out/ \;
|
|
||||||
find ${libcef}/libexec -type f -name "*" -exec ln -s {} $out/ \;
|
|
||||||
cp -r ${libcef}/share/cef/* $out/
|
|
||||||
|
|
||||||
echo '${builtins.toJSON {
|
|
||||||
type = "minimal";
|
|
||||||
name = builtins.baseNameOf libcef.src.url;
|
|
||||||
sha1 = "";
|
|
||||||
}}' > $out/archive.json
|
|
||||||
'';
|
|
||||||
|
|
||||||
# Shared build inputs - system libraries that need to be in LD_LIBRARY_PATH
|
|
||||||
buildInputs = with pkgs; [
|
|
||||||
# System libraries
|
|
||||||
wayland
|
|
||||||
openssl
|
|
||||||
vulkan-loader
|
|
||||||
libraw
|
|
||||||
libGL
|
|
||||||
|
|
||||||
# X11 libraries, not needed on wayland! Remove when x11 is finally dead
|
# X11 libraries, not needed on wayland! Remove when x11 is finally dead
|
||||||
libxkbcommon
|
pkgs.libxkbcommon
|
||||||
xorg.libXcursor
|
pkgs.xorg.libXcursor
|
||||||
xorg.libxcb
|
pkgs.xorg.libxcb
|
||||||
xorg.libX11
|
pkgs.xorg.libX11
|
||||||
];
|
];
|
||||||
|
|
||||||
# Development tools that don't need to be in LD_LIBRARY_PATH
|
# Packages needed to build the package
|
||||||
buildTools = [
|
buildTools = [
|
||||||
rust
|
rust
|
||||||
pkgs.nodejs
|
pkgs.nodejs
|
||||||
@@ -120,40 +62,95 @@
|
|||||||
pkgs.wasm-bindgen-cli
|
pkgs.wasm-bindgen-cli
|
||||||
pkgs.wasm-pack
|
pkgs.wasm-pack
|
||||||
pkgs.pkg-config
|
pkgs.pkg-config
|
||||||
pkgs.git
|
|
||||||
pkgs.cargo-about
|
pkgs.cargo-about
|
||||||
|
];
|
||||||
|
|
||||||
|
# Development tools; not needed to build the package
|
||||||
|
devTools = [
|
||||||
|
pkgs.git
|
||||||
|
|
||||||
|
pkgs.cargo-watch
|
||||||
|
pkgs.cargo-nextest
|
||||||
|
pkgs.cargo-expand
|
||||||
|
|
||||||
# Linker
|
# Linker
|
||||||
pkgs.mold
|
pkgs.mold
|
||||||
];
|
|
||||||
# Development tools that don't need to be in LD_LIBRARY_PATH
|
|
||||||
devTools = with pkgs; [
|
|
||||||
cargo-watch
|
|
||||||
cargo-nextest
|
|
||||||
cargo-expand
|
|
||||||
|
|
||||||
# Profiling tools
|
# Profiling tools
|
||||||
gnuplot
|
pkgs.gnuplot
|
||||||
samply
|
pkgs.samply
|
||||||
cargo-flamegraph
|
pkgs.cargo-flamegraph
|
||||||
];
|
];
|
||||||
|
|
||||||
|
cefEnv = import ./cef.nix { inherit pkgs; };
|
||||||
|
rustGPUEnv = import ./rust-gpu.nix { inherit pkgs; };
|
||||||
|
|
||||||
|
libPath = "${pkgs.lib.makeLibraryPath buildInputs}:${cefEnv.CEF_PATH}";
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
# Development shell configuration
|
devShells.default = pkgs.mkShell ({
|
||||||
devShells.default = pkgs.mkShell {
|
|
||||||
packages = buildInputs ++ buildTools ++ devTools;
|
packages = buildInputs ++ buildTools ++ devTools;
|
||||||
|
|
||||||
LD_LIBRARY_PATH = "${pkgs.lib.makeLibraryPath buildInputs}:${libcefPath}";
|
LD_LIBRARY_PATH = libPath;
|
||||||
CEF_PATH = libcefPath;
|
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";
|
|
||||||
|
|
||||||
RUST_GPU_PATH_OVERRIDE = rustGpuPathOverride;
|
|
||||||
RUSTC_CODEGEN_SPIRV_PATH = "${rustc_codegen_spirv}/lib/librustc_codegen_spirv.so";
|
|
||||||
|
|
||||||
shellHook = ''
|
shellHook = ''
|
||||||
alias cargo='mold --run cargo'
|
alias cargo='mold --run cargo'
|
||||||
'';
|
'';
|
||||||
};
|
} // cefEnv // rustGPUEnv);
|
||||||
|
|
||||||
|
packages.default = pkgs.stdenv.mkDerivation(finalAttrs: {
|
||||||
|
pname = "graphite-editor";
|
||||||
|
version = "unstable";
|
||||||
|
src = pkgs.lib.cleanSource ./..;
|
||||||
|
|
||||||
|
cargoDeps = pkgs.rustPlatform.fetchCargoVendor {
|
||||||
|
src = finalAttrs.src;
|
||||||
|
hash = "sha256-BVIQIZbGW19Rof0J7U2r6XFCUC52hb7+uaE1di4bV4A=";
|
||||||
|
};
|
||||||
|
|
||||||
|
npmDeps = pkgs.fetchNpmDeps {
|
||||||
|
inherit (finalAttrs) pname version;
|
||||||
|
src = "${finalAttrs.src}/frontend";
|
||||||
|
hash = "sha256-UWuJpKNYj2Xn34rpMDZ75pzMYUOLQjPeGuJ/QlPbX9A=";
|
||||||
|
};
|
||||||
|
|
||||||
|
npmRoot = "frontend";
|
||||||
|
npmConfigScript = "setup";
|
||||||
|
makeCacheWritable = true;
|
||||||
|
|
||||||
|
buildInputs = buildInputs;
|
||||||
|
nativeBuildInputs = buildTools ++ [
|
||||||
|
pkgs.rustPlatform.cargoSetupHook
|
||||||
|
pkgs.npmHooks.npmConfigHook
|
||||||
|
pkgs.makeWrapper
|
||||||
|
];
|
||||||
|
|
||||||
|
env = cefEnv // rustGPUEnv;
|
||||||
|
|
||||||
|
buildPhase = ''
|
||||||
|
export HOME="$TMPDIR"
|
||||||
|
|
||||||
|
npm run build-desktop
|
||||||
|
'';
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
mkdir -p $out/bin
|
||||||
|
cp target/release/graphite-desktop $out/bin/graphite-editor
|
||||||
|
|
||||||
|
mkdir -p $out/share/applications
|
||||||
|
cp $src/desktop/assets/*.desktop $out/share/applications/
|
||||||
|
|
||||||
|
mkdir -p $out/share/icons/hicolor/scalable/apps
|
||||||
|
cp $src/desktop/assets/graphite-icon-color.svg $out/share/icons/hicolor/scalable/apps/
|
||||||
|
'';
|
||||||
|
|
||||||
|
postFixup = ''
|
||||||
|
wrapProgram "$out/bin/graphite-editor" \
|
||||||
|
--prefix LD_LIBRARY_PATH : "${libPath}" \
|
||||||
|
--set CEF_PATH "${cefEnv.CEF_PATH}"
|
||||||
|
'';
|
||||||
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
{ pkgs }:
|
||||||
|
|
||||||
|
let
|
||||||
|
toolchainPkg = pkgs.rust-bin.nightly."2025-06-23".default.override {
|
||||||
|
extensions = [ "rust-src" "rust-analyzer" "clippy" "cargo" "rustc-dev" "llvm-tools" ];
|
||||||
|
};
|
||||||
|
toolchainRustPlatform = pkgs.makeRustPlatform {
|
||||||
|
cargo = toolchainPkg;
|
||||||
|
rustc = toolchainPkg;
|
||||||
|
};
|
||||||
|
rustc_codegen_spirv = toolchainRustPlatform.buildRustPackage (finalAttrs: {
|
||||||
|
pname = "rustc_codegen_spirv";
|
||||||
|
version = "0-unstable-2025-08-04";
|
||||||
|
src = pkgs.fetchFromGitHub {
|
||||||
|
owner = "Rust-GPU";
|
||||||
|
repo = "rust-gpu";
|
||||||
|
rev = "c12f216121820580731440ee79ebc7403d6ea04f";
|
||||||
|
hash = "sha256-rG1cZvOV0vYb1dETOzzbJ0asYdE039UZImobXZfKIno=";
|
||||||
|
};
|
||||||
|
cargoHash = "sha256-AEigcEc5wiBd3zLqWN/2HSbkfOVFneAqNvg9HsouZf4=";
|
||||||
|
cargoBuildFlags = [ "-p" "rustc_codegen_spirv" "--features=use-compiled-tools" "--no-default-features" ];
|
||||||
|
doCheck = false;
|
||||||
|
});
|
||||||
|
cargoWrapper = pkgs.writeShellScriptBin "cargo" ''
|
||||||
|
#!${pkgs.lib.getExe pkgs.bash}
|
||||||
|
|
||||||
|
filtered_args=()
|
||||||
|
for arg in "$@"; do
|
||||||
|
case "$arg" in
|
||||||
|
+nightly|+nightly-*) ;;
|
||||||
|
*) filtered_args+=("$arg") ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
exec ${toolchainPkg}/bin/cargo ${"\${filtered_args[@]}"}
|
||||||
|
'';
|
||||||
|
in
|
||||||
|
{
|
||||||
|
RUST_GPU_PATH_OVERRIDE = "${cargoWrapper}/bin:${toolchainPkg}/bin";
|
||||||
|
RUSTC_CODEGEN_SPIRV_PATH = "${rustc_codegen_spirv}/lib/librustc_codegen_spirv.so";
|
||||||
|
}
|
||||||
@@ -21,8 +21,8 @@
|
|||||||
"lint-fix": "eslint . --fix && tsc --noEmit",
|
"lint-fix": "eslint . --fix && tsc --noEmit",
|
||||||
"---------- INTERNAL ----------": "",
|
"---------- INTERNAL ----------": "",
|
||||||
"setup": "node package-installer.js",
|
"setup": "node package-installer.js",
|
||||||
"native:build-dev": "wasm-pack build ./wasm --dev --target=web --features native",
|
"native:build-dev": "wasm-pack build ./wasm --dev --target=web --no-default-features --features native",
|
||||||
"native:build-production": "wasm-pack build ./wasm --release --target=web --features native",
|
"native:build-production": "wasm-pack build ./wasm --release --target=web --no-default-features --features native",
|
||||||
"wasm:build-dev": "wasm-pack build ./wasm --dev --target=web",
|
"wasm:build-dev": "wasm-pack build ./wasm --dev --target=web",
|
||||||
"wasm:build-profiling": "wasm-pack build ./wasm --profiling --target=web",
|
"wasm:build-profiling": "wasm-pack build ./wasm --profiling --target=web",
|
||||||
"wasm:build-production": "wasm-pack build ./wasm --release --target=web",
|
"wasm:build-production": "wasm-pack build ./wasm --release --target=web",
|
||||||
|
|||||||
Reference in New Issue
Block a user