Skip to content

Commit ebb4346

Browse files
Desktop: Enable GPU nodes (#3364)
* desktop simple nix ci * make workflow manual * fixup * fix nix shell * nix fmt * fix shell
1 parent 94414ad commit ebb4346

File tree

18 files changed

+508
-253
lines changed

18 files changed

+508
-253
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Build Nix Package
2+
3+
on:
4+
workflow_dispatch: {}
5+
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
permissions:
10+
contents: read
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: DeterminateSystems/nix-installer-action@main
14+
- uses: DeterminateSystems/magic-nix-cache-action@main
15+
16+
- name: Build Nix Package Dev
17+
run: nix build .nix#graphite-dev --print-build-logs

.nix/cef.nix

Lines changed: 0 additions & 26 deletions
This file was deleted.

.nix/deps/cef.nix

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{ pkgs, inputs, ... }:
2+
3+
let
4+
libcef = pkgs.libcef.overrideAttrs (
5+
_: _: {
6+
postInstall = ''
7+
strip $out/lib/*
8+
'';
9+
}
10+
);
11+
cefPath = pkgs.runCommand "cef-path" { } ''
12+
mkdir -p $out
13+
14+
ln -s ${libcef}/include $out/include
15+
find ${libcef}/lib -type f -name "*" -exec ln -s {} $out/ \;
16+
find ${libcef}/libexec -type f -name "*" -exec ln -s {} $out/ \;
17+
cp -r ${libcef}/share/cef/* $out/
18+
19+
echo '${
20+
builtins.toJSON {
21+
type = "minimal";
22+
name = builtins.baseNameOf libcef.src.url;
23+
sha1 = "";
24+
}
25+
}' > $out/archive.json
26+
'';
27+
in
28+
{
29+
env.CEF_PATH = cefPath;
30+
}

.nix/deps/crane.nix

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{ pkgs, inputs, ... }:
2+
3+
{
4+
lib = inputs.crane.mkLib pkgs;
5+
}

.nix/deps/rust-gpu.nix

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{ pkgs, inputs, ... }:
2+
3+
let
4+
extensions = [
5+
"rust-src"
6+
"rust-analyzer"
7+
"clippy"
8+
"cargo"
9+
"rustc-dev"
10+
"llvm-tools"
11+
];
12+
toolchain = pkgs.rust-bin.nightly."2025-06-23".default.override {
13+
inherit extensions;
14+
};
15+
cargo = pkgs.writeShellScriptBin "cargo" ''
16+
#!${pkgs.lib.getExe pkgs.bash}
17+
18+
filtered_args=()
19+
for arg in "$@"; do
20+
case "$arg" in
21+
+nightly|+nightly-*) ;;
22+
*) filtered_args+=("$arg") ;;
23+
esac
24+
done
25+
26+
exec ${toolchain}/bin/cargo ${"\${filtered_args[@]}"}
27+
'';
28+
rustc_codegen_spirv =
29+
(pkgs.makeRustPlatform {
30+
cargo = toolchain;
31+
rustc = toolchain;
32+
}).buildRustPackage
33+
(finalAttrs: {
34+
pname = "rustc_codegen_spirv";
35+
version = "0-unstable-2025-08-04";
36+
src = pkgs.fetchFromGitHub {
37+
owner = "Firestar99";
38+
repo = "rust-gpu-new";
39+
rev = "c12f216121820580731440ee79ebc7403d6ea04f";
40+
hash = "sha256-rG1cZvOV0vYb1dETOzzbJ0asYdE039UZImobXZfKIno=";
41+
};
42+
cargoHash = "sha256-AEigcEc5wiBd3zLqWN/2HSbkfOVFneAqNvg9HsouZf4=";
43+
cargoBuildFlags = [
44+
"-p"
45+
"rustc_codegen_spirv"
46+
"--features=use-compiled-tools"
47+
"--no-default-features"
48+
];
49+
doCheck = false;
50+
});
51+
in
52+
{
53+
toolchain = toolchain;
54+
env = {
55+
RUST_GPU_PATH_OVERRIDE = "${cargo}/bin:${toolchain}/bin";
56+
RUSTC_CODEGEN_SPIRV_PATH = "${rustc_codegen_spirv}/lib/librustc_codegen_spirv.so";
57+
};
58+
}

.nix/dev.nix

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
pkgs,
3+
deps,
4+
libs,
5+
tools,
6+
...
7+
}:
8+
9+
pkgs.mkShell (
10+
{
11+
packages = tools.all ++ libs.all;
12+
13+
LD_LIBRARY_PATH = "${pkgs.lib.makeLibraryPath libs.all}:${deps.cef.env.CEF_PATH}";
14+
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";
15+
16+
shellHook = ''
17+
alias cargo='mold --run cargo'
18+
'';
19+
}
20+
// deps.cef.env
21+
// deps.rustGPU.env
22+
)

.nix/flake.lock

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)