Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Postgresql commands no longer working inside dockerTools #350128

Closed
ailocam opened this issue Oct 21, 2024 · 1 comment
Closed

Postgresql commands no longer working inside dockerTools #350128

ailocam opened this issue Oct 21, 2024 · 1 comment
Labels
0.kind: bug Something is broken

Comments

@ailocam
Copy link

ailocam commented Oct 21, 2024

Describe the bug

The command line tools such as psql are not being symlinked into /bin inside Docker images created with pkgs.dockerTools.buildLayeredImage

The issue was introduced here 5547322#diff-3a40021ad7a436b9b71a4552b7b0ad4191dc190654bcfd383bf5fac2248e2ca9L292 #294504

Steps To Reproduce

Create a flake like so, note the commit hash is from before the change and works fine.

{
  description = "A very basic flake";
  inputs = {
    nixpkgs.url =
      "github:nixos/nixpkgs?ref=a3836576dd7d7e606f393434d39661ff096859f9";
  };
  outputs = { self, nixpkgs }:
    let
      pkgs = nixpkgs.legacyPackages.x86_64-linux;
      customPostgresql = pkgs.postgresql.withPackages (nixPgExtensions:
        [
          # I have some extensions here. 
        ]);
      dockerOptions = {
        name = "test-docker";
        tag = "latest";
        contents = [ pkgs.bash pkgs.coreutils customPostgresql ];
        config = {
          Entrypoint = [ "/bin/bash" ];
          WorkingDir = "/";
        };
      };
      dockerImageGzip = pkgs.dockerTools.buildLayeredImage dockerOptions;
    in {
      packages.x86_64-linux.docker = dockerImageGzip;
      packages.x86_64-linux.postgres = customPostgresql;
    };
}

It can be used like so and works fine.

nix build .#docker
docker load < result
docker run -it test-docker:latest
psql --version

Changing the nixpkgs url to github:nixos/nixpkgs?ref=5547322a0c01dd30a7e0111adc1f02bafbbd6ebc and running the same commands as above results in bash: psql: command not found

Expected behavior

That the contents of postgresql derivation's bin directory be symlinked into /bin like it is for other packages.

Additional context

Looks like dockerTools does not support derivations where the bin directory is a symlink.
This only happens when using pkgs.postgresql.withPackages using just pkgs.postgresql works fine.

Notify maintainers

@wolfgangwalther
I'm not sure who maintains dockerTools.

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

> nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.6.52, NixOS, 24.05 (Uakari), 24.05.5366.fbca5e745367`
 - multi-user?: `yes`
 - sandbox: `relaxed`
 - version: `nix-env (Nix) 2.18.8`
 - channels(root): `"nixos-24.05, nixos-hardware"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
@ailocam ailocam added the 0.kind: bug Something is broken label Oct 21, 2024
@wolfgangwalther
Copy link
Contributor

Is this a duplicate of #102962? There's some discussion about contents not being the right tool for the job in there. I didn't go through that in detail, but maybe you want to see whether there are alternative ways to write your flake?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken
Projects
None yet
Development

No branches or pull requests

3 participants