Skip to content

Commit

Permalink
Wait for /nix to be there, and restart the hook until it works
Browse files Browse the repository at this point in the history
  • Loading branch information
grahamc committed Oct 11, 2023
1 parent b3af5d9 commit 25f9e71
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/action/macos/create_nix_hook_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,15 @@ impl Action for CreateNixHookService {
/// This function must be able to operate at both plan and execute time.
async fn generate_plist(service_label: &str) -> Result<LaunchctlHookPlist, ActionErrorKind> {
let plist = LaunchctlHookPlist {
run_at_load: true,
keep_alive: KeepAliveOpts {
successful_exit: false,
},
label: service_label.into(),
program_arguments: vec!["/nix/nix-installer".into(), "restore-shell".into()],
program_arguments: vec![
"/bin/sh".into(),
"-c".into(),
"/bin/wait4path /nix/nix-installer && /nix/nix-installer restore-shell".into(),
],
standard_error_path: "/nix/.nix-installer-hook.err.log".into(),
standard_out_path: "/nix/.nix-installer-hook.out.log".into(),
};
Expand All @@ -195,13 +201,19 @@ async fn generate_plist(service_label: &str) -> Result<LaunchctlHookPlist, Actio
#[derive(Deserialize, Clone, Debug, Serialize, PartialEq)]
#[serde(rename_all = "PascalCase")]
pub struct LaunchctlHookPlist {
run_at_load: bool,
label: String,
program_arguments: Vec<String>,
keep_alive: KeepAliveOpts,
standard_error_path: String,
standard_out_path: String,
}

#[derive(Deserialize, Clone, Debug, Serialize, PartialEq)]
#[serde(rename_all = "PascalCase")]
pub struct KeepAliveOpts {
successful_exit: bool,
}

#[non_exhaustive]
#[derive(Debug, thiserror::Error)]
pub enum CreateNixHookServiceError {
Expand Down

0 comments on commit 25f9e71

Please sign in to comment.