Skip to content

Commit 09362de

Browse files
committed
Show warning if no systemd
1 parent 988cdf0 commit 09362de

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

internal/boxcli/setup.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func runInstallNixCmd(cmd *cobra.Command) error {
4949
)
5050
return nil
5151
}
52-
return nix.Install(cmd.ErrOrStderr(), nixDaemonFlagVal(cmd)())
52+
return nix.Install(cmd.ErrOrStderr(), nixDaemonFlagVal(cmd))
5353
}
5454

5555
// ensureNixInstalled verifies that nix is installed and that it is of a supported version

internal/nix/install.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const rootError = "warning: installing Nix as root is not supported by this scri
2929

3030
// Install runs the install script for Nix. daemon has 3 states
3131
// nil is unset. false is --no-daemon. true is --daemon.
32-
func Install(writer io.Writer, daemon *bool) error {
32+
func Install(writer io.Writer, daemon func() *bool) error {
3333
if isRoot() && build.OS() == build.OSWSL {
3434
return usererr.New("Nix cannot be installed as root on WSL. Please run as a normal user with sudo access.")
3535
}
@@ -44,11 +44,15 @@ func Install(writer io.Writer, daemon *bool) error {
4444
// Should we pin version? Or just trust detsys
4545
installScript = "curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install"
4646
if isLinuxWithoutSystemd() {
47+
ux.Fwarningf(
48+
writer,
49+
"Could not detect systemd on your system. Installing Nix in root only mode (--init none).\n",
50+
)
4751
installScript += " linux --init none"
4852
}
4953
installScript += " --no-confirm"
5054
} else if daemon != nil {
51-
if *daemon {
55+
if *daemon() {
5256
installScript += " -- --daemon"
5357
} else {
5458
installScript += " -- --no-daemon"
@@ -165,7 +169,7 @@ func EnsureNixInstalled(writer io.Writer, withDaemonFunc func() *bool) (err erro
165169
fmt.Scanln() //nolint:errcheck
166170
}
167171

168-
if err = Install(writer, withDaemonFunc()); err != nil {
172+
if err = Install(writer, withDaemonFunc); err != nil {
169173
return err
170174
}
171175

0 commit comments

Comments
 (0)