I’m trying to follow the instructions described for Pinning nixpkgs on the wiki, doing so in a Dockerfile build with the recommended lnl7/nix base image, and I’m running into trouble. It looks like nix expects that the tar
command will be present in the system environment (as an impure dependency?), but it seems it is not:
default.nix:
let
pkgs = import (fetchTarball {
name = "nixos-20.09-2020-10-28";
url = "https://github.com/nixos/nixpkgs/archive/13d0c311e3ae923a00f734b43fd1d35b47d8943a.tar.gz";
sha256 = "0izp5y55whbdaf26w3zy2xvkjvlll39lib1ifvb61ps9gmvlqn39";
}) {};
in
pkgs.buildEnv {
# ...
}
Dockerfile:
FROM lnl7/nix:2.3.7
ADD default.nix /
RUN nix-env -i -f default.nix
When I try to build this:
$ docker build -f Dockerfile-server .
Sending build context to Docker daemon 0.2MB
Step 1/15 : FROM lnl7/nix:2020-09-11
---> 28904601fe33
Step 2/15 : ADD default.nix /
---> 20b62fd161c2
Step 3/15 : RUN nix-env -i -f default.nix
---> Running in c38e418aba3f
unpacking 'https://github.com/nixos/nixpkgs/archive/13d0c311e3ae923a00f734b43fd1d35b47d8943a.tar.gz'...
error: executing 'tar': No such file or directory
error: program 'tar' failed with exit code 1
What’s the recommended approach here?