Skip to content

Commit

Permalink
[#45] Use flake update instead of flake lock --update-input
Browse files Browse the repository at this point in the history
Problem: Newer nix versions report the following warning when nix flake
lock --update-input is used:
```
warning: '--update-input' is a deprecated alias for 'flake update' and
will be removed in a future version
```
However, update-daemon still uses this option, so it's better to switch to the newer interface.

Solution: Replace command `flake lock --update-inputs` with `flake
update` in case when a list of inputs to update is provided.
  • Loading branch information
alexd1971 committed Aug 28, 2024
1 parent 45ff382 commit 6a102ef
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,16 @@ fn flake_update(
lock: &Lock,
) -> Result<(), FlakeUpdateError> {
let mut nix_flake_update = Command::new("nix");
nix_flake_update.arg("flake");
nix_flake_update.arg("flake").arg("update");

// If a list of inputs to update is not provided, update all inputs
if settings.inputs.is_empty() {
nix_flake_update.arg("update");
// Otherwise, update only the specified inputs
} else {
nix_flake_update.arg("lock");
// If a list of inputs to update is provided, update only the specified inputs
if !settings.inputs.is_empty() {
for input in settings.inputs.iter() {
// 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()));
};
nix_flake_update.arg("--update-input");
nix_flake_update.arg(input);
}
};
Expand Down

0 comments on commit 6a102ef

Please sign in to comment.