Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple change to support shell hooks #45

Closed
wants to merge 3 commits into from
Closed
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
2 changes: 0 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ on:
default: false
type: boolean
# Nightly releases
schedule:
- cron: "45 8 * * 1-5"
push:
tags:
- "*" # Tags that trigger a new release version
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:

permissions:
contents: read
pull-requests: read
pull-requests: none

jobs:
golangci-lint:
Expand Down
3 changes: 2 additions & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import (
type Config struct {
// Packages is the slice of Nix packages that devbox makes available in
// its environment.
Packages []string `cue:"[...string]" json:"packages,omitempty"`
Packages []string `cue:"[...string]" json:"packages,omitempty"`
ShellHook string `cue:"string" json:"shell-hook"`
}

// ReadConfig reads a devbox config file.
Expand Down
3 changes: 2 additions & 1 deletion devbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ func (d *Devbox) Build(opts ...docker.BuildOptions) error {
// environment.
func (d *Devbox) Plan() *planner.BuildPlan {
basePlan := &planner.BuildPlan{
Packages: d.cfg.Packages,
Packages: d.cfg.Packages,
ShellHook: d.cfg.ShellHook,
Copy link
Collaborator

@LucilleH LucilleH Aug 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming ShellHook is only applicable on devbox shell command, and not devbox build?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LucilleH Plan is currently called by both devbox shell and devbox build

Copy link
Collaborator

@LucilleH LucilleH Aug 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@loreto sorry to clarify, will/should the shell hook be called in the Dockerfile as well? (I lean more towards .env in this case)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It won't run because there's nothing that executes it. This behaves as you want. I'm just saying the same struct that includes the hook is passed to both shell and build.

}
return planner.MergePlans(basePlan, planner.Plan(d.srcDir))
}
Expand Down
1 change: 1 addition & 0 deletions planner/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
// or whether it should be the same structure as devbox.Config.
type BuildPlan struct {
Packages []string `cue:"[...string]" json:"packages"`
ShellHook string `cue:"string" json:"shell-hook,omitempty"`
InstallCommand string `cue:"string" json:"install_command,omitempty"`
BuildCommand string `cue:"string" json:"build_command,omitempty"`
StartCommand string `cue:"string" json:"start_command,omitempty"`
Expand Down
1 change: 1 addition & 0 deletions tmpl/shell.nix.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ mkShell {
export name="devbox"
export IN_NIX_SHELL=0
export DEVBOX_SHELL_ENABLED=1
{{.ShellHook}}
'';
packages = [
{{- range .Packages}}
Expand Down