-
Notifications
You must be signed in to change notification settings - Fork 264
Description
Issue
When adding go_1_19 to my projects Devbox configuration, the devbox build
command fails with the error
#0 38.04 error: collision between `/nix/store/i0rdvlkvc5sz0dr87s379j0i4xmnwrp5-go-1.18.4/bin/go' and `/nix/store/w205lbrnh8cm9680pqzw2pc07rhi43an-go-1.19/bin/go'
#0 38.15 error: builder for '/nix/store/9vrr8h6l7n1gjrl8ybb24qrvpbirvd33-devbox.drv' failed with exit code 25
------
error: failed to solve: executor failed running [/bin/sh -eux -o pipefail -c nix-env -if ./.devbox/gen/default.nix]: exit code: 100
Expected Result
A devbox container image that includes Go version 1.19
Additional Information
I dug into the code a bit and the issue is being caused by the language detection feature for Go. The Go planner builder does not contain any logic for detecting that a golang nix package has already been requested which results in both the go_1_19
and go
Nix packages being added to the list of packages used for populating the default.nix
and shell.nix
template files.
Contents of devbox.json
{
"packages": [
"go_1_19"
]
}
Generated default.nix
let
pkgs = import (fetchTarball {
# Commit hash as of 2022-08-16
# `git ls-remote https://github.com/nixos/nixpkgs nixos-unstable`
url = "https://github.com/nixos/nixpkgs/archive/af9e00071d0971eb292fd5abef334e66eda3cb69.tar.gz";
sha256 = "1mdwy0419m5i9ss6s5frbhgzgyccbwycxm5nal40c8486bai0hwy";
}) {};
in with pkgs;
buildEnv {
name = "devbox";
paths = [
go_1_19
go
];
pathsToLink = [ "/bin" ];
}
Generated shell.nix
let
pkgs = import (fetchTarball {
# Commit hash as of 2022-08-16
# `git ls-remote https://github.com/nixos/nixpkgs nixos-unstable`
url = "https://github.com/nixos/nixpkgs/archive/af9e00071d0971eb292fd5abef334e66eda3cb69.tar.gz";
sha256 = "1mdwy0419m5i9ss6s5frbhgzgyccbwycxm5nal40c8486bai0hwy";
}) {};
in with pkgs;
mkShell {
shellHook =
''
echo "Starting a devbox shell..."
export name="devbox"
export IN_NIX_SHELL=0
export DEVBOX_SHELL_ENABLED=1
'';
packages = [
go_1_19
go
];
}
Possible Solutions
I started poking around at a solution for handling this and at first I was going to just add a check in the Go planner's IsRelevant()
method when I realized that this problem will not be limited to just Golang. I can think of 2 different methods for addressing this:
- Modify the Planner interface in a way that forwards user-specified packages to each languages Planner in a way that allows it to create it's build plan using the user-specified language version and removing that entry from the user-specified packages list
- Implement language version detection in each planner (ie. parsing go.mod/pyproject.toml for versions) and add collision checking for user-specified packages elsewhere.
I figured I'd forgo sending in a PR since this probably warrants a discussion before deciding on how this situation is handled.