Deployment and lifecycle management for Nix
0
fork

Configure Feed

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

rename settings, add autoreboot/mode to config

+13 -14
+9 -3
cli/src/main.rs
··· 91 91 92 92 #[derive(Debug, Deserialize)] 93 93 pub struct Config { 94 + autoreboot: Option<bool>, 95 + mode: Option<ActivationMode>, 94 96 name: Option<String>, 95 97 #[serde(rename(deserialize = "type"))] 96 98 seed_type: Option<SeedType>, ··· 148 150 toml::from_str(&config_string).expect("failed to parse config file") 149 151 } 150 152 _ => Config { 153 + autoreboot: None, 154 + mode: None, 151 155 name: None, 152 156 seed_type: None, 153 157 url: None, ··· 165 169 match &cli.action { 166 170 Actions::Seed { action } => match action { 167 171 SeedCommands::Activate { mode, .. } => { 168 - seed.activate(mode.clone()).expect("failed to activate"); 172 + let mode = mode.clone().or(config.mode); 173 + seed.activate(mode).expect("failed to activate"); 169 174 } 170 175 171 176 SeedCommands::Download {} => { ··· 175 180 176 181 Actions::Tree { action } => match action { 177 182 TreeCommands::Upgrade { mode, reboot, yes } => { 183 + let mode = mode.clone().or(config.mode); 178 184 seed.realize() 179 185 .expect("failed to realize") 180 - .activate(mode.clone()) 186 + .activate(mode) 181 187 .expect("failed to activate"); 182 188 183 - if reboot.clone() { 189 + if config.autoreboot.unwrap_or(false) || reboot.clone() { 184 190 tree.reboot(yes.clone()); 185 191 } 186 192 }
+4 -11
nix/nixos-client.nix
··· 16 16 17 17 package = lib.mkOption { type = lib.types.package; }; 18 18 19 - config = lib.mkOption { 19 + settings = lib.mkOption { 20 20 type = lib.types.submodule { 21 21 freeformType = tomlType; 22 22 ··· 43 43 }; 44 44 45 45 config = lib.mkIf cfg.enable { 46 - assertions = [ 47 - { 48 - assertion = cfg.config.url != null; 49 - message = "Sower URL is required"; 50 - } 51 - ]; 52 - 53 - environment.etc."sower/config.toml".source = lib.mkIf (cfg.config != null) ( 54 - toml.generate "sower-config.toml" cfg.config 46 + environment.etc."sower/config.toml".source = lib.mkIf (cfg.settings != null) ( 47 + toml.generate "sower-config.toml" cfg.settings 55 48 ); 56 49 57 50 systemd.services.sower-client = { 58 51 path = [ pkgs.nix ]; 59 52 60 53 serviceConfig = { 61 - ExecStart = "${lib.getExe cfg.package} tree upgrade --reboot --yes"; 54 + ExecStart = "${lib.getExe cfg.package} tree upgrade"; 62 55 Type = "oneshot"; 63 56 }; 64 57 };