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

Add a matrix of stdenvs to the flake #4996

Merged
merged 2 commits into from
Nov 30, 2021
Merged

Add a matrix of stdenvs to the flake #4996

merged 2 commits into from
Nov 30, 2021

Conversation

thufschmitt
Copy link
Member

@thufschmitt thufschmitt commented Jul 8, 2021

For a (currently hardcoded and limited) list of stdenvs,
make .#$nix-${stdenvName} correspond to a Nix built with the
corresponding stdenv.

For example, .#nix-${clang11Stdenv} is Nix built with clang11.

Likewise, devShell.x86_64-linux.clang11StdenvPackages is a development shell for Nix with clang11

Fix #4129

/cc @Pamplemousse

@thufschmitt thufschmitt force-pushed the build-with-clang branch 2 times, most recently from cd656ea to 1dcb30e Compare July 8, 2021 15:09
flake.nix Outdated

defaultPackage = forAllSystems (system: self.packages.${system}.nix);

devShell = forAllSystems (system:
devShell = forAllSystemsAndStdenvs (system: stdenv:
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we should make devShell an attrset of derivations/shells. It's assumed to be a single derivation, like defaultPackage. So e.g. nix flake check won't check these. Maybe to enforce uniformity we should disallow attributes deeper than the expected level in the CLI...

Instead we probably should add a devShells flake output (and maybe rename devShell to defaultDevShell). That would also be less verbose since it can be searched by default, so instead of

nix develop .#devShell.x86_64-linux.clang11StdenvPackages

you could do

nix develop .#clang11StdenvPackages

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh indeed, devShells is much nicer. I’ve changed that in 6378f36, and I’ll probably open another PR shortly to make nix develop and the various nix flake commands aware of it

Copy link
Member

Choose a reason for hiding this comment

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

I tried to use nix develop .#clang11StdenvPackages with this PR, and I get an error:

nix --experimental-features "nix-command flakes" develop .#clang11StdenvPackages
warning: Git tree '/src/nix' is dirty
error: flake 'git+file:///src/nix?shallow=1' does not provide attribute 'devShells.x86_64-linuxclang11StdenvPackages', 'packages.x86_64-linux.clang11StdenvPackages', 'legacyPackages.x86_64-linux.clang11StdenvPackages' or 'clang11StdenvPackages'

nix --version
nix (Nix) 2.4pre20210805_d64f967

Also, completion gives other attributes:

.#defaultPackage     .#checks            .#                                                                               
.#hydraJobs          .#devShells         .#devShell                                                                       
.#nix-armv7l-linux   .#nix-armv6l-linux  .#nix                                                                            
.#nix-clang11Stdenv  .#nix-clangStdenv   .#nix-gccStdenv                                                                  
.#nix-stdenv         .#nix-static        .#overlay

It should be nix develop .#nix-clang11Stdenv .

Copy link
Member

@Ericson2314 Ericson2314 left a comment

Choose a reason for hiding this comment

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

I do like this. I will build on this to duplicate the cross / static stuff.

(It was only ever the is only the way it use because there used to be an issue with nix being overridden in https://github.com/NixOS/nixpkgs/blob/master/pkgs/top-level/static.nix, but it no longer is overridden there.)

or if you have a flake-enabled nix:

```console
$ nix develop .#devShell.x86_64-linux.clang11StdenvPackages
Copy link
Member

Choose a reason for hiding this comment

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

This should be .#clang11StdenvPackages now right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Indeed, thanks. And actually the flake search path was broken (was missing a trailing .), so I fixed it.

I’ve also fixed the command above to use devShells and not devShell

Pamplemousse pushed a commit to Pamplemousse/nix that referenced this pull request Aug 6, 2021
Squash commit of all the commits of
NixOS#4996 .

Signed-off-by: Pamplemousse <xav.maso@gmail.com>
Pamplemousse pushed a commit to Pamplemousse/nix that referenced this pull request Aug 9, 2021
Squash commit of all the commits of
NixOS#4996 .

Signed-off-by: Pamplemousse <xav.maso@gmail.com>
Pamplemousse pushed a commit to Pamplemousse/nix that referenced this pull request Aug 9, 2021
Squash commit of all the commits of
NixOS#4996 .

Signed-off-by: Pamplemousse <xav.maso@gmail.com>
@Pamplemousse
Copy link
Member

Pamplemousse commented Aug 9, 2021

Also, it seems that the devShell 's shellHook (https://github.com/NixOS/nix/blob/master/flake.nix#L614-L619) is ran OK when doing nix develop, but not when doing nix develop .#nix-clang11Stdenv .

Example:

$ nix develop .#nix-clang11Stdenv
warning: Git tree '/home/pamplemousse/Workspace/tools/nix' is dirty
$ echo $MANPATH

$ nix develop                    
warning: Git tree '/home/pamplemousse/Workspace/tools/nix' is dirty
$ echo $MANPATH
/home/pamplemousse/Workspace/tools/nix/outputs/out/share/man:

Pamplemousse pushed a commit to Pamplemousse/nix that referenced this pull request Aug 9, 2021
Squash commit of all the commits of
NixOS#4996 .

Signed-off-by: Pamplemousse <xav.maso@gmail.com>
Pamplemousse pushed a commit to Pamplemousse/nix that referenced this pull request Aug 11, 2021
Squash commit of all the commits of
NixOS#4996 .

Signed-off-by: Pamplemousse <xav.maso@gmail.com>
@Pamplemousse
Copy link
Member

Pamplemousse commented Aug 12, 2021

Ah, nevermind!
I got confused because nix develop .#clang11StdenvPackages did not work (because of the missing .), so I started using .#nix-clang11Stdenv, which does NOT use devShells)...

Now, I use nix develop .#.clang11StdenvPackages (notice the extra dot), and the shellHook gets called properly.

Pamplemousse pushed a commit to Pamplemousse/nix that referenced this pull request Aug 19, 2021
Squash commit of all the commits of
NixOS#4996 .

Signed-off-by: Pamplemousse <xav.maso@gmail.com>
@Pamplemousse
Copy link
Member

This is blocking for google/oss-fuzz#6317, as they require good upstream integration (they won't merge as long as I use my fork of nix over there).

Is there anything blocking the merge?

Pamplemousse pushed a commit to Pamplemousse/nix that referenced this pull request Sep 2, 2021
Squash commit of all the commits of
NixOS#4996 .

Signed-off-by: Pamplemousse <xav.maso@gmail.com>
Pamplemousse pushed a commit to Pamplemousse/nix that referenced this pull request Sep 2, 2021
Squash commit of all the commits of
NixOS#4996 .

Signed-off-by: Pamplemousse <xav.maso@gmail.com>
@Ericson2314
Copy link
Member

Can we get this in before 2.4? I think it is decently important, and I would like to delete the duplicate mkDerivation for static and cross nix too.

@Ericson2314
Copy link
Member

We would make something like forAllSystemsAndCrossSystemsAndStdenvs. https://github.com/NixOS/nixpkgs/blob/master/pkgs/top-level/release-lib.nix has some stuff which might be useful to look at.

thufschmitt and others added 2 commits November 26, 2021 10:04
For a (currently hardcoded and limited) list of stdenvs,
make `.#$nix-${stdenvName}` correspond to a Nix built with the
corresponding stdenv.

For example, `.#nix-${clang11Stdenv}` is Nix built with clang11.

Likewise, `devShells.x86_64-linux.clang11StdenvPackages` is a development
shell for Nix with clang11, that can be used with

```shell
nix develop .#clang11StdenvPackages
```

Fix #4129

/cc @Pamplemousse
Signed-off-by: Pamplemousse <xav.maso@gmail.com>
@thufschmitt
Copy link
Member Author

Rebased on top of latest master.

@edolstra care to have a look?

@edolstra edolstra deleted the build-with-clang branch November 30, 2021 10:56
@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/tweag-nix-dev-update-23/16631/1

@9999years 9999years mentioned this pull request Jan 4, 2024
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.

Restore the ability to build with clang on linux
5 participants