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:
2025-07-14 22:10:48 +09:00
parent f052e0b98a
commit 1c968c1e36
3 changed files with 74 additions and 4 deletions

View File

@@ -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 {