diff --git a/pkgs/oizys/cmd/output.go b/pkgs/oizys/cmd/output.go index 7eafba9..e4f1a2f 100644 --- a/pkgs/oizys/cmd/output.go +++ b/pkgs/oizys/cmd/output.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/spf13/cobra" + "oizys/internal/oizys" ) diff --git a/pkgs/oizys/cmd/root.go b/pkgs/oizys/cmd/root.go index fb18888..f5c4ec2 100644 --- a/pkgs/oizys/cmd/root.go +++ b/pkgs/oizys/cmd/root.go @@ -48,11 +48,8 @@ var rootCmd = &cobra.Command{ } oizys.SetFlake(flake) oizys.SetHost(host) - oizys.SetCache(cacheName) // TODO: move oizys.SetVerbose(verbose) oizys.SetResetCache(resetCache) - - oizys.CheckFlake() }, } diff --git a/pkgs/oizys/internal/oizys/main.go b/pkgs/oizys/internal/oizys/main.go index c6951ba..9469d52 100644 --- a/pkgs/oizys/internal/oizys/main.go +++ b/pkgs/oizys/internal/oizys/main.go @@ -11,7 +11,6 @@ import ( "github.com/charmbracelet/lipgloss" - "github.com/briandowns/spinner" "github.com/charmbracelet/log" ) @@ -55,9 +54,19 @@ func New() *Oizys { } func SetFlake(path string) { + // Check path exists if path != "" { o.flake = path } + // check local path exists + if !strings.HasPrefix(o.flake, "github") && !strings.HasPrefix(o.flake, "git+") { + if _, ok := os.LookupEnv("OIZYS_SKIP_CHECK"); !ok { + if _, err := os.Stat(o.flake); errors.Is(err, fs.ErrNotExist) { + log.Warnf("path to flake %s does not exist, using remote as fallback", o.flake) + o.flake = "github:daylinmorgan/oizys" + } + } + } } func SetCache(name string) { @@ -131,24 +140,6 @@ func Output() string { } } -// func (o *Oizys) Set( -// flake, host, cache string, -// verbose, systemPath, resetCache bool, -// ) { -// if host != "" { -// o.host = host -// } -// if flake != "" { -// o.flake = flake -// } -// if cache != "" { -// o.cache = cache -// } -// o.verbose = verbose -// o.systemPath = systemPath -// o.resetCache = resetCache -// } - func git(rest ...string) *exec.Cmd { args := []string{"-C", o.flake} args = append(args, rest...) @@ -497,11 +488,6 @@ func CacheBuild(rest ...string) { } func CheckFlake() { - if _, ok := os.LookupEnv("OIZYS_SKIP_CHECK"); !ok { - if _, err := os.Stat(o.flake); errors.Is(err, fs.ErrNotExist) { - log.Fatalf("path to flake: %s does not exist", o.flake) - } - } } func CI(rest ...string) { @@ -511,10 +497,10 @@ func CI(rest ...string) { exitWithCommand(cmd) } -// TODO: deprecate -func nixSpinner(host string) *spinner.Spinner { - msg := fmt.Sprintf("%s %s", " evaluating derivation for:", - lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("6")).Render(host), - ) - return startSpinner(msg) -} +// // TODO: deprecate +// func nixSpinner(host string) *spinner.Spinner { +// msg := fmt.Sprintf("%s %s", " evaluating derivation for:", +// lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("6")).Render(host), +// ) +// return startSpinner(msg) +// }