Im quite new to nix
and have been playing around a bit with shell.nix
files to create some simple development environments. I’m having some trouble pinning the correct version of gcc
. Consider the following code:
{ nixpkgs ? import <nixpkgs> {} } :
let
clang_14 = import (builtins.fetchGit {
name = "clang_14";
url = "https://github.com/NixOS/nixpkgs/";
ref = "refs/heads/nixos-23.11";
rev = "eb090f7b923b1226e8beb954ce7c8da99030f4a8";
}) {};
gcc_11 = import (builtins.fetchGit {
name = "gcc_11";
url = "https://github.com/NixOS/nixpkgs/";
ref = "refs/heads/nixos-23.11";
rev = "6c9faad8466f17216c0cb6f0bd645f3985046090";
}) {};
in
nixpkgs.mkShell {
name = "myShell";
buildInputs = [
gcc_11.gcc-unwrapped # 11.3.0
clang_14.llvmPackages_14.clang-unwrapped # 14.0.6
clang_14.cmake # 3.27.7
clang_14.ninja # 1.11.1
gcc_11.python310Packages.python # 3.10.9
];
}
In principle the script works, all packages have the expected version (indicated in the comment behind the individual packages), but for whatever reason, gcc
has the wrong version. The version comes out to 13.0.2
.
The hash for gcc
comes from here. Even more confusing, if I run
nix-shell -p gcc-unwrapped -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/6c9faad8466f17216c0cb6f0bd645f3985046090.tar.gz
I end up in a shell with gcc-11.3.0
, as indented. I use nix (Nix) 2.21.1
on Linux (x86_64
).
Can somebody explain this?