Skip to content

Commit

Permalink
Merge pull request #46 from serokell/alexd1971/use-nix-flake-update
Browse files Browse the repository at this point in the history
[#45] Use `flake update` instead of `flake lock --update-input`
  • Loading branch information
alexd1971 authored Aug 30, 2024
2 parents 45ff382 + 1e21638 commit 3f9dcf9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
16 changes: 16 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@
inputs = {
flake-compat.flake = false;
naersk.url = "github:nix-community/naersk";
nix.url = "github:nixos/nix?ref=2.21.4";
};

outputs = { self, nixpkgs, flake-utils, serokell-nix, naersk, ... }:
outputs = { self, nixpkgs, flake-utils, serokell-nix, naersk, ... }@inputs:
flake-utils.lib.eachSystem [ "x86_64-linux" ] (system:
let
pkgs = nixpkgs.legacyPackages.${system}.extend serokell-nix.overlay;
naersk' = pkgs.callPackage naersk {};
nix = pkgs.nix;
nix = inputs.nix.packages.${system}.nix;

update-daemon = naersk'.buildPackage {
src = builtins.path {
Expand Down
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 3f9dcf9

Please sign in to comment.