Skip to content

Simplify ContentAddress#8650

Merged
edolstra merged 1 commit intoNixOS:masterfrom
obsidiansystems:content-address-simpler
Jul 21, 2023
Merged

Simplify ContentAddress#8650
edolstra merged 1 commit intoNixOS:masterfrom
obsidiansystems:content-address-simpler

Conversation

@Ericson2314
Copy link
Member

Motivation

Whereas ContentAddressWithReferences is a sum type complex because different varieties support different notions of reference, and ContentAddressMethod is a nested enum to support that, ContentAddress can be a simple pair of a method and hash.

ContentAddress does not need to be a sum type on the outside because the choice of method doesn't effect what type of hashes we can use.

Context

#3746 and #3959 got the data types in their current form, but I did not notice that this simplification became possible.

@amjoseph-nixpkgs in #3959 (comment) raised the goal of flattening the content address data types / making text less "the odd one out". I agree, and this gets us closer.

Checklist for maintainers

Maintainers: tick if completed or explain if not relevant

  • agreed on idea
  • agreed on implementation strategy
  • tests, as appropriate
    • functional tests - tests/**.sh
    • unit tests - src/*/tests
    • integration tests - tests/nixos/*
  • documentation in the manual
  • documentation in the internal API docs
  • code and comments are self-explanatory
  • commit message explains why the change was made
  • new feature or incompatible change: updated release notes

Priorities

Add 👍 to pull requests you find important.

@Ericson2314 Ericson2314 marked this pull request as ready for review July 5, 2023 23:08
@github-actions github-actions bot added new-cli Relating to the "nix" command store Issues and pull requests concerning the Nix store fetching Networking with the outside (non-Nix) world, input locking tests labels Jul 5, 2023
Whereas `ContentAddressWithReferences` is a sum type complex because different
varieties support different notions of reference, and
`ContentAddressMethod` is a nested enum to support that,
`ContentAddress` can be a simple pair of a method and hash.

`ContentAddress` does not need to be a sum type on the outside because
the choice of method doesn't effect what type of hashes we can use.

Co-Authored-By: Cale Gibbard <cgibbard@gmail.com>
@Ericson2314 Ericson2314 force-pushed the content-address-simpler branch from 5ab2afe to 903700c Compare July 7, 2023 11:30
@Ericson2314 Ericson2314 added the contributor-experience Developer experience for Nix contributors label Jul 9, 2023
Comment on lines -1859 to +1858
FixedOutputHash LocalStore::hashCAPath(
const FileIngestionMethod & method, const HashType & hashType,
ContentAddress LocalStore::hashCAPath(
const ContentAddressMethod & method, const HashType & hashType,
const StorePath & path)
{
return hashCAPath(method, hashType, Store::toRealPath(path), path.hashPart());
}

FixedOutputHash LocalStore::hashCAPath(
const FileIngestionMethod & method,
ContentAddress LocalStore::hashCAPath(
const ContentAddressMethod & method,
Copy link
Member Author

@Ericson2314 Ericson2314 Jul 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These I just generalized to not use the deleted type. And this gets us closer in fact to being able to deduplicate this with some build/local-derivation-goal.cc stuff later.

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2023-07-10-nix-team-meeting-minutes-70/30471/1

@edolstra edolstra merged commit 7ac24d9 into NixOS:master Jul 21, 2023
@Ericson2314 Ericson2314 deleted the content-address-simpler branch July 21, 2023 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor-experience Developer experience for Nix contributors fetching Networking with the outside (non-Nix) world, input locking new-cli Relating to the "nix" command store Issues and pull requests concerning the Nix store tests

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants