Skip to content

Commit a4c2b40

Browse files
authored
[devbox] Allow for custom install/build/start commands (#43)
## Summary Allow for custom install/build/start commands by customizing them in `devbox.json`. This makes it possible for users to build docker images in the cases when they need to do some customization, or when we have not yet written a language planner for that language. ## How was it tested? Built, and ran `devbox plan` and `devbox generate` against a few examples.
1 parent fa25b9d commit a4c2b40

File tree

19 files changed

+117
-67
lines changed

19 files changed

+117
-67
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
with:
4646
distribution: goreleaser
4747
version: latest
48-
args: release --rm-dist --skip-publish --snapshot
48+
args: release --rm-dist --skip-publish --skip-announce --snapshot
4949
env:
5050
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5151
TELEMETRY_KEY: ${{ secrets.TELEMETRY_KEY }}

boxcli/add.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ import (
1111

1212
func AddCmd() *cobra.Command {
1313
command := &cobra.Command{
14-
Use: "add <pkg>...",
15-
Args: cobra.MinimumNArgs(1),
16-
RunE: runAddCmd,
14+
Use: "add <pkg>...",
15+
Short: "Add a new package to your devbox",
16+
Args: cobra.MinimumNArgs(1),
17+
RunE: runAddCmd,
1718
}
1819
return command
1920
}

boxcli/build.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ func BuildCmd() *cobra.Command {
1414
flags := &docker.BuildFlags{}
1515

1616
command := &cobra.Command{
17-
Use: "build [<dir>]",
18-
Args: cobra.MaximumNArgs(1),
19-
Hidden: true, // Hide until ready for release.
20-
RunE: buildCmdFunc(flags),
17+
Use: "build [<dir>]",
18+
Short: "Build an OCI image that can run as a container",
19+
Args: cobra.MaximumNArgs(1),
20+
RunE: buildCmdFunc(flags),
2121
}
2222

2323
command.Flags().BoolVar(

boxcli/init.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ import (
1111

1212
func InitCmd() *cobra.Command {
1313
command := &cobra.Command{
14-
Use: "init [<dir>]",
15-
Args: cobra.MaximumNArgs(1),
16-
RunE: runInitCmd,
14+
Use: "init [<dir>]",
15+
Short: "Initialize a directory as a devbox project",
16+
Args: cobra.MaximumNArgs(1),
17+
RunE: runInitCmd,
1718
}
1819
return command
1920
}

boxcli/plan.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ import (
1313

1414
func PlanCmd() *cobra.Command {
1515
command := &cobra.Command{
16-
Use: "plan [<dir>]",
17-
Args: cobra.MaximumNArgs(1),
18-
RunE: runPlanCmd,
16+
Use: "plan [<dir>]",
17+
Short: "Preview the plan used to build your environment",
18+
Args: cobra.MaximumNArgs(1),
19+
RunE: runPlanCmd,
1920
}
2021
return command
2122
}

boxcli/rm.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ import (
1111

1212
func RemoveCmd() *cobra.Command {
1313
command := &cobra.Command{
14-
Use: "rm <pkg>...",
15-
Args: cobra.MinimumNArgs(1),
16-
RunE: runRemoveCmd,
14+
Use: "rm <pkg>...",
15+
Short: "Remove a package from your devbox",
16+
Args: cobra.MinimumNArgs(1),
17+
RunE: runRemoveCmd,
1718
}
1819
return command
1920
}

boxcli/root.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ import (
1616

1717
func RootCmd() *cobra.Command {
1818
command := &cobra.Command{
19-
Use: "devbox",
19+
Use: "devbox",
20+
Short: "Instant, easy, predictable shells and containers",
2021
PersistentPreRun: func(cmd *cobra.Command, args []string) {
2122
// Don't display 'usage' on application errors.
2223
cmd.SilenceUsage = true

boxcli/shell.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ import (
1515

1616
func ShellCmd() *cobra.Command {
1717
command := &cobra.Command{
18-
Use: "shell [<dir>]",
19-
Args: cobra.MaximumNArgs(1),
20-
RunE: runShellCmd,
18+
Use: "shell [<dir>]",
19+
Short: "Start a new shell with access to your packages",
20+
Args: cobra.MaximumNArgs(1),
21+
RunE: runShellCmd,
2122
}
2223
return command
2324
}

boxcli/version.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ import (
1414
func VersionCmd() *cobra.Command {
1515
flags := &versionFlags{}
1616
command := &cobra.Command{
17-
Use: "version",
18-
Args: cobra.NoArgs,
19-
RunE: versionCmdFunc(flags),
17+
Use: "version",
18+
Short: "Print version information",
19+
Args: cobra.NoArgs,
20+
RunE: versionCmdFunc(flags),
2021
}
2122

2223
command.Flags().BoolVarP(&flags.verbose, "verbose", "v", false, // value

config.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@ package devbox
66
import (
77
"github.com/pkg/errors"
88
"go.jetpack.io/devbox/cuecfg"
9+
"go.jetpack.io/devbox/planner"
910
)
1011

1112
// Config defines a devbox environment as JSON.
1213
type Config struct {
13-
// Packages is the slice of Nix packages that devbox makes available in
14-
// its environment.
15-
Packages []string `cue:"[...string]" json:"packages,omitempty"`
14+
planner.Plan
1615
}
1716

1817
// ReadConfig reads a devbox config file.

0 commit comments

Comments
 (0)