mirror of
https://github.com/daylinmorgan/oizys.git
synced 2024-11-05 06:03: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() {
|
||||
rootCmd.AddCommand(buildCmd)
|
||||
buildCmd.Flags().BoolVar(&nom, "nom", false, "display result with nom")
|
||||
buildCmd.Flags().BoolVar(&systemPath, "system-path", false, "show system-path drv")
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -12,8 +12,7 @@ var dryCmd = &cobra.Command{
|
|||
},
|
||||
}
|
||||
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(dryCmd)
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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=";
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue