Create development environment based on shell.nix

When I create a shell environment with the command

$ nix-shell --pure -p postgresql

I get an environment with the command pg_ctl. But when I run nix-shell in a directory with a shell.nix file containing

{
	pkgs ? import <nixpkgs> {}
}:

pkgs.mkShell
{
	buildinputs =
	[
		pkgs.postgresql
	];
}

I get an environment without any of the pg_* tools. Why is that?

Because of the buildinputs attribute, you have to write the i for Inputs with a capital I, as in buildInputs.

1 Like

Thanks, now it works!

Does it exist any tool that find these kind of errors?

Not that I am aware of, also what makes it hard to detect those “errors” is, that any attribute you provide will be translated to an environment variable for the underlying derivation.

It is the build script in the derivation which attaches a meaning to those environment variables.

https://nixos.wiki/wiki/Editor_Modes_for_Nix_Files

Coloured Syntax highlighting is always good to have. So depending on what editor/IDE you have there maybe a plugin.

Code completion/Code Suggestion are always nice too, there might be something in this list that fits the bill.

maybe nix-linter may also be able to help you in some cases.

https://github.com/Synthetica9/nix-linter

1 Like

I opened PR adding a basic check for typos to nixpkgs-hammering: https://github.com/jtojnar/nixpkgs-hammering/pull/29

2 Likes