Skip to content

Add a matrix of stdenvs to the flake - #4996

Merged
edolstra merged 2 commits into
masterfrom
build-with-clang
Nov 30, 2021
Merged

edolstra merged 2 commits into
masterfrom
build-with-clang

Conversation

@thufschmitt

@thufschmitt thufschmitt commented Jul 8, 2021 •

Copy link
Copy Markdown
Member

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
Comment thread flake.nix Outdated
defaultPackage = forAllSystems (system: self.packages.${system}.nix);

devShell = forAllSystems (system:
devShell = forAllSystemsAndStdenvs (system: stdenv:

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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 .

@Ericson2314 Ericson2314 left a comment

Copy link
Copy Markdown
Member

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.)

Comment thread doc/manual/src/contributing/hacking.md Outdated
or if you have a flake-enabled nix:

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

Copy link
Copy Markdown
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
Copy Markdown
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

Pamplemousse commented Aug 9, 2021 •

Copy link
Copy Markdown
Member

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

Pamplemousse commented Aug 12, 2021 •

Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
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?

@Ericson2314

Copy link
Copy Markdown
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
Copy Markdown
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
@thufschmitt

Copy link
Copy Markdown
Member Author

Rebased on top of latest master.

@edolstra care to have a look?

@edolstra
edolstra merged commit b96164f into master Nov 30, 2021
@edolstra
edolstra deleted the build-with-clang branch November 30, 2021 10:56
@nixos-discourse

Copy link
Copy Markdown

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