build: wrap nix build
These things currently require manual testing unfortunately since writing a nix stub would take a long time.
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"log"
|
||||
"os"
|
||||
"os/signal"
|
||||
"slices"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
@@ -20,6 +21,9 @@ type commandHandlerError string
|
||||
func (c commandHandlerError) Error() string { return string(c) }
|
||||
|
||||
func main() {
|
||||
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
|
||||
defer stop()
|
||||
|
||||
var (
|
||||
flagNixOS bool
|
||||
flagVerbose bool
|
||||
@@ -38,7 +42,18 @@ func main() {
|
||||
Flag(&flagVerbose, "v", command.BoolFlag(false), "Connect nix stderr").
|
||||
Flag(&flagJSON, "json", command.BoolFlag(false), "Serialise output in JSON when applicable")
|
||||
|
||||
c.Command("instantiated", "Evaluate an installable and output all derivations it instantiated", func(args []string) error {
|
||||
c.Command("build", "Build a list of installables", func(args []string) error {
|
||||
if len(args) < 1 {
|
||||
return commandHandlerError("build requires at least 1 argument")
|
||||
}
|
||||
|
||||
if err := nixbuild.Build(ctx, slices.Values(args)); err != nil {
|
||||
return commandHandlerError(fmt.Sprintf("cannot build: %v", err))
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
c.Command("instantiated", "Evaluate an installable and output all derivations instantiated during evaluation", func(args []string) error {
|
||||
if len(args) != 1 {
|
||||
return commandHandlerError("instantiated requires exactly 1 argument")
|
||||
}
|
||||
@@ -60,9 +75,6 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
|
||||
defer stop()
|
||||
|
||||
if v, err := nixbuild.EvalInstantiated(ctx, installable); err != nil {
|
||||
return commandHandlerError(fmt.Sprintf("cannot evaluate for instantiated derivations: %v", err))
|
||||
} else if flagJSON {
|
||||
|
||||
Reference in New Issue
Block a user