Nix
Nix 錯誤:未定義的變數“goPackages”
我正在嘗試建構一個 docker 映像,如此處所述:http: //lethalman.blogspot.com/2016/04/cheap-docker-images-with-nix_15.html
預設.nix
{ pkgs ? import <nixpkgs> {} }: with pkgs; let entrypoint = writeScript "entrypoint.sh" '' #!${stdenv.shell} set -e # allow the container to be started with `--user` if [ "$1" = "redis-server" -a "$(${coreutils}/bin/id -u)" = "0" ]; then chown -R redis . exec ${goPackages.gosu.bin}/bin/gosu redis "$BASH_SOURCE" "$@" fi exec "$@" ''; in dockerTools.buildImage { name = "redis"; runAsRoot = '' #!${stdenv.shell} ${dockerTools.shadowSetup} groupadd -r redis useradd -r -g redis -d /data -M redis mkdir /data chown redis:redis /data ''; contents = [ redis ]; config = { Cmd = [ "redis-server" ]; Entrypoint = [ entrypoint ]; ExposedPorts = { "6379/tcp" = {}; }; WorkingDir = "/data"; Volumes = { "/data" = {}; }; }; }
但是,這會產生以下錯誤:
nix-build error: undefined variable 'goPackages' at /home/chris/temp/nix/default.nix:12:14 (use '--show-trace' to show detailed location information)
我該如何解決這個問題?
gosu
現在可在:${pkgs.gosu.bin}
換句話說,替換:
exec ${goPackages.gosu.bin}/bin/gosu redis "$BASH_SOURCE" "$@"
和:
exec ${pkgs.gosu.bin}/bin/gosu redis "$BASH_SOURCE" "$@"
如果有人知道發生了什麼,
goPackages
那將很有用。我發布這個問題/答案是因為我認為其他人可能會遇到同樣的錯誤。