Is is possible to override a derivation directly in a nix-build
command?
I am trying to do something like:
$ nix-build -A 'nginx.override{ openssl = libressl; }'
error: attribute ‘override{ openssl = libressl; }’ in selection path ‘nginx.override{ openssl = libressl; }’ not found
As a comparison, overriding is working fine with nix-shell
:
$ nix-shell -p 'nginx.override{ openssl = libressl; }' --run "nginx -V"
nginx version: nginx/1.12.0
built by gcc 5.4.0 (GCC)
built with LibreSSL 2.5.4
...
nix-build -A
expects an attribute path; instead try something like
nix-build -E 'with (import <nixpkgs>{}); nginx.override { openssl = libressl; }'`
Thanks, that made the trick!
It would be nice if the new cli could provide a simpler way to do this.
BTW, the fact that it works with nix-shell -p
is really a bug/accident. It just pastes the argument into a Nix expression that it constructs, rather than parsing it properly as an attribute.
Most helpful comment
nix-build -A
expects an attribute path; instead try something like