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

Flakes support #103

Merged
merged 1 commit into from Apr 28, 2021
Merged

Flakes support #103

merged 1 commit into from Apr 28, 2021

Conversation

domenkozar
Copy link
Member

@domenkozar domenkozar commented Apr 26, 2021

Blocked on #102
Blocked on NixOS/nixpkgs#120752

@domenkozar domenkozar mentioned this pull request Apr 26, 2021
@domenkozar domenkozar force-pushed the flakes branch 6 times, most recently from 0da0360 to 2eb2917 Compare April 27, 2021 14:00
@domenkozar domenkozar marked this pull request as ready for review April 27, 2021 14:03
with:
name: pre-commit-hooks
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
- run: nix flake check
Copy link

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks!

@evalexpr
Copy link

evalexpr commented Apr 28, 2021

@domenkozar is there a documentation update needed here? I have the following snippet:

nix-pre-commit-hooks = import sources."pre-commit-hooks.nix";
pre-commit-checks = nix-pre-commit-hooks.run {
    src = ./.;
    hooks = {
      nixpkgs-fmt = {
        enable = true;
        pass_filenames = true;
      };
      nix-linter = {
        enable = true;
        entry = pkgs.lib.mkForce "${pkgs.nix-linter}/bin/nix-linter";
        pass_filenames = true;
        excludes = [ "nix/sources.nix" ];
      };
    };
  };

Using niv to pin pre-commit-hooks.nix, my sources look like:

"pre-commit-hooks.nix": {
        "branch": "master",
        "description": "Seamless integration of https://pre-commit.com git hooks with Nix.",
        "homepage": "",
        "owner": "cachix",
        "repo": "pre-commit-hooks.nix",
        "rev": "c33f92d9d69a73c77061e4fd47234662625cbdf9",
        "sha256": "0hr64z6ypc74fqhqnqpn238bgi2nxzzx8ypc405waapkzlaxx19l",
        "type": "tarball",
        "url": "https://github.com/cachix/pre-commit-hooks.nix/archive/c33f92d9d69a73c77061e4fd47234662625cbdf9.tar.gz",
        "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
    }

I've been waiting for flakes support so I've been eager to update, just updated and now I get the error:

error: attribute 'run' missing

       at /home/wilkins/nixcfg/shell.nix:5:23:

            5|   pre-commit-checks = nix-pre-commit-hooks.run {

I've checked what the pre-commit-hooks import looks like and I see:

{ ansible-lint = <CODE>; brittany = <CODE>; cabal-fmt = <CODE>; cargo = <CODE>; clippy = <CODE>; elm-format = <CODE>; fourmolu = <CODE>; hindent = <CODE>; hlint = <CODE>; hpack = <CODE>; hpack-dir = <CODE>; html-tidy = <CODE>; hunspell = <CODE>; nix-linter = <CODE>; nixfmt = <CODE>; nixpkgs-fmt = <CODE>; ormolu = <CODE>; pre-commit = <CODE>; pre-commit-check = <CODE>; prettier = <CODE>; purty = <CODE>; rustfmt = <CODE>; shellcheck = <CODE>; stylish-haskell = <CODE>; terraform-fmt = <CODE>; yamllint = <CODE>; }

I'm curious if I'm doing something wrong now? or run has been removed.

@domenkozar
Copy link
Member Author

You want to use nix-pre-commit-hooks.lib.run {

@evalexpr
Copy link

I'm not seeing lib in the trace above at the bottom of my last message, and also get:

error: attribute 'lib' missing

when I try this, shall I create an issue rather than continuing on this PR? I think we should update the README to mention whatever solution we find as it still mentions nix-pre-commit-hooks.run - I can do this after we find a solution.

@domenkozar
Copy link
Member Author

I'll provide an example in README :)

@domenkozar
Copy link
Member Author

@evalexpr
Copy link

@domenkozar got it working, thanks! I realize my error was that I wasn't importing it as a flake... 🤦 sorry!

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.

None yet

3 participants