Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions internal/boxcli/featureflag/impure_print_dev_env.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright 2024 Jetify Inc. and contributors. All rights reserved.
// Use of this source code is governed by the license in the LICENSE file.

package featureflag

// ImpurePrintDevEnv controls whether the `devbox print-dev-env` command
// will be called with the `--impure` flag.
// Using the `--impure` flag will have two consequences:
// 1. All environment variables will be passed to nix, this will enable
// the usage of flakes that rely on environment variables.
// 2. It will disable nix caching, making the command slower.
var ImpurePrintDevEnv = disable("IMPURE_PRINT_DEV_ENV")
9 changes: 6 additions & 3 deletions internal/nix/nix.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"time"

"github.com/pkg/errors"
"go.jetpack.io/devbox/internal/boxcli/featureflag"
"go.jetpack.io/devbox/internal/boxcli/usererr"
"go.jetpack.io/devbox/internal/redact"
"golang.org/x/mod/semver"
Expand Down Expand Up @@ -74,9 +75,11 @@ func (*Nix) PrintDevEnv(ctx context.Context, args *PrintDevEnvArgs) (*PrintDevEn
}

if len(data) == 0 {
cmd := command("print-dev-env", "--json",
"path:"+flakeDirResolved,
)
cmd := command("print-dev-env", "--json")
if featureflag.ImpurePrintDevEnv.Enabled() {
cmd.Args = append(cmd.Args, "--impure")
}
cmd.Args = append(cmd.Args, "path:"+flakeDirResolved)
slog.Debug("running print-dev-env cmd", "cmd", cmd)
data, err = cmd.Output(ctx)
if insecure, insecureErr := IsExitErrorInsecurePackage(err, "" /*pkgName*/, "" /*installable*/); insecure {
Expand Down
Loading