I’m totally new to Nix and are now working my way through the various docs.
The manual talks about modifying all-packages.nix
in order to register my derivation.
I manged to build my first derivation like this
$ nix-build default.nix
these derivations will be built:
/nix/store/mrvd5q77f6qxy58pj0y3xbc0fryyxgyc-myhello-1.0.0.drv
building '/nix/store/mrvd5q77f6qxy58pj0y3xbc0fryyxgyc-myhello-1.0.0.drv'...
/nix/store/9d365cd0ikiz6c8k8faaczh6j45hh12z-myhello-1.0.0
with very simple content
{ pkgs ? import <nixpkgs> {} }:
pkgs.stdenv.mkDerivation {
pname = "myhello";
version = "1.0.0";
builder = ./builder.sh;
}
and builder
source $stdenv/setup
mkdir -p $out/bin
cat << EOF >> $out/bin/hello
echo "Hello World!"
EOF
chmod +x $out/bin/hello
This works as expected
$ ./result/bin/hello
Hello World!
but nix cannot find this derivation when I query for it
$ nix-env -qa myhello
error: selector 'myhello' matches no derivations
I guess this is because I didn’t register myhello “globally”.
My goal is to build a few derivations that should (for now) only exist in my local nix installation.
How can I register this derivation so that it can be referenced and included in an env for example?
$ nix-env -i myhello
error: selector 'myhello' matches no derivations