forked from jetify-com/devbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.go
31 lines (26 loc) · 824 Bytes
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Copyright 2022 Jetpack Technologies Inc and contributors. All rights reserved.
// Use of this source code is governed by the license in the LICENSE file.
package devbox
import (
"github.com/pkg/errors"
"go.jetpack.io/devbox/cuecfg"
)
// Config defines a devbox environment as JSON.
type Config struct {
// Packages is the slice of Nix packages that devbox makes available in
// its environment.
Packages []string `cue:"[...string]" json:"packages,omitempty"`
}
// ReadConfig reads a devbox config file.
func ReadConfig(path string) (*Config, error) {
cfg := &Config{}
err := cuecfg.ReadFile(path, cfg)
if err != nil {
return nil, errors.WithStack(err)
}
return cfg, nil
}
// WriteConfig saves a devbox config file.
func WriteConfig(path string, cfg *Config) error {
return cuecfg.WriteFile(path, cfg)
}