diff --git a/pkgs/oizys/oizys-go/cmd/build.go b/pkgs/oizys/oizys-go/cmd/build.go index 486ca91..c439d86 100644 --- a/pkgs/oizys/oizys-go/cmd/build.go +++ b/pkgs/oizys/oizys-go/cmd/build.go @@ -15,4 +15,5 @@ var buildCmd = &cobra.Command{ func init() { rootCmd.AddCommand(buildCmd) buildCmd.Flags().BoolVar(&nom, "nom", false, "display result with nom") + buildCmd.Flags().BoolVar(&systemPath, "system-path", false, "show system-path drv") } diff --git a/pkgs/oizys/oizys-go/cmd/ci.go b/pkgs/oizys/oizys-go/cmd/ci.go index 968f88f..7c6ebbf 100644 --- a/pkgs/oizys/oizys-go/cmd/ci.go +++ b/pkgs/oizys/oizys-go/cmd/ci.go @@ -3,18 +3,18 @@ package cmd import ( "github.com/spf13/cobra" ) + // gh workflow run build.yml -F lockFile=@flake.lock -var ciCmd= &cobra.Command{ +var ciCmd = &cobra.Command{ Use: "ci", Short: "offload build to GHA", Run: func(cmd *cobra.Command, args []string) { - oizys.CI(args...) + oizys.CI(args...) }, } - func init() { rootCmd.AddCommand(ciCmd) - + } diff --git a/pkgs/oizys/oizys-go/cmd/dry.go b/pkgs/oizys/oizys-go/cmd/dry.go index a5f5a6e..0649aef 100644 --- a/pkgs/oizys/oizys-go/cmd/dry.go +++ b/pkgs/oizys/oizys-go/cmd/dry.go @@ -12,8 +12,7 @@ var dryCmd = &cobra.Command{ }, } - func init() { rootCmd.AddCommand(dryCmd) - + } diff --git a/pkgs/oizys/oizys-go/cmd/output.go b/pkgs/oizys/oizys-go/cmd/output.go index 077adb4..fc018f7 100644 --- a/pkgs/oizys/oizys-go/cmd/output.go +++ b/pkgs/oizys/oizys-go/cmd/output.go @@ -14,8 +14,7 @@ var outputCmd = &cobra.Command{ }, } - func init() { rootCmd.AddCommand(outputCmd) - outputCmd.Flags().BoolVar(&systemPath, "system-path", false, "show system-path drv") + outputCmd.Flags().BoolVar(&systemPath, "system-path", false, "show system-path drv") } diff --git a/pkgs/oizys/oizys-go/cmd/root.go b/pkgs/oizys/oizys-go/cmd/root.go index 15ab125..d66df90 100644 --- a/pkgs/oizys/oizys-go/cmd/root.go +++ b/pkgs/oizys/oizys-go/cmd/root.go @@ -57,7 +57,7 @@ func setupLogger() { for k, v := range styles.Levels { styles.Levels[k] = v.MaxWidth(10) } - log.SetStyles(styles) + log.SetStyles(styles) } func init() { diff --git a/pkgs/oizys/oizys-go/default.nix b/pkgs/oizys/oizys-go/default.nix index 5cfc727..d1e4506 100644 --- a/pkgs/oizys/oizys-go/default.nix +++ b/pkgs/oizys/oizys-go/default.nix @@ -13,7 +13,7 @@ let in buildGoModule { pname = "oizys"; - version = "d${mkDate self.lastModifiedDate}"; + version = "${self.shortRev or "dirty"}"; src = cleanSource ./.; vendorHash = "sha256-/JVXhXrU2np/ty7AGFy+LPZCo1NaLYl9NAyD9+FJYBI="; diff --git a/pkgs/oizys/oizys-go/internal/oizys/main.go b/pkgs/oizys/oizys-go/internal/oizys/main.go index 8d9a76e..a13d48b 100644 --- a/pkgs/oizys/oizys-go/internal/oizys/main.go +++ b/pkgs/oizys/oizys-go/internal/oizys/main.go @@ -62,7 +62,8 @@ func parseSystemPath(derivation map[string]Derivation) (string, error) { // nix derivation show `oizys output` | jq -r '.[].inputDrvs | with_entries(select(.key|match("system-path";"i"))) | keys | .[]' func (o *Oizys) getSystemPath() string { cmd := exec.Command("nix", "derivation", "show", o.nixosConfigAttr()) - log.Info("evaluating to get system-path") + logCmd(cmd) + // TODO: add spinner? cmd.Stderr = os.Stderr out, err := cmd.Output() if err != nil { @@ -189,6 +190,9 @@ func (p *packages) summary() { Render(fmt.Sprint(len(p.names))), ) } +func logCmd(cmd *exec.Cmd) { + log.Debugf("CMD: %s", strings.Join(cmd.Args, " ")) +} func (o *Oizys) git(rest ...string) *exec.Cmd { args := []string{"-C", o.flake} @@ -256,10 +260,6 @@ func showDryRunResult(nixOutput string, verbose bool) { toFetch.show(verbose) } -func logCmd(cmd *exec.Cmd) { - log.Debugf("CMD: %s %s", cmd.Path, strings.Join(cmd.Args, " ")) -} - func (o *Oizys) NixDryRun(verbose bool, rest ...string) { args := []string{ "build", o.nixosConfigAttr(), "--dry-run", @@ -288,11 +288,11 @@ func (o *Oizys) NixosRebuild(subcmd string, rest ...string) { if o.verbose { cmd.Args = append(cmd.Args, "--print-build-logs") } - logCmd(cmd) runCommand(cmd) } func runCommand(cmd *exec.Cmd) { + logCmd(cmd) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr if err := cmd.Run(); err != nil { @@ -308,6 +308,9 @@ func (o *Oizys) NixBuild(nom bool, rest ...string) { cmdName = "nix" } cmd := exec.Command(cmdName, "build") + if o.systemPath { + cmd.Args = append(cmd.Args, fmt.Sprintf("%s^*", o.getSystemPath())) + } cmd.Args = append(cmd.Args, rest...) runCommand(cmd) }