Deployment and lifecycle management for Nix
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat(client): first nix-darwin application

+23 -4
+23 -4
client/src/sower.rs
··· 32 32 pub fn activate(&self, mode: Option<ActivationMode>) -> Result<&Self, String> { 33 33 // TODO compare new activation to existing profile 34 34 match &self.seed_type { 35 - SeedType::HomeManager => self.activate_generic(), 36 - SeedType::NixDarwin => self.activate_generic(), 35 + SeedType::HomeManager => self.activate_home_manager(), 36 + SeedType::NixDarwin => self.activate_nix_darwin(), 37 37 SeedType::Nixos => self.activate_nixos(mode), 38 38 } 39 39 } 40 40 41 - fn activate_generic(&self) -> Result<&Self, String> { 41 + fn activate_home_manager(&self) -> Result<&Self, String> { 42 + match run_command(format!("{}/activate", &self.out_path).as_ref(), vec![]) { 43 + true => Ok(self), 44 + false => Err(format!("failed to realize: {}", &self.out_path)), 45 + } 46 + } 47 + 48 + fn activate_nix_darwin(&self) -> Result<&Self, String> { 49 + // nixos profile needs to be manually set to ensure correct switching 50 + run_command( 51 + "nix-env", 52 + vec![ 53 + "--set", 54 + "--profile", 55 + "/nix/var/nix/profiles/system", 56 + &self.out_path.clone(), 57 + ], 58 + ); 59 + 42 60 match run_command(format!("{}/activate", &self.out_path).as_ref(), vec![]) { 43 61 true => Ok(self), 44 62 false => Err(format!("failed to realize: {}", &self.out_path)), ··· 105 123 env::var("HOME").expect("missing $HOME environment variable") 106 124 ) 107 125 } 108 - SeedType::NixDarwin => panic!("unsupported"), 126 + SeedType::NixDarwin => "/nix/var/nix/profiles/system".to_string(), 127 + 109 128 SeedType::Nixos => "/nix/var/nix/profiles/system".to_string(), 110 129 } 111 130 }