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

explicitly define project root in treefmt #103

Merged
merged 7 commits into from
Feb 20, 2024

Conversation

conscious-puppet
Copy link
Contributor

@conscious-puppet conscious-puppet commented Feb 19, 2024

specifying projectRoot in treefmt fixes #45

treefmt-check> treefmt 0.6.1
treefmt-check> [INFO ] #nixpkgs-fmt: 26 files processed in 31.84ms
treefmt-check> 0 files changed in 37ms (found 42, matched 26, cache misses 26)
treefmt-check> On branch main
treefmt-check> nothing to commit, working tree clean

@shivaraj-bh
Copy link
Member

@srid running nix run nixpkgs#nixci seems to work with this PR, i.e treefmt checks all nix files, but nix run github:srid/nixci doesn’t, any idea what might’ve changed?

@shivaraj-bh
Copy link
Member

with nixpkgs#nixci:

❯ nix run nixpkgs#nixci
🍏 .
🐚 nix --extra-experimental-features 'nix-command flakes' eval '.#nixci.default' --json️
🍎 default.dev
🐚 nix --extra-experimental-features 'nix-command flakes' flake lock --no-update-lock-file '.?dir=./dev'️
warning: Git tree '/home/shivaraj/juspay/services-flake' is dirty
🐚 nix --extra-experimental-features 'nix-command flakes' build '/nix/store/p8vfkmfh43yy8lmz1r65dr9yq3ql7cd7-source#default' -L --no-link --print-out-paths --override-input flake '.?dir=./dev' --refresh -j auto️
warning: Git tree '/home/shivaraj/juspay/services-flake' is dirty
/nix/store/r2g40v56xwfbfqlfdp81p4i6plxnfpdv-nix-shell
/nix/store/3lz7sywmw7rcc7vnc2v7cfx3jfflvsjf-treefmt-check
...

with github:srid/nixci:

❯ nix run github:srid/nixci
🍏 .
🐚 nix --extra-experimental-features 'nix-command flakes' eval '.#nixci.default' --json️
🐚 nix --extra-experimental-features 'nix-command flakes' show-config --json️
🍎 default.dev
🐚 nix --extra-experimental-features 'nix-command flakes' flake lock --no-update-lock-file path:././dev️
🐚 nix --extra-experimental-features 'nix-command flakes' build '/nix/store/p8vfkmfh43yy8lmz1r65dr9yq3ql7cd7-source#default' -L --no-link --print-out-paths --override-input flake path:././dev --refresh -j auto️
error (ignored): error: reached end of FramedSource
error:
       … while calling the 'derivationStrict' builtin

         at /builtin/derivation.nix:9:12: (source not available)

       … while evaluating derivation 'devour-output'
         whose name attribute is located at /nix/store/qjqzr7905xxv3rv70z7mkpp06lalnzzb-source/pkgs/stdenv/generic/make-derivation.nix:300:7

       … while evaluating attribute 'text' of derivation 'devour-output'

         at /nix/store/qjqzr7905xxv3rv70z7mkpp06lalnzzb-source/pkgs/build-support/trivial-builders/default.nix:148:16:

          147|     runCommand name
          148|       { inherit text executable checkPhase allowSubstitutes preferLocalBuild;
             |                ^
          149|         passAsFile = [ "text" ];

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: opening file '/nix/store/00p454skn3x07s3k6zwrixmyzhn1hyqb-Cabal-3.10.2.1-doc.lock': Permission denied
Error: devour-flake failed to run (exited: 1)

@shivaraj-bh
Copy link
Member

I think it is do with this:

--override-input flake '.?dir=./dev'

vs

--override-input flake path:././dev

@srid
Copy link
Member

srid commented Feb 19, 2024

I saw the same error before, but didn't think it was due to the latest nixci (not sure how it is related even):

https://nixos.zulipchat.com/#narrow/stream/413948-nixos/topic/Self-hosted.20GitHub.20runners/near/421222981

@srid
Copy link
Member

srid commented Feb 19, 2024

We switched from dir to path in juspay/omnix#115

dev/flake.nix Outdated
@@ -14,7 +14,8 @@
];
perSystem = { pkgs, lib, config, ... }: {
treefmt = {
projectRootFile = "flake.nix";
projectRoot = ../.;
Copy link
Member

Choose a reason for hiding this comment

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

Is this legal in pure evaluation? AFAIU, a flake (or sub-flake) cannot refer to contents outside its containing directory.

Try running nix with sandbox enabled; I think it is disabled by default on macOS.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i ran the command with sandbox on ubuntu. treefmt is able to scan 26 files.

Screenshot 2024-02-19 at 10 02 27 PM

@shivaraj-bh
Copy link
Member

Looks good! Thanks for the contrib

dev/flake.nix Outdated Show resolved Hide resolved
@shivaraj-bh shivaraj-bh merged commit dafaeb0 into juspay:main Feb 20, 2024
3 checks passed
@conscious-puppet conscious-puppet deleted the fix/ci-treefmt branch February 20, 2024 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Formatting checks in CI is limited to ./dev
3 participants