MCPcopy
hub / github.com/jetify-com/devbox / Run

Method Run

nix/install.go:74–109  ·  view source on GitHub ↗

Run downloads and installs Nix.

(ctx context.Context)

Source from the content-addressed store, hash-verified

72
73// Run downloads and installs Nix.
74func (i *Installer) Run(ctx context.Context) error {
75 if i.Path == "" {
76 err := i.Download(ctx)
77 if err != nil {
78 return err
79 }
80 }
81
82 cmd := exec.CommandContext(ctx, i.Path, "install")
83 switch runtime.GOOS {
84 case "darwin":
85 cmd.Args = append(cmd.Args, "macos")
86 case "linux":
87 cmd.Args = append(cmd.Args, "linux")
88 _, err := os.Stat("/run/systemd/system")
89 if errors.Is(err, os.ErrNotExist) {
90 // Respect any env var settings from the user.
91 _, ok := os.LookupEnv("NIX_INSTALLER_INIT")
92 if !ok {
93 cmd.Args = append(cmd.Args, "--init", "none")
94 }
95 }
96 }
97 cmd.Args = append(cmd.Args, "--no-confirm")
98 cmd.Cancel = func() error {
99 return cmd.Process.Signal(os.Interrupt)
100 }
101 cmd.Stdin = os.Stdin
102 cmd.Stdout = os.Stdout
103 cmd.Stderr = os.Stderr
104 if err := cmd.Run(); err != nil {
105 return fmt.Errorf("run installer: %v", err)
106 }
107 _, _ = SourceProfile()
108 return nil
109}
110
111func writeTempFile(r io.Reader) (path string, err error) {
112 tempFile, err := os.CreateTemp("", "devbox-nix-installer-")

Callers 1

EnsureNixInstalledFunction · 0.95

Calls 4

DownloadMethod · 0.95
IsMethod · 0.80
SourceProfileFunction · 0.70
RunMethod · 0.65

Tested by

no test coverage detected