numtide / treefmt-nix

treefmt nix configuration
https://numtide.github.io/treefmt/
MIT License
228 stars 68 forks source link

error: attribute 'getExe' missing when adding to buildInputs the wrapper #40

Closed teto closed 1 year ago

teto commented 1 year ago

Describe the bug

I triy adding a wrapped treefmt to my shell input but on nix develop I get:

error: attribute 'getExe' missing

       at /nix/store/4aw9k94v81xq3mnqd2lrvhka3m4sb7ns-source/module-options.nix:15:9:

           14|       else
           15|         lib.getExe res;
             |         ^
           16|   };

To Reproduce

add to flake

  packages.x86_64-linux = {
          # this apparently returns a ...build.wrapper 
          treefmt = (treefmt-nix.lib.mkWrapper pkgs {
              # Used to find the project root
              projectRootFile = ".git/config";
              programs.nixpkgs-fmt.enable = true;
              programs.shellcheck.enable = true;
            });
     }

     devShells.x86_64-linux.default = pkgs.mkShell {
        buildInputs = with pkgs; [
          gnumake
          shellcheck
          self.packages.${system}.treefmt # REFERENCING packages defined before

          # dependencies of https://github.com/covertsh/ubuntu-preseed-iso-generator
          xorriso # to write the iso
          syslinux
        ];

Expected behavior

wrapped treefmt in dev shell

System information

└───treefmt-nix: github:numtide/treefmt-nix/70e03145e26c2f3199f4320ecd9fd343f1129c60
    └───nixpkgs: github:nixos/nixpkgs/0591d6b57bfeb55dfeec99a671843337bc2c3323

Additional context

NB: I have a side question: I use git worktrees a lot and thus projectRootFile = ".git/config"; fails to detect my worktree (.git becomes a file that contains a path to the main repo). Would projectRootFile = ".git" work on the main repo (since .git is a folder then ?).

zimbatm commented 1 year ago

What version of nixpkgs does the pkgs instance refer to? lib.getExe is available in nixpkgs 22.05 and later only. https://github.com/NixOS/nixpkgs/commit/379b9c8be30ee14eb8703ec00c7ea5da5337c6b6


Right now we use test -f, so only files can be pointed to. You could split out the treefmt.nix config file and then refer to it like this: https://github.com/numtide/treefmt-nix/blob/main/treefmt.nix

teto commented 1 year ago

ha yeah that was it sry for the ticket, I tend to track unstable closely, this project was the exception. Thanks for the answers.

I can track flake.nix instead of .git too