Skip to content

Commit

Permalink
Add the submodule info to flake fingerprint
Browse files Browse the repository at this point in the history
This allows changes to dirty submodules to propagate correctly and
trigger a re-eval as one would expect. This previously only worked with
`__contentAddressed = true;`.
  • Loading branch information
Shay Bergmann committed Dec 6, 2021
1 parent 551cb98 commit c2cde79
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/libexpr/flake/flake.cc
Original file line number Diff line number Diff line change
Expand Up @@ -727,9 +727,10 @@ Fingerprint LockedFlake::getFingerprint() const
// and we haven't changed it, then it's sufficient to use
// flake.sourceInfo.storePath for the fingerprint.
return hashString(htSHA256,
fmt("%s;%s;%d;%d;%s",
fmt("%s;%s;%s;%d;%d;%s",
flake.sourceInfo->storePath.to_string(),
flake.lockedRef.subdir,
flake.lockedRef.input.getModules().value_or(""),
flake.lockedRef.input.getRevCount().value_or(0),
flake.lockedRef.input.getLastModified().value_or(0),
lockFile));
Expand Down
7 changes: 7 additions & 0 deletions src/libfetchers/fetchers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,13 @@ std::optional<time_t> Input::getLastModified() const
return {};
}

std::optional<std::string> Input::getModules() const
{
if (auto s = maybeGetStrAttr(attrs, "modules"))
return *s;
return {};
}

ParsedURL InputScheme::toURL(const Input & input)
{
throw Error("don't know how to convert input '%s' to a URL", attrsToJSON(input.attrs));
Expand Down
1 change: 1 addition & 0 deletions src/libfetchers/fetchers.hh
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public:
std::optional<Hash> getRev() const;
std::optional<uint64_t> getRevCount() const;
std::optional<time_t> getLastModified() const;
std::optional<std::string> getModules() const;
};


Expand Down

0 comments on commit c2cde79

Please sign in to comment.