After waiting a couple of days and getting no response I found this talk, which in combination with the examples in the man pages of nix-shell, nix-build and nix-instantiate, produced the required answer.
The equivalent of:
nix-shell '<nixpkgs>' -A gnused
is:
nix-shell -E 'with import <nixpkgs> {}; gnused'
or as a shell.nix:
# shell.nix
with import <nixpkgs> {};
gnused
The equivalent of:
nix-shell -p ctags
is:
nix-shell -E 'with import <nixpkgs> {}; runCommand "dummy" { buildInputs = [ ctags ]; } ""'
or as a shell.nix:
# shell.nix
with import <nixpkgs> {};
runCommand "dummy" { buildInputs = [ ctags ]; } ""
N.B. The runCommand
takes the 3 input parameters, in this case the 3rd parameter is purposely left blank.
To combine both, we use an override but not gnused.override
which would override the arguments of mkDerivation
for gnused, instead we use gnused.overrideAttrs
which overrides the attributes inside of mkDerivation
.
nix-shell -E 'with import <nixpkgs> {}; gnused.overrideAttrs (oldAttrs: { buildInputs = [ ctags ]; })'
or as a shell.nix:
# shell.nix
with import <nixpkgs> {};
gnused.overrideAttrs (oldAttrs: { buildInputs = [ ctags ]; })
N.B. To find the attributes of a derivation such as gnused
, invoke the nix repl using nix repl '<nixpkgs>'
and type gnused.
and then press tab for completion or use nix edit nixpkgs.gnused
which will open up the derivation in the editor set by $EDITOR
.