Skip to content

Commit 7ed5b7a

Browse files
authored
Run daemon at startup (#1782)
1 parent abe9458 commit 7ed5b7a

2 files changed

Lines changed: 22 additions & 16 deletions

File tree

src/action/common/configure_determinate_nixd_init_service/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ enum SocketFamily {
206206

207207
fn generate_plist() -> DeterminateNixDaemonPlist {
208208
DeterminateNixDaemonPlist {
209-
run_at_load: false,
209+
run_at_load: true,
210210
label: "systems.determinate.nix-daemon".into(),
211211
program_arguments: vec!["/usr/local/bin/determinate-nixd".into(), "daemon".into()],
212212
standard_error_path: "/var/log/determinate-nix-daemon.log".into(),

src/action/common/configure_init_service.rs

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -181,28 +181,23 @@ impl Action for ConfigureInitService {
181181
let mut vec = Vec::new();
182182
match self.init {
183183
InitSystem::Systemd => {
184+
let service_dest = self
185+
.service_dest
186+
.as_ref()
187+
.expect("service_dest should be defined for systemd")
188+
.display();
189+
184190
let mut explanation = vec![
185191
"Run `systemd-tmpfiles --create --prefix=/nix/var/nix`".to_string(),
186192
match self
187193
.service_src
188194
.as_ref()
189195
.expect("service_src should be defined or systemd")
190196
{
191-
UnitSrc::Path(src) => format!(
192-
"Symlink `{0}` to `{1}`",
193-
src.display(),
194-
self.service_dest
195-
.as_ref()
196-
.expect("service_dest should be defined for systemd")
197-
.display()
198-
),
199-
UnitSrc::Literal(_) => format!(
200-
"Create `{0}`",
201-
self.service_dest
202-
.as_ref()
203-
.expect("service_dest should be defined for systemd")
204-
.display()
205-
),
197+
UnitSrc::Path(src) => {
198+
format!("Symlink `{0}` to `{1}`", src.display(), service_dest,)
199+
},
200+
UnitSrc::Literal(_) => format!("Create `{0}`", service_dest,),
206201
},
207202
];
208203

@@ -227,6 +222,13 @@ impl Action for ConfigureInitService {
227222
explanation.push(format!("Run `systemctl enable --now {}`", name));
228223
}
229224
}
225+
226+
explanation.push(format!(
227+
"Run `systemctl enable {}{}`",
228+
if self.start_daemon { "--now " } else { "" },
229+
service_dest
230+
));
231+
230232
vec.push(ActionDescription::new(self.tracing_synopsis(), explanation))
231233
},
232234
InitSystem::Launchd => {
@@ -478,6 +480,10 @@ impl Action for ConfigureInitService {
478480
},
479481
}
480482
}
483+
484+
enable(service_dest.display().to_string().as_ref(), *start_daemon)
485+
.await
486+
.map_err(Self::error)?;
481487
},
482488
InitSystem::None => {
483489
// Nothing here, no init system

0 commit comments

Comments
 (0)