diff --git a/module.nix b/module.nix index 55c9c41..0496358 100644 --- a/module.nix +++ b/module.nix @@ -11,6 +11,16 @@ let lib.mapAttrsFlatten (owner: lib.mapAttrsFlatten (repo: settings: { inherit type owner repo settings; }))) cfg.repos)); + input_override = lib.types.submodule { + input = lib.mkOption { + type = lib.types.str; + description = "Input to override"; + }; + override_url = lib.mkOption { + type = lib.types.str; + description = "Input to override"; + }; + }; in { options.services.update-daemon = with lib; with types; { @@ -97,7 +107,7 @@ in { default = 100; }; inputs = mkOption { - type = listOf str; + type = listOf (either str input_override); description = "List of input names to be updated, if empty, all inputs will be updated"; default = []; example = [ "haskell-nix" ]; diff --git a/src/main.rs b/src/main.rs index cfe5960..9bf9cd0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -57,13 +57,24 @@ fn flake_update( } else { nix_flake_update.arg("lock"); for input in settings.inputs.iter() { + let input_name = match input { + UpdateOrOverrideInput::Update(input_name) => { + nix_flake_update.arg("--update-input"); + nix_flake_update.arg(input_name); + input_name + }, + UpdateOrOverrideInput::Override{input, override_url} => { + nix_flake_update.arg("--override-input"); + nix_flake_update.arg(input); + nix_flake_update.arg(override_url); + input + }, + }; // Abort flake update if input is missing from the flake.lock root nodes // and allow_missing_inputs is not set - if !settings.allow_missing_inputs && lock.get_root_dep(input.clone()).is_none() { - return Err(FlakeUpdateError::MissingInput(input.clone())); + if !settings.allow_missing_inputs && lock.get_root_dep(input_name.clone()).is_none() { + return Err(FlakeUpdateError::MissingInput(input_name.clone())); }; - nix_flake_update.arg("--update-input"); - nix_flake_update.arg(input); } }; diff --git a/src/types.rs b/src/types.rs index 714c6c0..4b40de6 100644 --- a/src/types.rs +++ b/src/types.rs @@ -18,7 +18,7 @@ pub struct UpdateSettings { pub title: String, pub extra_body: String, pub cooldown: Duration, - pub inputs: Vec, + pub inputs: Vec, pub allow_missing_inputs: bool, } @@ -36,10 +36,17 @@ pub struct UpdateSettingsOptional { pub title: Option, pub extra_body: Option, pub cooldown: Option, - pub inputs: Option>, + pub inputs: Option>, pub allow_missing_inputs: Option, } +#[derive(Debug, Clone, Deserialize)] +#[serde(untagged)] +pub enum UpdateOrOverrideInput { + Update (String), + Override {input: String, override_url: String}, +} + #[derive(Debug, Error)] pub struct UpdateSettingsMissingField(String);