ziglings/exercises
62
1.5k
Fork
You've already forked exercises
478

feat(nix): add nix flake #346

Closed
doprz wants to merge 2 commits from doprz/exercises:main into main
pull from: doprz/exercises:main
merge into: ziglings:main
ziglings:main
Contributor
Copy link

This should help nix users start working on ziglings without the complexity of making sure they are on a supported version of zig and zls.

This should help nix users start working on `ziglings` without the complexity of making sure they are on a supported version of `zig` and `zls`.
feat(nix): add nix flake
Some checks are pending
ci/woodpecker/pr/eowyn Pipeline is pending approval
ci/woodpecker/pull_request_metadata/eowyn Pipeline is pending approval
effbe115a5
feat(nix): add shell.nix
Some checks are pending
ci/woodpecker/pr/eowyn Pipeline is pending approval
ci/woodpecker/pull_request_closed/eowyn Pipeline is pending approval
f00ae44ec7

please look at: #194
and this: #342

please look at: https://codeberg.org/ziglings/exercises/pulls/194 and this: https://codeberg.org/ziglings/exercises/issues/342
chrboesch closed this pull request 2026年01月06日 14:36:28 +01:00
Author
Contributor
Copy link

Thank you for linking the other PRs for reference!

I do agree with your statement:

Thank you for the suggestion! However, we typically avoid including configuration details in our exercises to keep them focused and straightforward.

Yes, although it is trivial to just run nix shell 'github:mitchellh/zig-overlay#master', this PR also ensures that zls is available in the dev shell and also makes sure that it's zig input matches the zig version used/defined via mitchellh/zig-overlay either via an overlay or overrideAttrs.

e.g.

overrideAttrs

zls = inputs.zls-overlay.packages.${system}.zls.overrideAttrs (finalAttrs: previousAttrs: {
 nativeBuildInputs = [zig];
});

https://github.com/zigtools/zls/blob/master/flake.nix

#...
zls = pkgs.stdenvNoCC.mkDerivation {
 name = "zls";
 version = "master";
 meta.mainProgram = "zls";
 src = fs.toSource {
 root = ./.;
 fileset = fs.intersection (fs.fromSource (pkgs.lib.sources.cleanSource ./.)) (
 fs.unions [
 ./src
 ./tests
 ./build.zig
 ./build.zig.zon
 ./deps.nix
 ]
 );
 };
 nativeBuildInputs = [zig];
Thank you for linking the other PRs for reference! I do agree with your statement: > Thank you for the suggestion! However, we typically avoid including configuration details in our exercises to keep them focused and straightforward. Yes, although it is trivial to just run `nix shell 'github:mitchellh/zig-overlay#master'`, this PR also ensures that `zls` is available in the dev shell and also makes sure that it's zig input matches the zig version used/defined via `mitchellh/zig-overlay` either via an overlay or `overrideAttrs`. e.g. `overrideAttrs` ```nix zls = inputs.zls-overlay.packages.${system}.zls.overrideAttrs (finalAttrs: previousAttrs: { nativeBuildInputs = [zig]; }); ``` https://github.com/zigtools/zls/blob/master/flake.nix ```nix #... zls = pkgs.stdenvNoCC.mkDerivation { name = "zls"; version = "master"; meta.mainProgram = "zls"; src = fs.toSource { root = ./.; fileset = fs.intersection (fs.fromSource (pkgs.lib.sources.cleanSource ./.)) ( fs.unions [ ./src ./tests ./build.zig ./build.zig.zon ./deps.nix ] ); }; nativeBuildInputs = [zig]; ```
Some checks are pending
ci/woodpecker/pr/eowyn Pipeline is pending approval
ci/woodpecker/pull_request_closed/eowyn Pipeline is pending approval

Pull request closed

Please reopen this pull request to perform a merge.
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
2 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
ziglings/exercises!346
Reference in a new issue
ziglings/exercises
No description provided.
Delete branch "doprz/exercises:main"

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?