I am working on a simple nix environment where I want to run a script which generates shell script output that should (according to a complex web of rules) initialize a bunch of env vars in my env.
However, I am taken aback by a cryptic error message.
- What am I doing wrong?
- (In general: How do I define a derivation that I then can run as part of my shell initialization?)
Code
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
packages = with pkgs; [
pkgs.stdenv.mkDerivation {
deps = [];
buildInputs = [];
src = "hi";
name = "hello";
stdenv = "./";
}
];
shellHook = "echo " + "hi;";
}
Result
$ nix-shell "./dev-env.nix"
error:
… while calling the 'derivationStrict' builtin
at /builtin/derivation.nix:9:12: (source not available)
… while evaluating derivation 'nix-shell'
whose name attribute is located at /nix/store/ka3vmkgvsn6cj8dywj7n1xl3bm54gxm7-source/pkgs/stdenv/generic/make-derivation.nix:352:7
… while evaluating attribute 'nativeBuildInputs' of derivation 'nix-shell'
at /nix/store/ka3vmkgvsn6cj8dywj7n1xl3bm54gxm7-source/pkgs/stdenv/generic/make-derivation.nix:396:7:
395| depsBuildBuild = elemAt (elemAt dependencies 0) 0;
396| nativeBuildInputs = elemAt (elemAt dependencies 0) 1;
| ^
397| depsBuildTarget = elemAt (elemAt dependencies 0) 2;
error: Dependency is not of a valid type: element 1 of nativeBuildInputs for nix-shell