Skip to content

Commit 38f046c

Browse files
committed
feat: protect --impure behind feature flag
1 parent 7879371 commit 38f046c

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright 2024 Jetify Inc. and contributors. All rights reserved.
2+
// Use of this source code is governed by the license in the LICENSE file.
3+
4+
package featureflag
5+
6+
// ImpurePrintDevEnv controls whether the `devbox print-dev-env` command
7+
// will be called with the `--impure` flag.
8+
// Using the `--impure` flag will have two consequences:
9+
// 1. All environment variables will be passed to nix, this will enable
10+
// the usage of flakes that rely on environment variables.
11+
// 2. It will disable nix caching, making the command slower.
12+
var ImpurePrintDevEnv = disable("IMPURE_PRINT_DEV_ENV")

internal/nix/nix.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"time"
2121

2222
"github.com/pkg/errors"
23+
"go.jetpack.io/devbox/internal/boxcli/featureflag"
2324
"go.jetpack.io/devbox/internal/boxcli/usererr"
2425
"go.jetpack.io/devbox/internal/redact"
2526
"golang.org/x/mod/semver"
@@ -74,7 +75,11 @@ func (*Nix) PrintDevEnv(ctx context.Context, args *PrintDevEnvArgs) (*PrintDevEn
7475
}
7576

7677
if len(data) == 0 {
77-
cmd := command("print-dev-env", "--json", "--impure",
78+
optionalImpureFlag := ""
79+
if featureflag.ImpurePrintDevEnv.Enabled() {
80+
optionalImpureFlag = "--impure"
81+
}
82+
cmd := command("print-dev-env", "--json", optionalImpureFlag,
7883
"path:"+flakeDirResolved,
7984
)
8085
slog.Debug("running print-dev-env cmd", "cmd", cmd)

0 commit comments

Comments
 (0)