GramEditor/gram
38
985
Fork
You've already forked gram
88

WIP: Recreate the Nix flake #54

Closed
tasiaiso wants to merge 14 commits from tasiaiso:restore-nix into main
pull from: tasiaiso:restore-nix
merge into: GramEditor:main
GramEditor:main
GramEditor:test/wgpu-on-mac
GramEditor:test-ci/failing-test-mac
GramEditor:test/failing-test-mac
GramEditor:test/build-on-22-04
GramEditor:test/wgpu-present-mode-mailbox
GramEditor:v2.1
GramEditor:test/altgr-fix-again
GramEditor:test/2.0.0-rc1
GramEditor:test/linux-build
GramEditor:test/objc2
GramEditor:v1.2.1
First-time contributor
Copy link

Solves #29

Solves #29
Author
First-time contributor
Copy link

I should remove the dockerfiles that have been restored reverting the original commit

I should remove the dockerfiles that have been restored reverting the original commit
- delete the wrongly-restored Dockerfiles
- silence warnings
Author
First-time contributor
Copy link

#54 (comment) is solved

Couple of issues to investigate for now:

  • We most likely need to provide a working rust environment to install extensions (i didnt run into this issue because i have a rust toolchain installed on my user)
  • I've had to run rustup target add wasm32-wasip2 on my host in order to install extensions. Maybe adding cargo-wasi in the runtime dependencies could help, but im not too sure.
  • #58
  • I'm not sure what the names binaries that are exported should be. Right now they are gram and gramitor, a funny artifact of me replace zed with gram. I decided to leave it in, maybe you don't. lmk.
  • Write docs on how to use the flake and build Gram using nix.
  • #54 (comment)
  • Try on aarch64-linux
  • Try on x86_64-darwin
  • Try on aarch64-darwin
  • Upstream !54 (commit 163903e3d9) and revert to original repo
https://codeberg.org/GramEditor/gram/pulls/54#issuecomment-11322583 is solved Couple of issues to investigate for now: - [ ] We most likely need to provide a working rust environment to install extensions (i didnt run into this issue because i have a rust toolchain installed on my user) - [ ] I've had to run `rustup target add wasm32-wasip2` on my host in order to install extensions. *Maybe* adding `cargo-wasi` in the runtime dependencies could help, but im not too sure. - [ ] #58 - [x] I'm not sure what the names binaries that are exported should be. Right now they are `gram` and `gramitor`, a funny artifact of me replace `zed` with `gram`. I decided to leave it in, maybe you don't. lmk. - [ ] Write docs on how to use the flake and build Gram using nix. - [ ] https://codeberg.org/GramEditor/gram/pulls/54#issuecomment-11349061 - [ ] Try on aarch64-linux - [ ] Try on x86_64-darwin - [ ] Try on aarch64-darwin - [ ] Upstream https://codeberg.org/GramEditor/gram/pulls/54/commits/163903e3d99005b0ae96076db57bebc3bf8acab6 and revert to original repo
krig left a comment
Copy link

Hi!

Thank you for contributing to this project, but I don't think this PR is ready to be merged. If the Dockerfiles are needed by Nix, I think they should be moved to the nix/ folder. I have left som other comments but yeah I think this needs more work before merging.

Hi! Thank you for contributing to this project, but I don't think this PR is ready to be merged. If the Dockerfiles are needed by Nix, I think they should be moved to the `nix/` folder. I have left som other comments but yeah I think this needs more work before merging.
flake.nix Outdated
@ -0,0 +1,66 @@
{
description = "High-performance,multiplayercodeeditorfromthecreatorsofAtomandTree-sitter";
Owner
Copy link

Please replace this with the Gram tagline "A code editor for humanoid apes and grumpy toads" :)

Please replace this with the Gram tagline "A code editor for humanoid apes and grumpy toads" :)
tasiaiso marked this conversation as resolved
flake.nix Outdated
@ -0,0 +54,4 @@
};
nixConfig = {
# extra-substituters = [
Owner
Copy link

Probably best to remove these comments

Probably best to remove these comments
tasiaiso marked this conversation as resolved
@ -0,0 +17,4 @@
makeFontsConf,
makeWrapper,
alsa-lib,
Owner
Copy link

Gram doesn't need alsa

Gram doesn't need alsa
tasiaiso marked this conversation as resolved
@ -0,0 +26,4 @@
libgit2,
libglvnd,
libxkbcommon,
livekit-libwebrtc,
Owner
Copy link

Gram doesn't need livekit

Gram doesn't need livekit
tasiaiso marked this conversation as resolved
@ -0,0 +97,4 @@
++ lib.optionals stdenv'.hostPlatform.isDarwin [
(cargo-bundle.overrideAttrs (
new: old: {
version = "0.6.1-gram";
Owner
Copy link

This version should be 0.6.1-zed to match the cargo-bundle repo

This version should be `0.6.1-zed` to match the cargo-bundle repo
Author
First-time contributor
Copy link

surprised i didnt catch that lol

surprised i didnt catch that lol
tasiaiso marked this conversation as resolved
@ -0,0 +135,4 @@
zstd
]
++ lib.optionals stdenv'.hostPlatform.isLinux [
alsa-lib
Owner
Copy link

gram shouldn't depend on alsa

gram shouldn't depend on alsa
tasiaiso marked this conversation as resolved
nix/build.nix Outdated
@ -0,0 +173,4 @@
../assets/fonts/fira-sans
];
};
GRAM_UPDATE_EXPLANATION = "GramhasbeeninstalledusingNix.Auto-updateshavethusbeendisabled.";
Owner
Copy link

GRAM_UPDATE_EXPLANATION can be removed, Gram doesn't have auto updates.

`GRAM_UPDATE_EXPLANATION` can be removed, Gram doesn't have auto updates.
Owner
Copy link

LK_CUSTOM_WEBRTC can be removed, Gram doesn't use LiveKit / WebRTC.

`LK_CUSTOM_WEBRTC` can be removed, Gram doesn't use LiveKit / WebRTC.
tasiaiso marked this conversation as resolved
@ -0,0 +204,4 @@
inherit src cargoLock;
overrideVendorGitCheckout =
let
hasWebRtcSys = builtins.any (crate: crate.name == "webrtc-sys");
Owner
Copy link

hasWebRtcSys should be removed

`hasWebRtcSys` should be removed
tasiaiso marked this conversation as resolved
nix/build.nix Outdated
@ -0,0 +245,4 @@
# TODO: put this in a separate derivation that depends on src to avoid running it on every build
preBuild = ''
ALLOW_MISSING_LICENSES=yes bash script/generate-licenses
echo dev > crates/gram/RELEASE_CHANNEL
Owner
Copy link

I don't think it's necessary to update RELEASE_CHANNEL here

I don't think it's necessary to update `RELEASE_CHANNEL` here
tasiaiso marked this conversation as resolved
nix/build.nix Outdated
@ -0,0 +267,4 @@
# Physical location of the CLI must be inside the app bundle as this is used
# to determine which app to start
ln -s "$out/Applications/GramDev.app/Contents/MacOS/cli" $out/bin/gram
Owner
Copy link

If the RELEASE_CHANNEL file isn't written above, then this should be Gram.app, not Gram Dev.app

If the `RELEASE_CHANNEL` file isn't written above, then this should be `Gram.app`, not `Gram Dev.app`
tasiaiso marked this conversation as resolved
nix/build.nix Outdated
@ -0,0 +278,4 @@
mkdir -p $out/bin $out/libexec
cp $TARGET_DIR/gram $out/libexec/gram-editor
cp $TARGET_DIR/cli $out/bin/gram
ln -s $out/bin/gram $out/bin/gramitor # home-manager expects the CLI binary to be here
Owner
Copy link

gramitor seems odd, should this be gram-editor?

`gramitor` seems odd, should this be `gram-editor`?
First-time contributor
Copy link

this was probably a little funny side-effect from s/zed/gram/gi

this was probably a little funny side-effect from `s/zed/gram/gi`
Author
First-time contributor
Copy link

yep #54 (comment)

i did see that but i found it funny so i left it in as-is, i'll change it

yep https://codeberg.org/GramEditor/gram/pulls/54#issuecomment-11347996 i did see that but i found it funny so i left it in as-is, i'll change it
tasiaiso marked this conversation as resolved
nix/build.nix Outdated
@ -0,0 +282,4 @@
install -D "crates/gram/resources/app-icon-dev@2x.png" \
"$out/share/icons/hicolor/1024x1024@2x/apps/gram.png"
Owner
Copy link

Ok yeah all these lines assume that the release channel is dev.. Maybe it should be configurable?

Ok yeah all these lines assume that the release channel is `dev`.. Maybe it should be configurable?
nix/build.nix Outdated
@ -0,0 +306,4 @@
wrapProgram $out/libexec/gram-editor --suffix PATH : ${lib.makeBinPath [ nodejs_22 ]}
'';
meta = {
Owner
Copy link

These should all be updated for Gram.

These should all be updated for Gram.
tasiaiso marked this conversation as resolved
@ -0,0 +43,4 @@
})).env; # exfil `env`; it's not in drvAttrs
in
(removeAttrs baseEnvs [
"LK_CUSTOM_WEBRTC" # download the staticlib during the build as usual
Owner
Copy link

LiveKit/WebRTC should be removed

LiveKit/WebRTC should be removed
tasiaiso marked this conversation as resolved
nix/shell.nix Outdated
@ -0,0 +44,4 @@
in
(removeAttrs baseEnvs [
"LK_CUSTOM_WEBRTC" # download the staticlib during the build as usual
"GRAM_UPDATE_EXPLANATION" # allow auto-updates
Owner
Copy link

Gram doesn't have auto updates so this can be removed

Gram doesn't have auto updates so this can be removed
tasiaiso marked this conversation as resolved
Owner
Copy link

I just pushed an fix for GRAM_UPDATE_EXPLANATION: I updated the documentation and renamed it to GRAM_NO_BUNDLED_UNINSTALL since the only thing it does in Gram is to remove the bundled uninstallation script. So the Nix build should set that environment variable to something like "Use nix to uninstall gram".

I just pushed an fix for GRAM_UPDATE_EXPLANATION: I updated the documentation and renamed it to GRAM_NO_BUNDLED_UNINSTALL since the only thing it does in Gram is to remove the bundled uninstallation script. So the Nix build should set that environment variable to something like "Use nix to uninstall gram".
flake.nix Outdated
@ -0,0 +37,4 @@
rustToolchain = rustBin.fromRustupToolchainFile ./rust-toolchain.toml;
};
in
rec {
First-time contributor
Copy link

could i suggest using self.packages instead of rec

could i suggest using `self.packages` instead of `rec`
Author
First-time contributor
Copy link

sure! is there a technical difference between the two exactly? i agree it seems more intuitive. thanks for the review.

sure! is there a technical difference between the two exactly? i agree it seems more intuitive. thanks for the review.
apply some recommendations and try a fix
Some checks failed
Build and test / test-amd64 (pull_request) Has been cancelled
845e8788be
nix/build.nix Outdated
@ -0,0 +295,4 @@
export APP_NAME="GramDev"
export APP_ARGS="%U"
mkdir -p "$out/share/applications"
${lib.getExe envsubst} < "crates/gram/resources/gram.desktop.in" > "$out/share/applications/dev.gram.Gram-Dev.desktop"
Owner
Copy link

Just noticed, the app id should probably be app.liten.Gram-Dev, not dev.gram.Gram-Dev to match the app id used in the binary and the other installation variants.

Just noticed, the app id should probably be `app.liten.Gram-Dev`, not `dev.gram.Gram-Dev` to match the app id used in the binary and the other installation variants.
tasiaiso marked this conversation as resolved
@ -0,0 +49,4 @@
"TARGET_DIR"
])
// {
# note: different than `$FONTCONFIG_FILE` in `build.nix` this refers to relative paths
Owner
Copy link

Looks like at least this part was generated, did you get this from the Zed repo or some other example? Either way please replace the em dash with an ascii character to avoid the little warning triangle.

Looks like at least this part was generated, did you get this from the Zed repo or some other example? Either way please replace the em dash with an ascii character to avoid the little warning triangle.
Author
First-time contributor
Copy link

This is straight from the zed repo, i just reverted the commit that deleted this file (4926c6d6a4), which does seem to be an AI generated commit (4a7c84f490). I myself didn't use AI at any point of my work.

This is straight from the zed repo, i just reverted the commit that deleted this file (https://codeberg.org/GramEditor/gram/commit/4926c6d6a43a626e873e39024197a4e51b5bfa72), which does seem to be an AI generated commit (https://codeberg.org/GramEditor/gram/commit/4a7c84f490b6ab7d1ba1628ed0dc5433f18dcceb). I myself didn't use AI at any point of my work.
Owner
Copy link

Thank you :)

Thank you :)
tasiaiso marked this conversation as resolved
revert dumb patch, try actual fix
Some checks failed
Build and test / test-amd64 (pull_request) Has been cancelled
163903e3d9
Author
First-time contributor
Copy link

We need help trying this on aarch64 and darwin if possible.

We need help trying this on aarch64 and darwin if possible.
apply review comments
Some checks failed
Build and test / test-amd64 (pull_request) Has been cancelled
9403a8bf58
Author
First-time contributor
Copy link

In !54 (commit 163903e3d9) I changed the tree-sitter-sql url to my fork, CI was failing because there is a reference to the README file in Cargo.toml but not in the crate's actual branch (https://github.com/DerekStride/tree-sitter-sql/tree/gh-pages)

I should open a PR to upstream the change, this is what we have in the meantime.

In https://codeberg.org/GramEditor/gram/pulls/54/commits/163903e3d99005b0ae96076db57bebc3bf8acab6 I changed the `tree-sitter-sql` url to my fork, CI was failing because there is a reference to the README file in Cargo.toml but not in the crate's actual branch (https://github.com/DerekStride/tree-sitter-sql/tree/gh-pages) I should open a PR to upstream the change, this is what we have in the meantime.
Owner
Copy link

Looking good from what I can see, which admittedly is just surface level. Haven't used Nix much at all, but I am interested in learning to use flakes. Anyway, great work!

Looking good from what I can see, which admittedly is just surface level. Haven't used Nix much at all, but I am interested in learning to use flakes. Anyway, great work!
carelessness
Some checks failed
Build and test / test-amd64 (pull_request) Has been cancelled
6e31f6725b
Author
First-time contributor
Copy link

Thanks! I've fixed some things and I've told the CI to do its thing. We'll see. Either way there's a bunch of stuff I want to polish before getting this out the door (unless you're willing to merge an unfinished package and work on more complex fixes in another PR, your call). I still need to review everything before I give my green light.

Thanks! I've fixed some things and I've told the CI to do its thing. We'll see. Either way there's a bunch of stuff I want to polish before getting this out the door (unless you're willing to merge an unfinished package and work on more complex fixes in another PR, your call). I still need to review everything before I give my green light.
add hydra support
Some checks failed
Build and test / test-amd64 (pull_request) Has been cancelled
691937da38
Owner
Copy link

No rush! I would like to give it a go at testing it myself too before merging, and I have at least one fix I am working on before I will start thinking about another release or anything like that.

No rush! I would like to give it a go at testing it myself too before merging, and I have at least one fix I am working on before I will start thinking about another release or anything like that.
local build is good, send to ci
All checks were successful
Build and test / test-amd64 (pull_request) Successful in 45m7s
60becc9dc1
Owner
Copy link

I added this to main which I think can be useful for nix to get a reproducible build: 70a8786f79

I added this to main which I think can be useful for nix to get a reproducible build: https://codeberg.org/GramEditor/gram/commit/70a8786f79f85aa210d473144de5b858b3b9a4ed
First-time contributor
Copy link

tried to build on darwin_x86-64 , did not succeed

error: builder for '/nix/store/v6svdn4hvm51vvbf26az8myzg40b8l48-gram-editor-1.0.0-dev.drv' failed with exit code 1;
 last 25 log lines:
 > installing /nix/var/nix/b/070j7m9gfgf5i4p73vz1x2qndg/source/target/release/gram in postBuildInstallFromCargoBuildLogOutTemp9xS/bin
 > searching for bins/libs complete
 > buildPhase completed in 15 hours 42 minutes 34 seconds
 > Running phase: installPhase
 > /nix/var/nix/b/070j7m9gfgf5i4p73vz1x2qndg/source/crates/gram /nix/var/nix/b/070j7m9gfgf5i4p73vz1x2qndg/source
 > ++++ command cargo bundle --profile release
 > Bundling Gram Dev.app
 > Finished 1 bundle at:
 > /nix/var/nix/b/070j7m9gfgf5i4p73vz1x2qndg/source
 > stripping references to Rust toolchain
 > Rust toolchain at: /nix/store/1blgpp80g2y3in03zy38mjjj7wfvmmyv-rust-minimal-1.93.1
 > stripping Rust toolchain references done
 > stripping references to cargoVendorDir from:
 > /nix/store/ijy2p2sgk92yf9vlw6p4d4nfkh2r24ck-gram-editor-1.0.0-dev/Applications/Gram Dev.app/Contents/Info.plist
 > /nix/store/ijy2p2sgk92yf9vlw6p4d4nfkh2r24ck-gram-editor-1.0.0-dev/Applications/Gram Dev.app/Contents/MacOS/cli
 > /nix/store/ijy2p2sgk92yf9vlw6p4d4nfkh2r24ck-gram-editor-1.0.0-dev/Applications/Gram Dev.app/Contents/MacOS/gram
 > /nix/store/ijy2p2sgk92yf9vlw6p4d4nfkh2r24ck-gram-editor-1.0.0-dev/Applications/Gram Dev.app/Contents/Resources/Gram Dev.icns
 > stripping references done
 > installPhase completed in 5 minutes 4 seconds
 > Running phase: fixupPhase
 > checking for references to /nix/var/nix/b/070j7m9gfgf5i4p73vz1x2qndg/ in /nix/store/ijy2p2sgk92yf9vlw6p4d4nfkh2r24ck-gram-editor-1.0.0-dev...
 > patching script interpreter paths in /nix/store/ijy2p2sgk92yf9vlw6p4d4nfkh2r24ck-gram-editor-1.0.0-dev
 > stripping (with command strip and flags -S) in /nix/store/ijy2p2sgk92yf9vlw6p4d4nfkh2r24ck-gram-editor-1.0.0-dev/bin /nix/store/ijy2p2sgk92yf9vlw6p4d4nfkh2r24ck-gram-editor-1.0.0-dev/Applications
 > ERROR: noBrokenSymlinks: the symlink /nix/store/ijy2p2sgk92yf9vlw6p4d4nfkh2r24ck-gram-editor-1.0.0-dev/bin/gram points to a missing target: /nix/store/ijy2p2sgk92yf9vlw6p4d4nfkh2r24ck-gram-editor-1.0.0-dev/Applications/Gram.app/Contents/MacOS/cli
 > ERROR: noBrokenSymlinks: found 1 dangling symlinks, 0 reflexive symlinks and 0 unreadable symlinks
 For full logs, run:
 	nix log /nix/store/v6svdn4hvm51vvbf26az8myzg40b8l48-gram-editor-1.0.0-dev.drv

built with nom build .
unfortunate that it failed in the fixup phase lol , means the build completed after like 15h48m18s , and failed right at the end , so sad .

macOS 15.7.4
MacBookAir6,2
tried to build on darwin_x86-64 , did not succeed <details> ``` error: builder for '/nix/store/v6svdn4hvm51vvbf26az8myzg40b8l48-gram-editor-1.0.0-dev.drv' failed with exit code 1; last 25 log lines: > installing /nix/var/nix/b/070j7m9gfgf5i4p73vz1x2qndg/source/target/release/gram in postBuildInstallFromCargoBuildLogOutTemp9xS/bin > searching for bins/libs complete > buildPhase completed in 15 hours 42 minutes 34 seconds > Running phase: installPhase > /nix/var/nix/b/070j7m9gfgf5i4p73vz1x2qndg/source/crates/gram /nix/var/nix/b/070j7m9gfgf5i4p73vz1x2qndg/source > ++++ command cargo bundle --profile release > Bundling Gram Dev.app > Finished 1 bundle at: > /nix/var/nix/b/070j7m9gfgf5i4p73vz1x2qndg/source > stripping references to Rust toolchain > Rust toolchain at: /nix/store/1blgpp80g2y3in03zy38mjjj7wfvmmyv-rust-minimal-1.93.1 > stripping Rust toolchain references done > stripping references to cargoVendorDir from: > /nix/store/ijy2p2sgk92yf9vlw6p4d4nfkh2r24ck-gram-editor-1.0.0-dev/Applications/Gram Dev.app/Contents/Info.plist > /nix/store/ijy2p2sgk92yf9vlw6p4d4nfkh2r24ck-gram-editor-1.0.0-dev/Applications/Gram Dev.app/Contents/MacOS/cli > /nix/store/ijy2p2sgk92yf9vlw6p4d4nfkh2r24ck-gram-editor-1.0.0-dev/Applications/Gram Dev.app/Contents/MacOS/gram > /nix/store/ijy2p2sgk92yf9vlw6p4d4nfkh2r24ck-gram-editor-1.0.0-dev/Applications/Gram Dev.app/Contents/Resources/Gram Dev.icns > stripping references done > installPhase completed in 5 minutes 4 seconds > Running phase: fixupPhase > checking for references to /nix/var/nix/b/070j7m9gfgf5i4p73vz1x2qndg/ in /nix/store/ijy2p2sgk92yf9vlw6p4d4nfkh2r24ck-gram-editor-1.0.0-dev... > patching script interpreter paths in /nix/store/ijy2p2sgk92yf9vlw6p4d4nfkh2r24ck-gram-editor-1.0.0-dev > stripping (with command strip and flags -S) in /nix/store/ijy2p2sgk92yf9vlw6p4d4nfkh2r24ck-gram-editor-1.0.0-dev/bin /nix/store/ijy2p2sgk92yf9vlw6p4d4nfkh2r24ck-gram-editor-1.0.0-dev/Applications > ERROR: noBrokenSymlinks: the symlink /nix/store/ijy2p2sgk92yf9vlw6p4d4nfkh2r24ck-gram-editor-1.0.0-dev/bin/gram points to a missing target: /nix/store/ijy2p2sgk92yf9vlw6p4d4nfkh2r24ck-gram-editor-1.0.0-dev/Applications/Gram.app/Contents/MacOS/cli > ERROR: noBrokenSymlinks: found 1 dangling symlinks, 0 reflexive symlinks and 0 unreadable symlinks For full logs, run: nix log /nix/store/v6svdn4hvm51vvbf26az8myzg40b8l48-gram-editor-1.0.0-dev.drv ``` </details> built with `nom build .` unfortunate that it failed in the fixup phase lol , means the build completed after like 15h48m18s , and failed right at the end , so sad . ``` macOS 15.7.4 MacBookAir6,2 ```
Owner
Copy link

Most of the nix build is setting the RELEASE_CHANNEL to dev which names the app Gram Dev.app, but it looks like at least some part is using Gram.app as the app name.

Personally I think the right fix is to keep RELEASE_CHANNEL set to stable and use Gram.app throughout, but I'm not sure which bits are intended for a flake dev environment and what is meant to be able to install on NixOS.. maybe the right approach would be to use dev for the flake and stable for a NixOS build.

Most of the nix build is setting the `RELEASE_CHANNEL` to `dev` which names the app `Gram Dev.app`, but it looks like at least some part is using `Gram.app` as the app name. Personally I think the right fix is to keep `RELEASE_CHANNEL` set to `stable` and use `Gram.app` throughout, but I'm not sure which bits are intended for a flake dev environment and what is meant to be able to install on NixOS.. maybe the right approach would be to use `dev` for the flake and `stable` for a NixOS build.
alemonmk left a comment
Copy link

After changes release and debug builds on my MacBookPro16,1 Sequoia 15.7.2, great job!

(削除) Though debug build crashes on startup: (削除ここまで) Okay figured out it is rust-embed's default behavior.

INFO [crashes] crash handler registered
ERROR [crashes] thread 'main' panicked at /nix/var/nix/builds/nix-<snip>/source/crates/util/src/util.rs:827:24:
settings/default.jsonc...
ERROR [crashes] triggering a crash to generate a minidump...
After changes release and debug builds on my MacBookPro16,1 Sequoia 15.7.2, great job! ~~Though debug build crashes on startup:~~ Okay figured out it is rust-embed's default behavior. ``` INFO [crashes] crash handler registered ERROR [crashes] thread 'main' panicked at /nix/var/nix/builds/nix-<snip>/source/crates/util/src/util.rs:827:24: settings/default.jsonc... ERROR [crashes] triggering a crash to generate a minidump... ```
flake.nix Outdated
@ -0,0 +44,4 @@
});
devShells = forAllSystems (pkgs: {
default = pkgs.callPackage ./nix/shell.nix {
gram-editor = self.packages.${pkgs.stdenv.hostPlatform.system}.default;
First-time contributor
Copy link
- gram-editor = self.packages.${pkgs.stdenv.hostPlatform.system}.default;
+ gram-editor = self.packages.${pkgs.stdenv.hostPlatform.system}.debug;

It's environment for development, would it make more sense to run debug build here?

```diff - gram-editor = self.packages.${pkgs.stdenv.hostPlatform.system}.default; + gram-editor = self.packages.${pkgs.stdenv.hostPlatform.system}.debug; ``` It's environment for development, would it make more sense to run debug build here?
tasiaiso marked this conversation as resolved
@ -0,0 +41,4 @@
profile ? "release",
}:
assert withGLES -> stdenv.hostPlatform.isLinux;
let
First-time contributor
Copy link
 profile ? "release",
 }:
 assert withGLES -> stdenv.hostPlatform.isLinux;
+ assert
+ lib.assertOneOf "profile" profile [
+ "release"
+ "release-fast"
+ "dev"
+ ];
+ -> true;
 let

Having an assertion here would be beneficial.

```diff profile ? "release", }: assert withGLES -> stdenv.hostPlatform.isLinux; + assert + lib.assertOneOf "profile" profile [ + "release" + "release-fast" + "dev" + ]; + -> true; let ``` Having an assertion here would be beneficial.
nix/build.nix Outdated
@ -0,0 +67,4 @@
gpu-lib = if withGLES then libglvnd else vulkan-loader;
commonArgs =
let
gramCargoLock = builtins.fromTOML (builtins.readFile ../crates/gram/Cargo.toml);
First-time contributor
Copy link
+ gramCargoLock = builtins.fromTOML (builtins.readFile ../crates/gram/Cargo.toml);
 gpu-lib = if withGLES then libglvnd else vulkan-loader;
 commonArgs =
	let
- 	 gramCargoLock = builtins.fromTOML (builtins.readFile ../crates/gram/Cargo.toml);
	 stdenv' = stdenv;
	in

I moved it out so I can use it below.

```diff + gramCargoLock = builtins.fromTOML (builtins.readFile ../crates/gram/Cargo.toml); gpu-lib = if withGLES then libglvnd else vulkan-loader; commonArgs = let - gramCargoLock = builtins.fromTOML (builtins.readFile ../crates/gram/Cargo.toml); stdenv' = stdenv; in ``` I moved it out so I can use it below.
tasiaiso marked this conversation as resolved
nix/build.nix Outdated
@ -0,0 +72,4 @@
in
rec {
pname = "gram-editor";
version = gramCargoLock.package.version + "-dev";
First-time contributor
Copy link

Only add -dev suffix when running debug build?

Only add `-dev` suffix when running debug build?
@ -0,0 +229,4 @@
ALLOW_MISSING_LICENSES=yes bash script/generate-licenses
'';
installPhase =
First-time contributor
Copy link
 installPhase =
+ let
+ bundleProfile = if profile == "dev" then "dev" else "stable";
+ targetSection = "bundle-${bundleProfile}";
+ bundleName = gramCargoLock.package.metadata."${targetSection}".name;
+ appIdentifier = gramCargoLock.package metadata."${targetSection}".identifier;
+ in
 if stdenv.hostPlatform.isDarwin then
```diff installPhase = + let + bundleProfile = if profile == "dev" then "dev" else "stable"; + targetSection = "bundle-${bundleProfile}"; + bundleName = gramCargoLock.package.metadata."${targetSection}".name; + appIdentifier = gramCargoLock.package metadata."${targetSection}".identifier; + in if stdenv.hostPlatform.isDarwin then ```
nix/build.nix Outdated
@ -0,0 +235,4 @@
runHook preInstall
pushd crates/gram
sed -i "s/package.metadata.bundle-dev/package.metadata.bundle/" Cargo.toml
First-time contributor
Copy link
- sed -i "s/package.metadata.bundle-dev/package.metadata.bundle/" Cargo.toml
+ sed -i "s/package.metadata.${targetSection}/package.metadata.bundle/" Cargo.toml
```diff - sed -i "s/package.metadata.bundle-dev/package.metadata.bundle/" Cargo.toml + sed -i "s/package.metadata.${targetSection}/package.metadata.bundle/" Cargo.toml ```
nix/build.nix Outdated
@ -0,0 +248,4 @@
# Physical location of the CLI must be inside the app bundle as this is used
# to determine which app to start
ln -s "$out/Applications/Gram.app/Contents/MacOS/cli" $out/bin/gram
First-time contributor
Copy link
- ln -s "$out/Applications/Gram.app/Contents/MacOS/cli" $out/bin/gram
+ ln -s "$out/Applications/${bundleName}.app/Contents/MacOS/cli" $out/bin/gram

This is why @theotheroracle's build fails at fixupPhase.

```diff - ln -s "$out/Applications/Gram.app/Contents/MacOS/cli" $out/bin/gram + ln -s "$out/Applications/${bundleName}.app/Contents/MacOS/cli" $out/bin/gram ``` This is why @theotheroracle's build fails at fixupPhase.
@ -0,0 +275,4 @@
export APP_NAME="Gram"
export APP_ARGS="%U"
mkdir -p "$out/share/applications"
${lib.getExe envsubst} < "crates/gram/resources/gram.desktop.in" > "$out/share/applications/app.liten.Gram.desktop"
First-time contributor
Copy link
- ${lib.getExe envsubst} < "crates/gram/resources/gram.desktop.in" > "$out/share/applications/app.liten.Gram.desktop"
- chmod +x "$out/share/applications/app.liten.Gram.desktop"
+ ${lib.getExe envsubst} < "crates/gram/resources/gram.desktop.in" > "$out/share/applications/${appIdentifier}.desktop"
+	 chmod +x "$out/share/applications/${appIdentifier}.desktop"

I don't use GUI in Linux so I'm not sure if these are needed.

```diff - ${lib.getExe envsubst} < "crates/gram/resources/gram.desktop.in" > "$out/share/applications/app.liten.Gram.desktop" - chmod +x "$out/share/applications/app.liten.Gram.desktop" + ${lib.getExe envsubst} < "crates/gram/resources/gram.desktop.in" > "$out/share/applications/${appIdentifier}.desktop" + chmod +x "$out/share/applications/${appIdentifier}.desktop" ``` I don't use GUI in Linux so I'm not sure if these are needed.
First-time contributor
Copy link

they aren't strictly necessary, but without these files Gram won't appear in system menus, i.e search, krunner and alike.

they aren't strictly necessary, but without these files Gram won't appear in system menus, i.e search, krunner and alike.
First-time contributor
Copy link

About extensions: I think we can also provide a mkGramExtension helper to package them, then install via a home-manager module that install symbolic links and updated index.json to user_data_dir/extensions.

About extensions: I think we can also provide a `mkGramExtension` helper to package them, then install via a home-manager module that install symbolic links and updated index.json to `user_data_dir`/extensions.
nix/build.nix Outdated
@ -0,0 +282,4 @@
runHook postInstall
'';
# TODO: why isn't this also done on macOS?
First-time contributor
Copy link

I'm the maintainer of zed-editor in nixpkgs, so I can add some context here.
The reason this was added was to unblock some language servers in the non-FHS variant of the package. Zed would just download Nodejs itself to execute these, but normal Nodejs binaries are incompatible on NixOS without FHS. They do work on macOS however (and in a Linux FHS environment).

If Gram needs Node.js for language servers, then this should also be provided on macOS, as I understand Gram does not download any binaries itself unlike Zed. Note though that you need a binary wrapper for macOS app bundles (as opposed to the script wrapper created here).

I'm the maintainer of zed-editor in nixpkgs, so I can add some context here. The reason this was added was to unblock some language servers in the non-FHS variant of the package. Zed would just download Nodejs itself to execute these, but normal Nodejs binaries are incompatible on NixOS without FHS. They do work on macOS however (and in a Linux FHS environment). If Gram needs Node.js for language servers, then this should also be provided on macOS, as I understand Gram does not download any binaries itself unlike Zed. Note though that you need a binary wrapper for macOS app bundles (as opposed to the script wrapper created here).
@ -0,0 +37,4 @@
zlib,
zstd,
withGLES ? false,
First-time contributor
Copy link

At least with the move to wgpu this isn't needed anymore, but I think Gram has been forked before Zed migrated from blade to wgpu

At least with the move to wgpu this isn't needed anymore, but I think Gram has been forked before Zed migrated from blade to wgpu
First-time contributor
Copy link

Ah the migration to wgpu has been backported, so withGLES as well as the distinction of libGL vs vulkan-loader isn't needed anymore

Ah the migration to wgpu has been backported, so `withGLES` as well as the distinction of libGL vs vulkan-loader isn't needed anymore
First-time contributor
Copy link

Just used this to build main (at 422df2edcf), had to nix flake update to update latest Rust from the oxalica overlay to 1.95.0, as now required by rust-toolchain.toml

This also brought cargo-edit to 0.8.4, which conflicts with the generate-licenses version check introduced by 642cd3ada9. Pinning to 0.8.2 isn't strictly necessary, it seems like 0.8.4 fixed the issue introduced in 0.8.3. Locally I set it back to CARGO_ABOUT_VERSION="0.8" but might be good to have a slightly more involved check to error/replace if 0.8.3 specifically is being used.

Cargo also wanted to run with --offline instead of --locked but not sure what that actually ended up modifying.

edit: pushed those changes to https://codeberg.org/f0x/gram/commits/branch/restore-nix

Just used this to build main (at https://codeberg.org/GramEditor/gram/commit/422df2edcf75fab471ebf9ba3609845ef14079cf), had to `nix flake update` to update `latest` Rust from the oxalica overlay to 1.95.0, as now required by rust-toolchain.toml This also brought cargo-edit to 0.8.4, which conflicts with the generate-licenses version check introduced by https://codeberg.org/GramEditor/gram/commit/642cd3ada90039c6245b90ac31cdfbe55d92ef95. Pinning to 0.8.2 isn't strictly necessary, it seems like [0.8.4 fixed the issue](https://github.com/EmbarkStudios/cargo-about/releases/tag/0.8.4) introduced in 0.8.3. Locally I set it back to `CARGO_ABOUT_VERSION="0.8"` but might be good to have a slightly more involved check to error/replace if 0.8.3 specifically is being used. Cargo also wanted to run with `--offline` instead of `--locked` but not sure what that actually ended up modifying. edit: pushed those changes to https://codeberg.org/f0x/gram/commits/branch/restore-nix
First-time contributor
Copy link

I will, again, argue that a nix package is unnecessary here. I would rather we add gram to nixpkgs, see PR.

Why? Because if gram decides to update libwebrtc, for example, you'd need to vendor in a build for it since it takes some time for nixpkgs to get an updated library version. This means that either you have to randomly add and then remove vendored code from nixpkgs from time to time or have your nix package not build sometimes. If you can't guarantee that the nix package builds than it's not much better than just overriding the nixpkgs package with the newer source

I'm all in for having a devshell, though

I will, again, argue that a nix package is unnecessary here. I would rather we add gram to nixpkgs, see [PR](https://github.com/NixOS/nixpkgs/pull/508631). Why? Because if gram decides to update libwebrtc, for example, you'd need to vendor in a build for it since it takes some time for nixpkgs to get an updated library version. This means that either you have to randomly add and then remove vendored code from nixpkgs from time to time or have your nix package not build sometimes. If you can't guarantee that the nix package builds than it's not much better than just overriding the nixpkgs package with the newer source I'm all in for having a devshell, though
First-time contributor
Copy link

@WeetHet wrote in #54 (comment):

I will, again, argue that a nix package is unnecessary here. I would rather we add gram to nixpkgs, see PR.

I don't think these are mutually exclusive, flake/nix in repo for development or bleeding edge, in nixpkgs for stable packaging. And if you're publishing this as a flake, you might as well expose the built packages, instead of just the dev shell environment?

Why? Because if gram decides to update libwebrtc, for example, you'd need to vendor in a build for it since it takes some time for nixpkgs to get an updated library version. This means that either you have to randomly add and then remove vendored code from nixpkgs from time to time or have your nix package not build sometimes. If you can't guarantee that the nix package builds than it's not much better than just overriding the nixpkgs package with the newer source

Because of this, project-specific version will likely use tooling that's closer to the language ecosystem, ie Crane which just reuses the Cargo-lock.toml without pinning hashes, whereas the nixpkgs package would use buildRustPackage?
Though take these comments with a grain of salt, since I don't have much experience with flakes specifically, nor Rust.

also libwebrtc specifically is a bad example, as all the livekit stuff in zed was removed from gram? but I get your point

@WeetHet wrote in https://codeberg.org/GramEditor/gram/pulls/54#issuecomment-14706963: > I will, again, argue that a nix package is unnecessary here. I would rather we add gram to nixpkgs, see [PR](https://github.com/NixOS/nixpkgs/pull/508631). I don't think these are mutually exclusive, flake/nix in repo for development or bleeding edge, in nixpkgs for stable packaging. And if you're publishing this as a flake, you might as well expose the built packages, instead of *just* the dev shell environment? > Why? Because if gram decides to update libwebrtc, for example, you'd need to vendor in a build for it since it takes some time for nixpkgs to get an updated library version. This means that either you have to randomly add and then remove vendored code from nixpkgs from time to time or have your nix package not build sometimes. If you can't guarantee that the nix package builds than it's not much better than just overriding the nixpkgs package with the newer source Because of this, project-specific version will likely use tooling that's closer to the language ecosystem, ie Crane which just reuses the Cargo-lock.toml without pinning hashes, whereas the nixpkgs package would use buildRustPackage? Though take these comments with a grain of salt, since I don't have much experience with flakes specifically, nor Rust. also libwebrtc specifically is a bad example, as all the livekit stuff in zed was removed from gram? but I get your point
Author
First-time contributor
Copy link

Alright, I'll keep it as is as it does technically work but I don't have the will to continue working on this. The derivation (again, this is pulled from zed) is insanely complex for no reason, and makes honestly weird choices. I also don't have enough time to work on making my own flake from the ground up. Wouldn't surprise me if this is all slop to begin with. There's also a much more sensible PR in nixpkgs that's only blocked by the staging cycle, so it's really not worth the effort imo.

If someone wants to work on this, I'll happily let them do it, but I have no desire to work on this letter soup anymore.

Alright, I'll keep it as is as it does technically work but I don't have the will to continue working on this. The derivation (again, this is pulled from zed) is insanely complex for no reason, and makes honestly weird choices. I also don't have enough time to work on making my own flake from the ground up. Wouldn't surprise me if this is all slop to begin with. There's also a much more sensible PR in nixpkgs that's only blocked by the staging cycle, so it's really not worth the effort imo. If someone wants to work on this, I'll happily let them do it, but I have no desire to work on this letter soup anymore.
Contributor
Copy link

Any updates?

@krig, is the PR can be closed?

Any updates? @krig, is the PR can be closed?
First-time contributor
Copy link

For the record:

  • If no one else wants to pick up, my partner @tasiaiso has already stated she won't continue work on it due to the flake's unnecessary complexity
  • Nixpkgs now has an upstream gram package

So, if you're just looking for Gram on nixOS, that's the way-to-go. I may ask tasia to close the PR herself unless someone else wants to step up and continue work on it

For the record: - If no one else wants to pick up, my partner @tasiaiso has already stated she won't continue work on it due to the flake's unnecessary complexity - Nixpkgs now [has an upstream gram package](https://search.nixos.org/packages?channel=26.05&query=gram#show=gram) So, if you're just looking for Gram on nixOS, that's the way-to-go. I may ask tasia to close the PR herself unless someone else wants to step up and continue work on it
Author
First-time contributor
Copy link

I'll close it now, since if you really want to make a flake, i recommend starting from scratch instead of using this code.

I'll close it now, since if you really want to make a flake, i recommend starting from scratch instead of using this code.
tasiaiso closed this pull request 2026年06月11日 15:23:11 +02:00
tasiaiso deleted branch restore-nix 2026年06月11日 15:23:25 +02:00
Owner
Copy link

Hi, thank you @tasiaiso for giving it a go :)

I have countless branches with failed attempts at fixing stuff lying around for this code base...

Hi, thank you @tasiaiso for giving it a go :) I have countless branches with failed attempts at fixing stuff lying around for this code base...

Pull request closed

This pull request cannot be reopened because the branch was deleted.
Sign in to join this conversation.
No reviewers
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
10 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
GramEditor/gram!54
Reference in a new issue
GramEditor/gram
No description provided.
Delete branch "tasiaiso:restore-nix"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?