I’m working on a Rust project I’ve set up to use shell.nix for CI. (Thanks to earlier help from y’all ) I am trying to add the latest dotnet sdk to my Rust shell.nix. Pick either example. I start with the short one
terse example
Building the following with nix-shell dotnet-shell.nix fails:
with import <nixpkgs> {};
mkShell {
name = "dotnet-env";
buildInputs = [
dotnet-sdk_3
];
}
It fails with:
error: undefined variable 'dotnet-sdk_3' at my-project/dotnet-shell.nix:5:5
(use '--show-trace' to show detailed location information)
Why is it failing? I see this locally on a macOS and on a GNU/Linux machine.
long winded example
I found the name from PRs like this one and pending documentation.
Trying to build the following with nix-shell fails:
let
moz_overlay = import (
builtins.fetchTarball
"https://github.com/mozilla/nixpkgs-mozilla/archive/master.tar.gz"
);
nixpkgs = import <nixpkgs> { overlays = [ moz_overlay ]; };
ruststable = (
nixpkgs.latest.rustChannels.stable.rust.override {
extensions = [ "rust-src" "rust-analysis" "rustfmt-preview" ];
}
);
in
with nixpkgs;
stdenv.mkDerivation {
name = "rust-stable";
buildInputs =
[ stdenv openssl pkgconfig which zip rustup ruststable dotnet-sdk_3 ];
}
The failure says:
$ nix-shell
error: undefined variable 'dotnet-sdk_3' at my-project/shell.nix:17:62
(use '--show-trace' to show detailed location information)
Is something wrong with my nix environment? I’m testing this on macOS but seeing the same failure in CI.
Am I specifying the package incorrectly? I suspect so but am confused about what type of arguments buildInputs expects.
My guess would be that your channel is not on nixos-unstable/nixpkgs-unstable, when you import <nixpkgs>
What does nix-channel --list (as root and as your current user) say?
CI only has nixpkgs https://nixos.org/channels/nixpkgs-unstable. I can run nix-info for CI too once I figure out the nix-shell -p nix-info incantation.
Also you may want to update from 18.03 to a more recent version. 18.03 doesn’t get updates anymore.
Ah, thanks. I have an older install on macOS. I’m thinking I’ll just pin the version of a channel that satisfies the constraints for Rust + dotnetsdk. I need to find the exact sha, but something like:
with import (
fetchTarball {
name = "nixos-unstable-2020-02-06";
url = https://github.com/NixOS/nixpkgs-channels/archive/nixos-unstable.tar.gz;
sha256 = "1z3kxlbz6bqx1dlagcazg04vhk67r8byihzf959c3m0laf2a1w7y";
}
) {};
mkShell {
name = "dotnet-env";
buildInputs = [
dotnet-sdk_3
];
}