mirror of
https://github.com/daylinmorgan/oizys.git
synced 2024-11-09 20:33:15 -06:00
add system-path to build
This commit is contained in:
parent
22c9a5b420
commit
ddcc88fd17
7 changed files with 18 additions and 16 deletions
|
@ -15,4 +15,5 @@ var buildCmd = &cobra.Command{
|
||||||
func init() {
|
func init() {
|
||||||
rootCmd.AddCommand(buildCmd)
|
rootCmd.AddCommand(buildCmd)
|
||||||
buildCmd.Flags().BoolVar(&nom, "nom", false, "display result with nom")
|
buildCmd.Flags().BoolVar(&nom, "nom", false, "display result with nom")
|
||||||
|
buildCmd.Flags().BoolVar(&systemPath, "system-path", false, "show system-path drv")
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,17 +3,17 @@ package cmd
|
||||||
import (
|
import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
// gh workflow run build.yml -F lockFile=@flake.lock
|
// gh workflow run build.yml -F lockFile=@flake.lock
|
||||||
|
|
||||||
var ciCmd= &cobra.Command{
|
var ciCmd = &cobra.Command{
|
||||||
Use: "ci",
|
Use: "ci",
|
||||||
Short: "offload build to GHA",
|
Short: "offload build to GHA",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
oizys.CI(args...)
|
oizys.CI(args...)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rootCmd.AddCommand(ciCmd)
|
rootCmd.AddCommand(ciCmd)
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@ var dryCmd = &cobra.Command{
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rootCmd.AddCommand(dryCmd)
|
rootCmd.AddCommand(dryCmd)
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,7 @@ var outputCmd = &cobra.Command{
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rootCmd.AddCommand(outputCmd)
|
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")
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ func setupLogger() {
|
||||||
for k, v := range styles.Levels {
|
for k, v := range styles.Levels {
|
||||||
styles.Levels[k] = v.MaxWidth(10)
|
styles.Levels[k] = v.MaxWidth(10)
|
||||||
}
|
}
|
||||||
log.SetStyles(styles)
|
log.SetStyles(styles)
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
|
@ -13,7 +13,7 @@ let
|
||||||
in
|
in
|
||||||
buildGoModule {
|
buildGoModule {
|
||||||
pname = "oizys";
|
pname = "oizys";
|
||||||
version = "d${mkDate self.lastModifiedDate}";
|
version = "${self.shortRev or "dirty"}";
|
||||||
|
|
||||||
src = cleanSource ./.;
|
src = cleanSource ./.;
|
||||||
vendorHash = "sha256-/JVXhXrU2np/ty7AGFy+LPZCo1NaLYl9NAyD9+FJYBI=";
|
vendorHash = "sha256-/JVXhXrU2np/ty7AGFy+LPZCo1NaLYl9NAyD9+FJYBI=";
|
||||||
|
|
|
@ -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 | .[]'
|
// nix derivation show `oizys output` | jq -r '.[].inputDrvs | with_entries(select(.key|match("system-path";"i"))) | keys | .[]'
|
||||||
func (o *Oizys) getSystemPath() string {
|
func (o *Oizys) getSystemPath() string {
|
||||||
cmd := exec.Command("nix", "derivation", "show", o.nixosConfigAttr())
|
cmd := exec.Command("nix", "derivation", "show", o.nixosConfigAttr())
|
||||||
log.Info("evaluating to get system-path")
|
logCmd(cmd)
|
||||||
|
// TODO: add spinner?
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
out, err := cmd.Output()
|
out, err := cmd.Output()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -189,6 +190,9 @@ func (p *packages) summary() {
|
||||||
Render(fmt.Sprint(len(p.names))),
|
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 {
|
func (o *Oizys) git(rest ...string) *exec.Cmd {
|
||||||
args := []string{"-C", o.flake}
|
args := []string{"-C", o.flake}
|
||||||
|
@ -256,10 +260,6 @@ func showDryRunResult(nixOutput string, verbose bool) {
|
||||||
toFetch.show(verbose)
|
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) {
|
func (o *Oizys) NixDryRun(verbose bool, rest ...string) {
|
||||||
args := []string{
|
args := []string{
|
||||||
"build", o.nixosConfigAttr(), "--dry-run",
|
"build", o.nixosConfigAttr(), "--dry-run",
|
||||||
|
@ -288,11 +288,11 @@ func (o *Oizys) NixosRebuild(subcmd string, rest ...string) {
|
||||||
if o.verbose {
|
if o.verbose {
|
||||||
cmd.Args = append(cmd.Args, "--print-build-logs")
|
cmd.Args = append(cmd.Args, "--print-build-logs")
|
||||||
}
|
}
|
||||||
logCmd(cmd)
|
|
||||||
runCommand(cmd)
|
runCommand(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
func runCommand(cmd *exec.Cmd) {
|
func runCommand(cmd *exec.Cmd) {
|
||||||
|
logCmd(cmd)
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
if err := cmd.Run(); err != nil {
|
if err := cmd.Run(); err != nil {
|
||||||
|
@ -308,6 +308,9 @@ func (o *Oizys) NixBuild(nom bool, rest ...string) {
|
||||||
cmdName = "nix"
|
cmdName = "nix"
|
||||||
}
|
}
|
||||||
cmd := exec.Command(cmdName, "build")
|
cmd := exec.Command(cmdName, "build")
|
||||||
|
if o.systemPath {
|
||||||
|
cmd.Args = append(cmd.Args, fmt.Sprintf("%s^*", o.getSystemPath()))
|
||||||
|
}
|
||||||
cmd.Args = append(cmd.Args, rest...)
|
cmd.Args = append(cmd.Args, rest...)
|
||||||
runCommand(cmd)
|
runCommand(cmd)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue