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": {
|
||||
"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": {
|
||||
"locked": {
|
||||
"lastModified": 1733328505,
|
||||
|
|
@ -50,6 +65,7 @@
|
|||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"crane": "crane",
|
||||
"flake-compat": "flake-compat",
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs",
|
||||
|
|
|
|||
178
.nix/flake.nix
178
.nix/flake.nix
|
|
@ -19,52 +19,71 @@
|
|||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
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
|
||||
flake-compat.url = "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz";
|
||||
};
|
||||
|
||||
outputs = { nixpkgs, rust-overlay, flake-utils, ... }:
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
outputs =
|
||||
inputs:
|
||||
inputs.flake-utils.lib.eachDefaultSystem (
|
||||
system:
|
||||
let
|
||||
overlays = [ (import rust-overlay) ];
|
||||
pkgs = import nixpkgs { inherit system overlays; };
|
||||
|
||||
rustExtensions = [ "rust-src" "rust-analyzer" "clippy" "cargo" ];
|
||||
rust = pkgs.rust-bin.stable.latest.default.override {
|
||||
targets = [ "wasm32-unknown-unknown" ];
|
||||
extensions = rustExtensions;
|
||||
info = {
|
||||
pname = "graphite";
|
||||
version = "unstable";
|
||||
src = ./..;
|
||||
};
|
||||
|
||||
# Shared build inputs; libraries that need to be in LD_LIBRARY_PATH
|
||||
buildInputs = [
|
||||
pkgs = import inputs.nixpkgs {
|
||||
inherit system;
|
||||
overlays = [ (import inputs.rust-overlay) ];
|
||||
};
|
||||
|
||||
deps = {
|
||||
crane = import ./deps/crane.nix { inherit pkgs inputs; };
|
||||
cef = import ./deps/cef.nix { inherit pkgs inputs; };
|
||||
rustGPU = import ./deps/rust-gpu.nix { inherit pkgs inputs; };
|
||||
};
|
||||
|
||||
libs = rec {
|
||||
desktop = [
|
||||
pkgs.wayland
|
||||
pkgs.openssl
|
||||
pkgs.vulkan-loader
|
||||
pkgs.libraw
|
||||
pkgs.libGL
|
||||
|
||||
# X11 libraries, not needed on wayland! Remove when x11 is finally dead
|
||||
];
|
||||
desktop-x11 = [
|
||||
pkgs.libxkbcommon
|
||||
pkgs.xorg.libXcursor
|
||||
pkgs.xorg.libxcb
|
||||
pkgs.xorg.libX11
|
||||
];
|
||||
desktop-all = desktop ++ desktop-x11;
|
||||
all = desktop-all;
|
||||
};
|
||||
|
||||
# Packages needed to build the package
|
||||
buildTools = [
|
||||
rust
|
||||
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.pkg-config
|
||||
pkgs.cargo-about
|
||||
];
|
||||
dev = [
|
||||
pkgs.rustc
|
||||
pkgs.cargo
|
||||
pkgs.rust-analyzer
|
||||
pkgs.clippy
|
||||
|
||||
# Development tools; not needed to build the package
|
||||
devTools = [
|
||||
pkgs.git
|
||||
|
||||
pkgs.cargo-watch
|
||||
|
|
@ -79,81 +98,58 @@
|
|||
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;
|
||||
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
|
||||
;
|
||||
};
|
||||
|
||||
# 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=";
|
||||
default = graphite;
|
||||
};
|
||||
|
||||
npmRoot = "frontend";
|
||||
npmConfigScript = "setup";
|
||||
makeCacheWritable = true;
|
||||
devShells.default = import ./dev.nix {
|
||||
inherit
|
||||
pkgs
|
||||
deps
|
||||
libs
|
||||
tools
|
||||
;
|
||||
};
|
||||
|
||||
buildInputs = buildInputs;
|
||||
nativeBuildInputs = buildTools ++ [
|
||||
pkgs.rustPlatform.cargoSetupHook
|
||||
pkgs.npmHooks.npmConfigHook
|
||||
pkgs.makeWrapper
|
||||
];
|
||||
|
||||
env = cefEnv // rustGPUEnv;
|
||||
|
||||
buildPhase = ''
|
||||
export HOME="$TMPDIR"
|
||||
|
||||
pushd frontend
|
||||
npm run build-native
|
||||
popd
|
||||
cargo build -r -p graphite-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/
|
||||
'';
|
||||
|
||||
doCheck = false;
|
||||
|
||||
postFixup = ''
|
||||
wrapProgram "$out/bin/graphite-editor" \
|
||||
--prefix LD_LIBRARY_PATH : "${libPath}" \
|
||||
--set CEF_PATH "${cefEnv.CEF_PATH}"
|
||||
'';
|
||||
});
|
||||
});
|
||||
formatter = pkgs.nixfmt-tree;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,8 +16,7 @@
|
|||
# > nix-shell .nix --command "npm start"
|
||||
|
||||
# Uses flake compat to provide a development shell that is identical to the one defined in the flake
|
||||
(import
|
||||
(
|
||||
(import (
|
||||
let
|
||||
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
|
||||
nodeName = lock.nodes.root.inputs.flake-compat;
|
||||
|
|
@ -26,6 +25,4 @@
|
|||
url = lock.nodes.${nodeName}.locked.url;
|
||||
sha256 = lock.nodes.${nodeName}.locked.narHash;
|
||||
}
|
||||
)
|
||||
{ src = ./.; }
|
||||
).shellNix
|
||||
) { src = ./.; }).shellNix
|
||||
|
|
|
|||
|
|
@ -8,6 +8,10 @@ repository = ""
|
|||
edition = "2024"
|
||||
rust-version = "1.87"
|
||||
|
||||
[[bin]]
|
||||
name = "graphite"
|
||||
path = "src/main.rs"
|
||||
|
||||
[features]
|
||||
default = ["recommended", "embedded_resources"]
|
||||
recommended = ["gpu", "accelerated_paint"]
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Name=Graphite
|
||||
GenericName=Vector & Raster Graphics Editor
|
||||
Comment=Open-source vector & raster graphics editor. Featuring node based procedural nondestructive editing workflow.
|
||||
Exec=graphite-editor
|
||||
Exec=graphite
|
||||
Terminal=false
|
||||
Type=Application
|
||||
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() {
|
||||
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}");
|
||||
if let Ok(resources) = crate_dir.join(RESOURCES).canonicalize()
|
||||
println!("cargo:rerun-if-env-changed={EMBEDDED_RESOURCES_ENV}");
|
||||
if let Ok(embedded_resources_env) = std::env::var(EMBEDDED_RESOURCES_ENV)
|
||||
&& 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-env=EMBEDDED_RESOURCES={}", resources.to_string_lossy());
|
||||
println!("cargo:rustc-env={EMBEDDED_RESOURCES_ENV}={embedded_resources}");
|
||||
} else {
|
||||
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"
|
||||
|
||||
[features]
|
||||
default = ["gpu"]
|
||||
gpu = ["graphite-editor/gpu"]
|
||||
gpu = ["graphite-editor/gpu", "graphene-std/shader-nodes"]
|
||||
|
||||
[dependencies]
|
||||
# Local dependencies
|
||||
|
|
|
|||
|
|
@ -11,20 +11,32 @@
|
|||
};
|
||||
};
|
||||
|
||||
outputs = {self, nixpkgs, flake-utils, rust-overlay }:
|
||||
flake-utils.lib.eachDefaultSystem ( system:
|
||||
outputs =
|
||||
{
|
||||
self,
|
||||
nixpkgs,
|
||||
flake-utils,
|
||||
rust-overlay,
|
||||
}:
|
||||
flake-utils.lib.eachDefaultSystem (
|
||||
system:
|
||||
let
|
||||
overlays = [ (import rust-overlay) ];
|
||||
pkgs = import nixpkgs {
|
||||
inherit system overlays;
|
||||
};
|
||||
toolchain = pkgs.rust-bin.stable.latest.default.override {
|
||||
extensions = ["rust-src" "clippy" "rust-analyzer"];
|
||||
extensions = [
|
||||
"rust-src"
|
||||
"clippy"
|
||||
"rust-analyzer"
|
||||
];
|
||||
};
|
||||
buildInputs = with pkgs; [
|
||||
llvm
|
||||
];
|
||||
in {
|
||||
in
|
||||
{
|
||||
devShells.default = pkgs.mkShell {
|
||||
stdenv = pkgs.clangStdenv;
|
||||
packages = with pkgs; [
|
||||
|
|
|
|||
|
|
@ -33,11 +33,15 @@ let
|
|||
rustc-wasm = pkgs.rust-bin.stable.latest.default.override {
|
||||
targets = [ "wasm32-unknown-unknown" ];
|
||||
# wasm-pack needs this
|
||||
extensions = [ "rust-src" "rust-analyzer" "clippy"];
|
||||
extensions = [
|
||||
"rust-src"
|
||||
"rust-analyzer"
|
||||
"clippy"
|
||||
];
|
||||
};
|
||||
in
|
||||
# Make a shell with the dependencies we need
|
||||
pkgs.mkShell {
|
||||
# Make a shell with the dependencies we need
|
||||
pkgs.mkShell {
|
||||
packages = with pkgs; [
|
||||
rustc-wasm
|
||||
nodejs
|
||||
|
|
@ -67,8 +71,16 @@ in
|
|||
];
|
||||
|
||||
# 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 [
|
||||
pkgs.openssl
|
||||
pkgs.vulkan-loader
|
||||
pkgs.libxkbcommon
|
||||
pkgs.llvmPackages.libcxxStdenv
|
||||
pkgs.gcc-unwrapped.lib
|
||||
pkgs.llvm
|
||||
pkgs.libraw
|
||||
];
|
||||
shellHook = ''
|
||||
alias cargo='mold --run cargo'
|
||||
'';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue