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

Expose as a flake #57

Closed
Mic92 opened this issue Aug 7, 2020 · 15 comments
Closed

Expose as a flake #57

Mic92 opened this issue Aug 7, 2020 · 15 comments

Comments

@Mic92
Copy link

Mic92 commented Aug 7, 2020

Currently its not possible to use this with nix develop because it internally re-imports nixpkgs:

error: --- EvalError --------------------------------------------------------------------------------- nix
at: (90:39) in file: /nix/store/ma3b77vjls3qrznwh66ix5ivvybx6003-source/pkgs/top-level/impure.nix

    89|                 else (if args ? localSystem then {}
    90|                       else { system = builtins.currentSystem; }) // localSystem;
      |                                       ^
    91| })

attribute 'currentSystem' missing
(use '--show-trace' to show detailed location information)
direnv: export +IN_NIX_SHELL ~PATH
@roberth
Copy link
Contributor

roberth commented Aug 7, 2020

It works fine if you import the modules directly. Not saying you should do that, but that means it's not far off.

@Mic92
Copy link
Author

Mic92 commented Aug 7, 2020

I don't think the modules can be imported directly. It's too tightly coupled too niv and inject overlays, which cannot be easily overwritten.

@roberth
Copy link
Contributor

roberth commented Aug 7, 2020

It's not that bad, but that's quite an experimental project anyway.

Let's focus on the problem here, which is probably the initialization of tools.

Myhlamaeus added a commit to Myhlamaeus/pre-commit-hooks.nix that referenced this issue Sep 24, 2020
Exposes the project as a nix flake and replaces niv with nix flake inputs.

BREAKING CHANGES: The project.nix module is now exposed as an output
`projectModules.pre-commit-hooks` on the flake instead of a separate file.

Fixes cachix#57
@lovesegfault
Copy link
Contributor

@Myhlamaeus any chance you can rebase your PR?

@domenkozar
Copy link
Member

I've closed that PR as it was out of date and not the approach I'd like to see merged - flake.nix shouldn't duplicate code from non-flake bits.

I'm going to start working towards flake support, starting with cleanups like #100

@domenkozar
Copy link
Member

Bumping packages with more cleanup at #102

@domenkozar
Copy link
Member

domenkozar commented Apr 26, 2021

Barebone flake support at #103, but it's blocked on two issues.

I'd appreciate if a macOS user can help with #102

@domenkozar
Copy link
Member

domenkozar commented Apr 27, 2021

#103 is ready to be merged, I'd like someone that uses flakes to give it a try!

Exposing lib.run for all the heavy lifting!

@dhess
Copy link

dhess commented Apr 27, 2021

I'm trying it out here:

https://github.com/hackworthltd/haskell-template/tree/pre-commit-hooks-flake

I'm probably being dense, but it's not clear to me out to use lib.run. This is what I've got, based on how we used to use it pre-flake:

https://github.com/hackworthltd/haskell-template/blob/4b66ab93e4ef4961e7ffff3298bfe8b6422fcf8e/flake.nix#L76

but I'm getting this error:

 nix-build -A hydraJobs.source-code-checks                                                                      /Volumes/src/dhess/haskell-template
error: attempt to call something which is not a function but a set

       at /nix/store/lrj3qxbgdpmdnlc2a9fh732vajdmqynb-source/flake.nix:76:9:

           75|         in
           76|         pre-commit-hooks-nix.lib.${system}.run {
             |         ^
           77|           src = ./.;
(use '--show-trace' to show detailed location information)

@domenkozar
Copy link
Member

domenkozar commented Apr 27, 2021

Oh, skip system on the lib output: pre-commit-hooks-nix.lib.run {

@dhess
Copy link

dhess commented Apr 27, 2021

I tried that as well, but no:

 nix build .#hydraJobs.source-code-checks                                                                       /Volumes/src/dhess/haskell-template
warning: Git tree '/Volumes/src/dhess/haskell-template' is dirty
error: attribute 'run' missing

       at /nix/store/n1myzg0ssh4v6vc3xh475cv5hd93qcjc-source/flake.nix:76:9:

           75|         in
           76|         pre-commit-hooks-nix.lib.run {
             |         ^
           77|           src = ./.;
(use '--show-trace' to show detailed location information)

@domenkozar
Copy link
Member

domenkozar commented Apr 27, 2021

run wasn't exported. I've added a test for that.

You can try with pre-commit-hooks-nix.lib.${system}.run, I've made the system explicit.

@dhess
Copy link

dhess commented Apr 28, 2021

Yes, this now works, thanks so much!

@domenkozar
Copy link
Member

Merged, thanks!

@domenkozar
Copy link
Member

Docs: https://github.com/cachix/pre-commit-hooks.nix#nix-flakes-support

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 a pull request may close this issue.

5 participants