Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(nix): Introduce flake.formatter for nix fmt #5687

Merged
merged 2 commits into from
Mar 1, 2024

Conversation

ditsuke
Copy link
Contributor

@ditsuke ditsuke commented Feb 23, 2024

What and why

Introduces a formatter in the repo's Nix flake. This enables the usage of nix fmt to format the Nix files in the repo reproducibly.

flake.nix Outdated
@@ -131,6 +135,11 @@
...
}:
{
# For standardised reproducible formatting with `nix fmt`
# HELP: why does the per system formatter not work?
# formatter = inputs.nixfmt.packages.${system}.nixfmt;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't work, and I couldn't quite figure out why. From the error message it appears to try building the aarch_64 darwin build in x86_64-linux.

       error: a 'aarch64-darwin' with features {} is required to build '/nix/store/apv47ywrf96wyiy5cd9l9grz0kmg1y1y-cabal2nix-nixfmt.drv', but I am a 'x86_64-linux' with features {benchmark,
 big-parallel, kvm, nixos-test, uid-range}

Copy link
Collaborator

@SomeoneSerge SomeoneSerge Feb 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I suspect we have maybe flake-parts partially evaluate other systems' attributes? I also just noticed that the nixfmt flake uses IFD (which would also explain why your system might try to build something darwin)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see. Do you see a solution that does not require changes in nixfmt's flake? Else maybe we can use nixfmt from nixpkgs, plus point being we get the builds cached for free.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(sorry, can't suggest anything rn, but can review your proposals; I'm more available next week)

@ditsuke
Copy link
Contributor Author

ditsuke commented Feb 23, 2024

/cc @SomeoneSerge

@SomeoneSerge SomeoneSerge added the nix Issues specific to consuming flake.nix, or generally concerned with ❄ Nix-based llama.cpp deployment label Feb 23, 2024
@leana8959
Copy link

What about alejandra as the nix formatter? It opts for "tall" layouts, which helps git diff.

@ditsuke
Copy link
Contributor Author

ditsuke commented Feb 29, 2024

What about alejandra as the nix formatter? It opts for "tall" layouts, which helps git diff.

I quite like alejandra's style, personally. This repo has been already using nixfmt's rfc101 branch, but if the consensus is with a switch to alejandra we could do that here.

@SomeoneSerge
Copy link
Collaborator

What about alejandra as the nix formatter? It opts for "tall" layouts, which helps git diff.

I think there are many similarities between alejandra and rfc101, and both aim to optimize git diffs. Personally, I dislike them both, and we only had chosen the experimental nixfmt in @philiptaron's rewrite because it has a chance of wider adoption (nixpkgs)

Copy link
Collaborator

@philiptaron philiptaron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use the RFC 166 by pulling it from nixpkgs, rather than the flake. See this discourse post from @piegamesde.

The name of the package is nixfmt-rfc-style.

As this PR notes, the flake.nix in piegamesde/nixfmt/rfc101-style has multiple issues. Let's side-step those by relying on nixpkgs.

@ditsuke
Copy link
Contributor Author

ditsuke commented Mar 1, 2024

You can use the RFC 166 by pulling it from nixpkgs, rather than the flake. See this discourse post from @piegamesde.

The name of the package is nixfmt-rfc-style.

As this PR notes, the flake.nix in piegamesde/nixfmt/rfc101-style has multiple issues. Let's side-step those by relying on nixpkgs.

Thank you, pulling in from nixpkgs is so much better.

Copy link
Collaborator

@philiptaron philiptaron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I intend to merge when CI passes.

@philiptaron philiptaron merged commit cb5e8f7 into ggerganov:master Mar 1, 2024
23 checks passed
hazelnutcloud pushed a commit to hazelnutcloud/llama.cpp that referenced this pull request Mar 10, 2024
* build(nix): Introduce flake.formatter for `nix fmt`
* chore: Switch to pkgs.nixfmt-rfc-style
jordankanter pushed a commit to jordankanter/llama.cpp that referenced this pull request Mar 13, 2024
* build(nix): Introduce flake.formatter for `nix fmt`
* chore: Switch to pkgs.nixfmt-rfc-style
hodlen pushed a commit to hodlen/llama.cpp that referenced this pull request Apr 1, 2024
* build(nix): Introduce flake.formatter for `nix fmt`
* chore: Switch to pkgs.nixfmt-rfc-style
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
nix Issues specific to consuming flake.nix, or generally concerned with ❄ Nix-based llama.cpp deployment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants