I am trying to explore the gnu sed code base.
I can do this from the command line:
nix-shell '<nixpkgs>' -A gnused
unpackPhase
cd sed-4.8
configurePhase
buildPhase
and then edit the code under sed etc
However, I would like to use ctags which is not installed:
nix-shell -p ctags
Installs the package but:
nix-shell '<nixpkgs>' -A gnused -p ctags
gets the error:
error: attribute 'gnused' in selection path 'gnused' not found
I realise I must use a shell.nix but I can't find a mkShell example for the above.
P.S. Two invocations of nix-shell achieve the required result but this seems unwieldy:
nix-shell -p ctags
nix-shell '<nixpkgs>' -A gnused
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:
is:
or as a shell.nix:
The equivalent of:
is:
or as a shell.nix:
N.B. The
runCommandtakes the 3 input parameters, in this case the 3rd parameter is purposely left blank.To combine both, we use an override but not
gnused.overridewhich would override the arguments ofmkDerivationfor gnused, instead we usegnused.overrideAttrswhich overrides the attributes inside ofmkDerivation.or as a shell.nix:
N.B. To find the attributes of a derivation such as
gnused, invoke the nix repl usingnix repl '<nixpkgs>'and typegnused.and then press tab for completion or usenix edit nixpkgs.gnusedwhich will open up the derivation in the editor set by$EDITOR.