kamadorueda / alejandra

The Uncompromising Nix Code Formatter
https://kamadorueda.github.io/alejandra/
The Unlicense
859 stars 41 forks source link

Add macOS/Darwin binaries #402

Open nikolay opened 1 year ago

arichtman-srt commented 10 months ago

Not entirely sure what's happened but since updating my pre-commit hooks it's failing

Seems like the derivation doesn't exist anymore for aarch64-darwin, but that's not the case since I can run it fine from nixpkgs.

alejandra (Nix)..........................................................Failed
- hook id: alejandra
- exit code: 1

+ command -v nix-build
/run/current-system/sw/bin/nix-build
+ '!command' -v nix-instantiate
/Users/arichtman/.cache/pre-commit/repocvhp2286/.pre-commit-entry.sh: line 10: !command: command not found
+ echo INFO: computing current system
INFO: computing current system
++ nix-instantiate --eval --expr builtins.currentSystem
+ system='"aarch64-darwin"'
+ echo INFO: building Alejandra
INFO: building Alejandra
+ nix-build --attr '"aarch64-darwin"' --out-link result-alejandra https://github.com/kamadorueda/alejandra/tarball/3.0.0
error: attribute 'aarch64-darwin' in selection path '"aarch64-darwin"' not found
ahgraber commented 7 months ago

I'm running into this issue as ; 1.3.0 worked for me; neither 2.0.0 nor 3.0.0 do.

Edit: using alejandra-system worked for me; I guess it uses the system alejandra instead of creating a separate version for pre-commit?

  - repo: https://github.com/kamadorueda/alejandra
    rev: 3.0.0
    hooks:
      - id: alejandra-system
        files: \.nix$
cooperpellaton commented 6 months ago

I use a (very recent) commit that still has the binaries present:

repos:
  - repo: https://github.com/kamadorueda/alejandra
    rev: e53c2c6
    hooks:
      # Requires Nix to be previously installed in the system
      - id: alejandra-nix
kamadorueda commented 3 weeks ago

I'm curious to know if the issue is that we don't provide pre-compiled MacOS/Darwin binaries that people may want to download, chmod +x and execute, or if the issue is asking about the pre-commit failures related to the missing system attribute

For the options above:

Please let me know if my understanding of the issue is accurate

cooperpellaton commented 3 weeks ago

Version 3.1.0 seems to have fixed the problem. Below works:

diff --git i/.pre-commit-config.yaml w/.pre-commit-config.yaml
index 182e228..5c0adf0 100644
--- i/.pre-commit-config.yaml
+++ w/.pre-commit-config.yaml
@@ -1,6 +1,6 @@
 repos:
   - repo: https://github.com/kamadorueda/alejandra
-    rev: d7552fef2ccf1bbf0d36b27f6fddb19073f205b7
+    rev: 3.1.0
     hooks:
       # Requires Nix to be previously installed in the system
       - id: alejandra-nix

Re: building binaries: I'm happy to lend compute to do this. If you share a script or something similar I'll run it and share the results.