Skip to content

Add nix flakes support #67

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

Closed
wants to merge 4 commits into from
Closed

Conversation

Myhlamaeus
Copy link

This adds a flake.nix which exposes the project's outputs (mainly packages.{system}.run) and defines the dependencies.

niv was removed as nix flakes obviate it.

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 #57

It is generally recommended to not have a leading dollar in shell snippets as it
makes copy-and-paste more annoying.
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
@Myhlamaeus
Copy link
Author

I'll soon create a corresponding PR on hercules-ci/project.nix as this PR breaks compatibility with it.

@domenkozar
Copy link
Member

This needs a rebase on top of master that landed 20.09 and other things :)

@Stupremee
Copy link

Stupremee commented Nov 11, 2020

Is this planned to be merged any time soon? (Otherwise, I can open another PR)

@roberth
Copy link
Contributor

roberth commented Nov 11, 2020

We should only offer a cleaned-up interface in the flake. Otherwise people will have to migrate twice - once for flakes and then again for the revised interface. This means implementing some of the ideas in #55 and #61.
This also means we can get rid of some of the inputs and take them from Nixpkgs.
If you enjoy removing unnecessary wiring, I'd be happy to review. Otherwise I can do it, but probably no earlier than a month from now.

@Stupremee
Copy link

I don't think I have enough experience with Nix to do it.

@terlar
Copy link
Contributor

terlar commented Mar 2, 2021

Did this result in anything? I see nothing linked here, so I guess not, but just checking as this would be a nice feature to have.

@dhess
Copy link

dhess commented Apr 26, 2021

Even just a simple fix for the currentSystem error when evaluating this project in a flake would be really helpful:

error: attribute 'currentSystem' missing

       at /nix/store/smvan4qznfgg79w1s6wjw1zdbszkynav-source/pkgs/top-level/impure.nix:90:39:

           89|                 else (if args ? localSystem then {}
           90|                       else { system = builtins.currentSystem; }) // localSystem;
             |                                       ^
           91| })
(use '--show-trace' to show detailed location information)

@domenkozar
Copy link
Member

Even just a simple fix for the currentSystem error when evaluating this project in a flake would be really helpful:

error: attribute 'currentSystem' missing

       at /nix/store/smvan4qznfgg79w1s6wjw1zdbszkynav-source/pkgs/top-level/impure.nix:90:39:

           89|                 else (if args ? localSystem then {}
           90|                       else { system = builtins.currentSystem; }) // localSystem;
             |                                       ^
           91| })
(use '--show-trace' to show detailed location information)

I'm happy to fix this - what's the easiest way to reproduce it?

@dhess
Copy link

dhess commented Apr 26, 2021

@domenkozar Thanks for the offer! This public project has a source-code-checks attribute which builds fine using nix-build (via flake-compat) but not using nix build (with flakes support enabled):

https://github.com/hackworthltd/haskell-template/blob/a51b92252120a7fe82bc4d9f70842aae3526cbe8/flake.nix#L82

Beware that it uses haskell.nix so you'll probably want to be using the upstream haskell.nix binary cache. Alternatively, you could just take a look at what I'm doing there and add it to a simple test flake. It's pretty straightforward, except for the part where we override the tools to use the haskell.nix versions, which is irrelevant to this particular issue.

BTW, I thought this was going to be a very easy fix as it looks like you just need to set localSystem.system to system in nixpkgss args, but that still didn't work. If I recall, it has something to do with niv.

@domenkozar
Copy link
Member

Sounds like the best way is to add flake support into the project itself.

I'm going to close this and track progress at #57

@domenkozar domenkozar closed this Apr 26, 2021
@domenkozar
Copy link
Member

domenkozar commented Apr 28, 2021

Thanks @Myhlamaeus, for your hard work.

I've incorporated some of your changes and flake support is live now: 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 this pull request may close these issues.

Expose as a flake
6 participants