Skip to content

Nix Feature: Packages Installing but not in PATH #1573

Description

@natescherer

Hi All,
Wanted to make an issue to note that using the packages option on the nix feature seems to install the packages but they do not end up on the PATH, and I'm not sure if that was intentional or not based on the documentation? Here's a minimal example:

devcontainer.json

{
    "image": "mcr.microsoft.com/devcontainers/base:debian",
    "features": {
        "ghcr.io/devcontainers/features/nix:1": {
            "packages": "alejandra"
        }
    }
}

After the container builds, I can verify that it did install alejandra, but it's not on the PATH.
Zsh

vscode ➜ /workspaces/h2ek8s (main) $ alejandra
zsh: command not found: alejandra
vscode ➜ /workspaces/h2ek8s (main) $ find / -name alejandra
EXTRANEOUS PERMISSION DENIED LINES REMOVED
/nix/store/abdks1z1vr080rip7m1svddsl3hy500d-nixpkgs/nixpkgs/pkgs/by-name/al/alejandra
/nix/store/8l4jxp6j7qjw2jvhw8zzcnd52rrkg8wr-user-environment/bin/alejandra
/nix/store/9smc80g61acjf8kk8dr9lb8phcz0fxfv-user-environment/bin/alejandra
/nix/store/fqc2w0lqhnfilywlf8q2r6dc98q9ppby-alejandra-4.0.0/bin/alejandra

Interestingly, if I change the package installation to happen with an onCreateCommand, it works fine, even though that seems to be more or less what the feature is doing?

devcontainer.json

{
    "image": "mcr.microsoft.com/devcontainers/base:debian",
    "features": {
        "ghcr.io/devcontainers/features/nix:1": {}
    },
    "onCreateCommand": "nix-env -iA nixpkgs.alejandra"
}

After the container builds, alejandra is on the PATH.
Zsh

vscode ➜ /workspaces/h2ek8s (main) $ alejandra
Formatting stdin.
Use --help to see all command line options.
use --quiet to suppress this and other messages.

I played around with various permutations of adding nixpkgs. before the package name, setting useAttributePath to true, and setting multiUser to false, and none seemed to result in what I put in packages ending up on the PATH.

Here's my local environment:

OS: Win 11 25H2
VS Code: 1.109.3
Docker Desktop: 4.60.1

Please let me know if you have any questions or need any more information!

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions