Desktop: Enable GPU nodes (#3364)
* desktop simple nix ci * make workflow manual * fixup * fix nix shell * nix fmt * fix shell
This commit is contained in:
parent
94414adaf8
commit
ebb434692a
|
|
@ -0,0 +1,17 @@
|
||||||
|
name: Build Nix Package
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch: {}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: DeterminateSystems/nix-installer-action@main
|
||||||
|
- uses: DeterminateSystems/magic-nix-cache-action@main
|
||||||
|
|
||||||
|
- name: Build Nix Package Dev
|
||||||
|
run: nix build .nix#graphite-dev --print-build-logs
|
||||||
26
.nix/cef.nix
26
.nix/cef.nix
|
|
@ -1,26 +0,0 @@
|
||||||
{ 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;
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
{ pkgs, inputs, ... }:
|
||||||
|
|
||||||
|
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
|
||||||
|
{
|
||||||
|
env.CEF_PATH = cefPath;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
{ pkgs, inputs, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
lib = inputs.crane.mkLib pkgs;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,58 @@
|
||||||
|
{ pkgs, inputs, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
extensions = [
|
||||||
|
"rust-src"
|
||||||
|
"rust-analyzer"
|
||||||
|
"clippy"
|
||||||
|
"cargo"
|
||||||
|
"rustc-dev"
|
||||||
|
"llvm-tools"
|
||||||
|
];
|
||||||
|
toolchain = pkgs.rust-bin.nightly."2025-06-23".default.override {
|
||||||
|
inherit extensions;
|
||||||
|
};
|
||||||
|
cargo = 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 ${toolchain}/bin/cargo ${"\${filtered_args[@]}"}
|
||||||
|
'';
|
||||||
|
rustc_codegen_spirv =
|
||||||
|
(pkgs.makeRustPlatform {
|
||||||
|
cargo = toolchain;
|
||||||
|
rustc = toolchain;
|
||||||
|
}).buildRustPackage
|
||||||
|
(finalAttrs: {
|
||||||
|
pname = "rustc_codegen_spirv";
|
||||||
|
version = "0-unstable-2025-08-04";
|
||||||
|
src = pkgs.fetchFromGitHub {
|
||||||
|
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"
|
||||||
|
];
|
||||||
|
doCheck = false;
|
||||||
|
});
|
||||||
|
in
|
||||||
|
{
|
||||||
|
toolchain = toolchain;
|
||||||
|
env = {
|
||||||
|
RUST_GPU_PATH_OVERRIDE = "${cargo}/bin:${toolchain}/bin";
|
||||||
|
RUSTC_CODEGEN_SPIRV_PATH = "${rustc_codegen_spirv}/lib/librustc_codegen_spirv.so";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
{
|
||||||
|
pkgs,
|
||||||
|
deps,
|
||||||
|
libs,
|
||||||
|
tools,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
|
pkgs.mkShell (
|
||||||
|
{
|
||||||
|
packages = tools.all ++ libs.all;
|
||||||
|
|
||||||
|
LD_LIBRARY_PATH = "${pkgs.lib.makeLibraryPath libs.all}:${deps.cef.env.CEF_PATH}";
|
||||||
|
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'
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
// deps.cef.env
|
||||||
|
// deps.rustGPU.env
|
||||||
|
)
|
||||||
|
|
@ -1,5 +1,20 @@
|
||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
|
"crane": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1762538466,
|
||||||
|
"narHash": "sha256-8zrIPl6J+wLm9MH5ksHcW7BUHo7jSNOu0/hA0ohOOaM=",
|
||||||
|
"owner": "ipetkov",
|
||||||
|
"repo": "crane",
|
||||||
|
"rev": "0cea393fffb39575c46b7a0318386467272182fe",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "ipetkov",
|
||||||
|
"repo": "crane",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"flake-compat": {
|
"flake-compat": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1733328505,
|
"lastModified": 1733328505,
|
||||||
|
|
@ -50,6 +65,7 @@
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
|
"crane": "crane",
|
||||||
"flake-compat": "flake-compat",
|
"flake-compat": "flake-compat",
|
||||||
"flake-utils": "flake-utils",
|
"flake-utils": "flake-utils",
|
||||||
"nixpkgs": "nixpkgs",
|
"nixpkgs": "nixpkgs",
|
||||||
|
|
|
||||||
232
.nix/flake.nix
232
.nix/flake.nix
|
|
@ -19,141 +19,137 @@
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
flake-utils.url = "github:numtide/flake-utils";
|
flake-utils.url = "github:numtide/flake-utils";
|
||||||
|
crane.url = "github:ipetkov/crane";
|
||||||
|
|
||||||
# This is used to provide a identical development shell at `shell.nix` for users that do not use flakes
|
# This is used to provide a identical development shell at `shell.nix` for users that do not use flakes
|
||||||
flake-compat.url = "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz";
|
flake-compat.url = "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz";
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { nixpkgs, rust-overlay, flake-utils, ... }:
|
outputs =
|
||||||
flake-utils.lib.eachDefaultSystem (system:
|
inputs:
|
||||||
|
inputs.flake-utils.lib.eachDefaultSystem (
|
||||||
|
system:
|
||||||
let
|
let
|
||||||
overlays = [ (import rust-overlay) ];
|
info = {
|
||||||
pkgs = import nixpkgs { inherit system overlays; };
|
pname = "graphite";
|
||||||
|
version = "unstable";
|
||||||
rustExtensions = [ "rust-src" "rust-analyzer" "clippy" "cargo" ];
|
src = ./..;
|
||||||
rust = pkgs.rust-bin.stable.latest.default.override {
|
|
||||||
targets = [ "wasm32-unknown-unknown" ];
|
|
||||||
extensions = rustExtensions;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
# Shared build inputs; libraries that need to be in LD_LIBRARY_PATH
|
pkgs = import inputs.nixpkgs {
|
||||||
buildInputs = [
|
inherit system;
|
||||||
pkgs.wayland
|
overlays = [ (import inputs.rust-overlay) ];
|
||||||
pkgs.openssl
|
};
|
||||||
pkgs.vulkan-loader
|
|
||||||
pkgs.libraw
|
|
||||||
pkgs.libGL
|
|
||||||
|
|
||||||
# X11 libraries, not needed on wayland! Remove when x11 is finally dead
|
deps = {
|
||||||
pkgs.libxkbcommon
|
crane = import ./deps/crane.nix { inherit pkgs inputs; };
|
||||||
pkgs.xorg.libXcursor
|
cef = import ./deps/cef.nix { inherit pkgs inputs; };
|
||||||
pkgs.xorg.libxcb
|
rustGPU = import ./deps/rust-gpu.nix { inherit pkgs inputs; };
|
||||||
pkgs.xorg.libX11
|
};
|
||||||
];
|
|
||||||
|
|
||||||
# Packages needed to build the package
|
libs = rec {
|
||||||
buildTools = [
|
desktop = [
|
||||||
rust
|
pkgs.wayland
|
||||||
pkgs.nodejs
|
pkgs.openssl
|
||||||
pkgs.nodePackages.npm
|
pkgs.vulkan-loader
|
||||||
pkgs.binaryen
|
pkgs.libraw
|
||||||
pkgs.wasm-bindgen-cli_0_2_100
|
pkgs.libGL
|
||||||
pkgs.wasm-pack
|
|
||||||
pkgs.pkg-config
|
|
||||||
pkgs.cargo-about
|
|
||||||
];
|
|
||||||
|
|
||||||
# Development tools; not needed to build the package
|
|
||||||
devTools = [
|
|
||||||
pkgs.git
|
|
||||||
|
|
||||||
pkgs.cargo-watch
|
|
||||||
pkgs.cargo-nextest
|
|
||||||
pkgs.cargo-expand
|
|
||||||
|
|
||||||
# Linker
|
|
||||||
pkgs.mold
|
|
||||||
|
|
||||||
# Profiling tools
|
|
||||||
pkgs.gnuplot
|
|
||||||
pkgs.samply
|
|
||||||
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 {
|
|
||||||
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";
|
|
||||||
|
|
||||||
shellHook = ''
|
|
||||||
alias cargo='mold --run cargo'
|
|
||||||
'';
|
|
||||||
} // cefEnv // rustGPUEnv);
|
|
||||||
|
|
||||||
packages.default = pkgs.rustPlatform.buildRustPackage (finalAttrs: {
|
|
||||||
pname = "graphite-editor";
|
|
||||||
version = "unstable";
|
|
||||||
src = pkgs.lib.cleanSource ./..;
|
|
||||||
|
|
||||||
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";
|
|
||||||
hash = "sha256-UWuJpKNYj2Xn34rpMDZ75pzMYUOLQjPeGuJ/QlPbX9A=";
|
|
||||||
};
|
|
||||||
|
|
||||||
npmRoot = "frontend";
|
|
||||||
npmConfigScript = "setup";
|
|
||||||
makeCacheWritable = true;
|
|
||||||
|
|
||||||
buildInputs = buildInputs;
|
|
||||||
nativeBuildInputs = buildTools ++ [
|
|
||||||
pkgs.rustPlatform.cargoSetupHook
|
|
||||||
pkgs.npmHooks.npmConfigHook
|
|
||||||
pkgs.makeWrapper
|
|
||||||
];
|
];
|
||||||
|
desktop-x11 = [
|
||||||
|
pkgs.libxkbcommon
|
||||||
|
pkgs.xorg.libXcursor
|
||||||
|
pkgs.xorg.libxcb
|
||||||
|
pkgs.xorg.libX11
|
||||||
|
];
|
||||||
|
desktop-all = desktop ++ desktop-x11;
|
||||||
|
all = desktop-all;
|
||||||
|
};
|
||||||
|
|
||||||
env = cefEnv // rustGPUEnv;
|
tools = rec {
|
||||||
|
desktop = [
|
||||||
|
pkgs.pkg-config
|
||||||
|
];
|
||||||
|
frontend = [
|
||||||
|
pkgs.lld
|
||||||
|
pkgs.nodejs
|
||||||
|
pkgs.nodePackages.npm
|
||||||
|
pkgs.binaryen
|
||||||
|
pkgs.wasm-bindgen-cli_0_2_100
|
||||||
|
pkgs.wasm-pack
|
||||||
|
pkgs.cargo-about
|
||||||
|
];
|
||||||
|
dev = [
|
||||||
|
pkgs.rustc
|
||||||
|
pkgs.cargo
|
||||||
|
pkgs.rust-analyzer
|
||||||
|
pkgs.clippy
|
||||||
|
|
||||||
buildPhase = ''
|
pkgs.git
|
||||||
export HOME="$TMPDIR"
|
|
||||||
|
|
||||||
pushd frontend
|
pkgs.cargo-watch
|
||||||
npm run build-native
|
pkgs.cargo-nextest
|
||||||
popd
|
pkgs.cargo-expand
|
||||||
cargo build -r -p graphite-desktop
|
|
||||||
'';
|
|
||||||
|
|
||||||
installPhase = ''
|
# Linker
|
||||||
mkdir -p $out/bin
|
pkgs.mold
|
||||||
cp target/release/graphite-desktop $out/bin/graphite-editor
|
|
||||||
|
|
||||||
mkdir -p $out/share/applications
|
# Profiling tools
|
||||||
cp $src/desktop/assets/*.desktop $out/share/applications/
|
pkgs.gnuplot
|
||||||
|
pkgs.samply
|
||||||
|
pkgs.cargo-flamegraph
|
||||||
|
];
|
||||||
|
all = desktop ++ frontend ++ dev;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
packages = rec {
|
||||||
|
graphiteWithArgs =
|
||||||
|
args:
|
||||||
|
(import ./pkgs/graphite.nix {
|
||||||
|
pkgs = pkgs // {
|
||||||
|
inherit graphene-raster-nodes-shaders;
|
||||||
|
};
|
||||||
|
inherit
|
||||||
|
info
|
||||||
|
inputs
|
||||||
|
deps
|
||||||
|
libs
|
||||||
|
tools
|
||||||
|
;
|
||||||
|
})
|
||||||
|
args;
|
||||||
|
graphite = graphiteWithArgs { };
|
||||||
|
graphite-dev = graphiteWithArgs { dev = true; };
|
||||||
|
graphite-without-resources = graphiteWithArgs { embeddedResources = false; };
|
||||||
|
graphite-without-resources-dev = graphiteWithArgs {
|
||||||
|
embeddedResources = false;
|
||||||
|
dev = true;
|
||||||
|
};
|
||||||
|
#TODO: graphene-cli = import ./pkgs/graphene-cli.nix { inherit info pkgs inputs deps libs tools; };
|
||||||
|
graphene-raster-nodes-shaders = import ./pkgs/graphene-raster-nodes-shaders.nix {
|
||||||
|
inherit
|
||||||
|
info
|
||||||
|
pkgs
|
||||||
|
inputs
|
||||||
|
deps
|
||||||
|
libs
|
||||||
|
tools
|
||||||
|
;
|
||||||
|
};
|
||||||
|
|
||||||
mkdir -p $out/share/icons/hicolor/scalable/apps
|
default = graphite;
|
||||||
cp $src/desktop/assets/graphite-icon-color.svg $out/share/icons/hicolor/scalable/apps/
|
};
|
||||||
'';
|
|
||||||
|
|
||||||
doCheck = false;
|
devShells.default = import ./dev.nix {
|
||||||
|
inherit
|
||||||
|
pkgs
|
||||||
|
deps
|
||||||
|
libs
|
||||||
|
tools
|
||||||
|
;
|
||||||
|
};
|
||||||
|
|
||||||
postFixup = ''
|
formatter = pkgs.nixfmt-tree;
|
||||||
wrapProgram "$out/bin/graphite-editor" \
|
}
|
||||||
--prefix LD_LIBRARY_PATH : "${libPath}" \
|
);
|
||||||
--set CEF_PATH "${cefEnv.CEF_PATH}"
|
|
||||||
'';
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
{
|
||||||
|
info,
|
||||||
|
pkgs,
|
||||||
|
inputs,
|
||||||
|
deps,
|
||||||
|
libs,
|
||||||
|
tools,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
|
(deps.crane.lib.overrideToolchain (_: deps.rustGPU.toolchain)).buildPackage {
|
||||||
|
pname = "graphene-raster-nodes-shaders";
|
||||||
|
inherit (info) version src;
|
||||||
|
|
||||||
|
cargoVendorDir = deps.crane.lib.vendorMultipleCargoDeps {
|
||||||
|
inherit (deps.crane.lib.findCargoFiles (deps.crane.lib.cleanCargoSource info.src)) cargoConfigs;
|
||||||
|
cargoLockList = [
|
||||||
|
"${info.src}/Cargo.lock"
|
||||||
|
"${deps.rustGPU.toolchain.passthru.availableComponents.rust-src}/lib/rustlib/src/rust/library/Cargo.lock"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
strictDeps = true;
|
||||||
|
|
||||||
|
env = deps.rustGPU.env;
|
||||||
|
|
||||||
|
buildPhase = ''
|
||||||
|
cargo build -r -p graphene-raster-nodes-shaders
|
||||||
|
'';
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
cp target/spirv-builder/spirv-unknown-naga-wgsl/release/deps/graphene_raster_nodes_shaders_entrypoint.wgsl $out
|
||||||
|
'';
|
||||||
|
|
||||||
|
doCheck = false;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,109 @@
|
||||||
|
{
|
||||||
|
info,
|
||||||
|
pkgs,
|
||||||
|
inputs,
|
||||||
|
deps,
|
||||||
|
libs,
|
||||||
|
tools,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
|
{
|
||||||
|
embeddedResources ? true,
|
||||||
|
dev ? false,
|
||||||
|
}:
|
||||||
|
|
||||||
|
let
|
||||||
|
resourcesCommon = {
|
||||||
|
pname = "${info.pname}-resources";
|
||||||
|
inherit (info) version src;
|
||||||
|
strictDeps = true;
|
||||||
|
doCheck = false;
|
||||||
|
nativeBuildInputs = tools.frontend;
|
||||||
|
env.CARGO_PROFILE = if dev then "dev" else "release";
|
||||||
|
cargoExtraArgs = "--target wasm32-unknown-unknown -p graphite-wasm --no-default-features --features native";
|
||||||
|
};
|
||||||
|
resources = deps.crane.lib.buildPackage (
|
||||||
|
resourcesCommon
|
||||||
|
// {
|
||||||
|
cargoArtifacts = deps.crane.lib.buildDepsOnly resourcesCommon;
|
||||||
|
|
||||||
|
# TODO: Remove the need for this hash by using individual package resolutions and hashes from package-lock.json
|
||||||
|
npmDeps = pkgs.fetchNpmDeps {
|
||||||
|
inherit (info) pname version;
|
||||||
|
src = "${info.src}/frontend";
|
||||||
|
hash = "sha256-UWuJpKNYj2Xn34rpMDZ75pzMYUOLQjPeGuJ/QlPbX9A=";
|
||||||
|
};
|
||||||
|
|
||||||
|
npmRoot = "frontend";
|
||||||
|
npmConfigScript = "setup";
|
||||||
|
makeCacheWritable = true;
|
||||||
|
|
||||||
|
nativeBuildInputs = tools.frontend ++ [ pkgs.npmHooks.npmConfigHook ];
|
||||||
|
|
||||||
|
buildPhase = ''
|
||||||
|
export HOME="$TMPDIR"
|
||||||
|
|
||||||
|
pushd frontend
|
||||||
|
npm run build-native${if dev then "-dev" else ""}
|
||||||
|
popd
|
||||||
|
'';
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
mkdir -p $out
|
||||||
|
cp -r frontend/dist/* $out/
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
);
|
||||||
|
common = {
|
||||||
|
inherit (info) pname version src;
|
||||||
|
strictDeps = true;
|
||||||
|
buildInputs = libs.desktop-all;
|
||||||
|
nativeBuildInputs = tools.desktop ++ [ pkgs.makeWrapper ];
|
||||||
|
env = deps.cef.env // {
|
||||||
|
CARGO_PROFILE = if dev then "dev" else "release";
|
||||||
|
};
|
||||||
|
cargoExtraArgs = "-p graphite-desktop${
|
||||||
|
if embeddedResources then "" else " --no-default-features --features recommended"
|
||||||
|
}";
|
||||||
|
doCheck = false;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
|
||||||
|
deps.crane.lib.buildPackage (
|
||||||
|
common
|
||||||
|
// {
|
||||||
|
cargoArtifacts = deps.crane.lib.buildDepsOnly common;
|
||||||
|
|
||||||
|
env =
|
||||||
|
common.env
|
||||||
|
// {
|
||||||
|
GRAPHENE_RASTER_NODES_SHADER_PATH = pkgs.graphene-raster-nodes-shaders;
|
||||||
|
}
|
||||||
|
// (
|
||||||
|
if embeddedResources then
|
||||||
|
{
|
||||||
|
EMBEDDED_RESOURCES = resources;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ }
|
||||||
|
);
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
mkdir -p $out/bin
|
||||||
|
cp target/${if dev then "debug" else "release"}/graphite $out/bin/graphite
|
||||||
|
|
||||||
|
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" \
|
||||||
|
--prefix LD_LIBRARY_PATH : "${pkgs.lib.makeLibraryPath libs.desktop-all}:${deps.cef.env.CEF_PATH}" \
|
||||||
|
--set CEF_PATH "${deps.cef.env.CEF_PATH}"
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
@ -1,47 +0,0 @@
|
||||||
{ 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 = "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"
|
|
||||||
];
|
|
||||||
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";
|
|
||||||
}
|
|
||||||
|
|
@ -16,16 +16,13 @@
|
||||||
# > nix-shell .nix --command "npm start"
|
# > nix-shell .nix --command "npm start"
|
||||||
|
|
||||||
# Uses flake compat to provide a development shell that is identical to the one defined in the flake
|
# Uses flake compat to provide a development shell that is identical to the one defined in the flake
|
||||||
(import
|
(import (
|
||||||
(
|
let
|
||||||
let
|
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
|
||||||
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
|
nodeName = lock.nodes.root.inputs.flake-compat;
|
||||||
nodeName = lock.nodes.root.inputs.flake-compat;
|
in
|
||||||
in
|
fetchTarball {
|
||||||
fetchTarball {
|
url = lock.nodes.${nodeName}.locked.url;
|
||||||
url = lock.nodes.${nodeName}.locked.url;
|
sha256 = lock.nodes.${nodeName}.locked.narHash;
|
||||||
sha256 = lock.nodes.${nodeName}.locked.narHash;
|
}
|
||||||
}
|
) { src = ./.; }).shellNix
|
||||||
)
|
|
||||||
{ src = ./.; }
|
|
||||||
).shellNix
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,10 @@ repository = ""
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
rust-version = "1.87"
|
rust-version = "1.87"
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "graphite"
|
||||||
|
path = "src/main.rs"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["recommended", "embedded_resources"]
|
default = ["recommended", "embedded_resources"]
|
||||||
recommended = ["gpu", "accelerated_paint"]
|
recommended = ["gpu", "accelerated_paint"]
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
Name=Graphite
|
Name=Graphite
|
||||||
GenericName=Vector & Raster Graphics Editor
|
GenericName=Vector & Raster Graphics Editor
|
||||||
Comment=Open-source vector & raster graphics editor. Featuring node based procedural nondestructive editing workflow.
|
Comment=Open-source vector & raster graphics editor. Featuring node based procedural nondestructive editing workflow.
|
||||||
Exec=graphite-editor
|
Exec=graphite
|
||||||
Terminal=false
|
Terminal=false
|
||||||
Type=Application
|
Type=Application
|
||||||
Icon=graphite-icon-color
|
Icon=graphite-icon-color
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,31 @@
|
||||||
const RESOURCES: &str = "../../frontend/dist";
|
const EMBEDDED_RESOURCES_ENV: &str = "EMBEDDED_RESOURCES";
|
||||||
|
const DEFAULT_RESOURCES_DIR: &str = "../../frontend/dist";
|
||||||
|
|
||||||
// Check if the directory `RESOURCES` exists and sets the embedded_resources cfg accordingly
|
|
||||||
// Absolute path of `RESOURCES` available via the `EMBEDDED_RESOURCES` environment variable
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let crate_dir = std::path::PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").unwrap());
|
let mut embedded_resources: Option<String> = None;
|
||||||
|
|
||||||
println!("cargo:rerun-if-changed={RESOURCES}");
|
println!("cargo:rerun-if-env-changed={EMBEDDED_RESOURCES_ENV}");
|
||||||
if let Ok(resources) = crate_dir.join(RESOURCES).canonicalize()
|
if let Ok(embedded_resources_env) = std::env::var(EMBEDDED_RESOURCES_ENV)
|
||||||
&& resources.exists()
|
&& std::path::PathBuf::from(&embedded_resources_env).exists()
|
||||||
{
|
{
|
||||||
|
embedded_resources = Some(embedded_resources_env);
|
||||||
|
}
|
||||||
|
|
||||||
|
if embedded_resources.is_none() {
|
||||||
|
// Check if the directory `DEFAULT_RESOURCES_DIR` exists and sets the embedded_resources cfg accordingly
|
||||||
|
// Absolute path of `DEFAULT_RESOURCES_DIR` available via the `EMBEDDED_RESOURCES` environment variable
|
||||||
|
let crate_dir = std::path::PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").unwrap());
|
||||||
|
println!("cargo:rerun-if-changed={DEFAULT_RESOURCES_DIR}");
|
||||||
|
if let Ok(resources) = crate_dir.join(DEFAULT_RESOURCES_DIR).canonicalize()
|
||||||
|
&& resources.exists()
|
||||||
|
{
|
||||||
|
embedded_resources = Some(resources.to_string_lossy().to_string());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(embedded_resources) = embedded_resources {
|
||||||
println!("cargo:rustc-cfg=embedded_resources");
|
println!("cargo:rustc-cfg=embedded_resources");
|
||||||
println!("cargo:rustc-env=EMBEDDED_RESOURCES={}", resources.to_string_lossy());
|
println!("cargo:rustc-env={EMBEDDED_RESOURCES_ENV}={embedded_resources}");
|
||||||
} else {
|
} else {
|
||||||
println!("cargo:warning=Resource directory does not exist. Resources will not be embedded. Did you forget to build the frontend?");
|
println!("cargo:warning=Resource directory does not exist. Resources will not be embedded. Did you forget to build the frontend?");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,7 @@ edition = "2024"
|
||||||
rust-version = "1.87"
|
rust-version = "1.87"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["gpu"]
|
gpu = ["graphite-editor/gpu", "graphene-std/shader-nodes"]
|
||||||
gpu = ["graphite-editor/gpu"]
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# Local dependencies
|
# Local dependencies
|
||||||
|
|
|
||||||
|
|
@ -11,20 +11,32 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = {self, nixpkgs, flake-utils, rust-overlay }:
|
outputs =
|
||||||
flake-utils.lib.eachDefaultSystem ( system:
|
{
|
||||||
|
self,
|
||||||
|
nixpkgs,
|
||||||
|
flake-utils,
|
||||||
|
rust-overlay,
|
||||||
|
}:
|
||||||
|
flake-utils.lib.eachDefaultSystem (
|
||||||
|
system:
|
||||||
let
|
let
|
||||||
overlays = [ (import rust-overlay) ];
|
overlays = [ (import rust-overlay) ];
|
||||||
pkgs = import nixpkgs {
|
pkgs = import nixpkgs {
|
||||||
inherit system overlays;
|
inherit system overlays;
|
||||||
};
|
};
|
||||||
toolchain = pkgs.rust-bin.stable.latest.default.override {
|
toolchain = pkgs.rust-bin.stable.latest.default.override {
|
||||||
extensions = ["rust-src" "clippy" "rust-analyzer"];
|
extensions = [
|
||||||
|
"rust-src"
|
||||||
|
"clippy"
|
||||||
|
"rust-analyzer"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
buildInputs = with pkgs; [
|
buildInputs = with pkgs; [
|
||||||
llvm
|
llvm
|
||||||
];
|
];
|
||||||
in {
|
in
|
||||||
|
{
|
||||||
devShells.default = pkgs.mkShell {
|
devShells.default = pkgs.mkShell {
|
||||||
stdenv = pkgs.clangStdenv;
|
stdenv = pkgs.clangStdenv;
|
||||||
packages = with pkgs; [
|
packages = with pkgs; [
|
||||||
|
|
@ -40,7 +52,7 @@
|
||||||
cargo
|
cargo
|
||||||
];
|
];
|
||||||
inherit buildInputs;
|
inherit buildInputs;
|
||||||
|
|
||||||
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildInputs;
|
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildInputs;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,42 +33,54 @@ let
|
||||||
rustc-wasm = pkgs.rust-bin.stable.latest.default.override {
|
rustc-wasm = pkgs.rust-bin.stable.latest.default.override {
|
||||||
targets = [ "wasm32-unknown-unknown" ];
|
targets = [ "wasm32-unknown-unknown" ];
|
||||||
# wasm-pack needs this
|
# wasm-pack needs this
|
||||||
extensions = [ "rust-src" "rust-analyzer" "clippy"];
|
extensions = [
|
||||||
|
"rust-src"
|
||||||
|
"rust-analyzer"
|
||||||
|
"clippy"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
# Make a shell with the dependencies we need
|
# Make a shell with the dependencies we need
|
||||||
pkgs.mkShell {
|
pkgs.mkShell {
|
||||||
packages = with pkgs; [
|
packages = with pkgs; [
|
||||||
rustc-wasm
|
rustc-wasm
|
||||||
nodejs
|
nodejs
|
||||||
cargo
|
cargo
|
||||||
cargo-watch
|
cargo-watch
|
||||||
cargo-nextest
|
cargo-nextest
|
||||||
cargo-expand
|
cargo-expand
|
||||||
wasm-pack
|
wasm-pack
|
||||||
binaryen
|
binaryen
|
||||||
wasm-bindgen-cli
|
wasm-bindgen-cli
|
||||||
vulkan-loader
|
vulkan-loader
|
||||||
libxkbcommon
|
libxkbcommon
|
||||||
llvm
|
llvm
|
||||||
gcc-unwrapped.lib
|
gcc-unwrapped.lib
|
||||||
llvmPackages.libcxxStdenv
|
llvmPackages.libcxxStdenv
|
||||||
pkg-config
|
pkg-config
|
||||||
# used for profiling
|
# used for profiling
|
||||||
gnuplot
|
gnuplot
|
||||||
samply
|
samply
|
||||||
cargo-flamegraph
|
cargo-flamegraph
|
||||||
|
|
||||||
# For Rawkit tests
|
# For Rawkit tests
|
||||||
libraw
|
libraw
|
||||||
|
|
||||||
# Use Mold as a linker
|
# Use Mold as a linker
|
||||||
mold
|
mold
|
||||||
];
|
];
|
||||||
|
|
||||||
# Hacky way to run Cargo through Mold
|
# Hacky way to run Cargo through Mold
|
||||||
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [pkgs.openssl pkgs.vulkan-loader pkgs.libxkbcommon pkgs.llvmPackages.libcxxStdenv pkgs.gcc-unwrapped.lib pkgs.llvm pkgs.libraw];
|
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [
|
||||||
shellHook = ''
|
pkgs.openssl
|
||||||
|
pkgs.vulkan-loader
|
||||||
|
pkgs.libxkbcommon
|
||||||
|
pkgs.llvmPackages.libcxxStdenv
|
||||||
|
pkgs.gcc-unwrapped.lib
|
||||||
|
pkgs.llvm
|
||||||
|
pkgs.libraw
|
||||||
|
];
|
||||||
|
shellHook = ''
|
||||||
alias cargo='mold --run cargo'
|
alias cargo='mold --run cargo'
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue