Shell.nix with llvmPackages_13.stdenv.mkDerivation -> flake

I have an old shell.nix which uses pkgs.llvmPackages_13.stdenv.mkDerivation to ensure everything is compiled with clang.

How would I go about transforming this into a flake? Can I simply use

devShell = pkgs.llvmPackages_13.stdenv.mkDerivation { ... }

instead of

devShell = pkgs.mkShell { ... }

or are there some significant incompatibilities between the two?

IIRC pkgs.mkShell.override { stdenv = pkgs.clang13Stdenv; } { … }.

AFAICT so far

devShell = pkgs.llvmPackages_13.stdenv.mkDerivation { ... }


devShell = pkgs.mkShell.override { stdenv = pkgs.clang13Stdenv; } { ... }

behave identically.

Not fully. mkShell doesn’t have phases to build something (even though today it actually can be nix build).

Though if this was not your question, then please elaborate. Both options work in flakes or in channel style nix.

But in the context of devShell = ... in a flake, there is no discernable difference?

You mean that mkShell can be bound to package.<system>.<whatever> in a flake?

The difference is that you can’t nix build a mkShelland expect a meaningfull output. While a mkDerivation should create a meaning full output.

As both create derivations, you can use either in packages or devShells.

1 Like