Nix 错误:未定义变量“goPackages”

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)

我该如何解决这个问题?

答案1

gosu现在可以在:${pkgs.gosu.bin}

换句话说,替换:

      exec ${goPackages.gosu.bin}/bin/gosu redis "$BASH_SOURCE" "$@"

和:

      exec ${pkgs.gosu.bin}/bin/gosu redis "$BASH_SOURCE" "$@"

如果有人知道发生了什么goPackages,那么知道会很有用。

我发布这个问题/答案是因为我认为其他人可能会遇到同样的错误。

相关内容