Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

addToStore to S3 and local binary cache #37

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

puffnfresh
Copy link
Member

No description provided.

@puffnfresh
Copy link
Member Author

puffnfresh commented Mar 11, 2019

Just verified that this is now producing the exact same .nar and .narinfo files! 🎆

store = localBinaryStoreEffects "/tmp/xxx/hnix"
addToStore "/nix/store" "shell.nix" "shell.nix" True store
$ nix copy --to file:///tmp/xxx/nix $(nix add-to-store shell.nix)
$ diff -r /tmp/xxx/hnix /tmp/xxx/nix
Only in /tmp/xxx/nix: nix-cache-info

@puffnfresh puffnfresh changed the title Initial work on S3 addToStore addToStore to S3 and local binary cache Mar 11, 2019
Copy link
Member

@shlevy shlevy left a comment

Choose a reason for hiding this comment

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

Same concern as #36 , haven't reviewed the rest yet.

, -- | The size of the nar the path, in bytes.
fileBytes :: !(Maybe Word64)
}

Copy link
Member

Choose a reason for hiding this comment

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

I've completely missed this and recently wrote/extracted from Cachix a lib - https://github.com/sorki/nix-narinfo which is hopefully polymorphic enough to accommodate our types.

:: StorePath storeDir
-> Text
narInfoFileFor p =
encodeBase32 (storePathHash p) <> ".narinfo"
Copy link
Member

Choose a reason for hiding this comment

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

This is now part of -cores System.Nix.StorePath called storePathToNarInfo.

-- | Encode a 'Digest' in algorithm:hash format.
encodeSomeDigest :: SomeNamedDigest -> Text
encodeSomeDigest (SomeDigest d) =
encodeDigest d
Copy link
Member

Choose a reason for hiding this comment

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

This is pending via #64.

case narHashMode of
Recursive -> ("source", h)
RegularFile -> ("output:out", hash ("fixed:out:" <> encodeUtf8 (encodeBase16 h) <> ":"))

Copy link
Member

Choose a reason for hiding this comment

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

This landed as part of #36.

encodeBase32 (storePathHash p) <> ".narinfo"

addToStore
:: forall storeDir m. (MonadIO m, KnownStoreDir storeDir)
Copy link
Member

Choose a reason for hiding this comment

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

As of #59 (1f86211) StorePath is no longer parametrized by KnownStoreDir storeDir, store root FilePath is part of storePathRoot of StorePath.

Suggested change
:: forall storeDir m. (MonadIO m, KnownStoreDir storeDir)
:: MonadIO m

-> FilePath
-> NarHashMode
-> BinaryStoreEffects m
-> m (StorePath storeDir)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
-> m (StorePath storeDir)
-> m StorePath

@sorki
Copy link
Member

sorki commented Jul 27, 2020

Looking good! Few things need to land and we can merge this. Your thoughts on effect systems and having GADT for ops like addToStore?

@Ericson2314
Copy link
Member

I would not bother with effect systems. Big waste of time.

@sorki
Copy link
Member

sorki commented Jul 27, 2020

I would not bother with effect systems. Big waste of time.

Care to elaborate on that?

I like how the effects compose compared to stack of transformers we use currently (mostly in hnix and hnix-store-remote) and came up with an hnix-store-polysemy experiment recently https://gist.github.com/sorki/10a035089e601045789357f37e7ab89c#file-a-hs-L32 that could be our high level effect, while parts of the store could be implemented in terms of effects again allowing for flexibility (e.g. running a store over TCP instead of socket, purely, local vs remote, s3..). We already have a home-brew effect system in both hnix and hnix-store so why not full blown effect system? (disregarding immaturity, which is gonna change when eff and related GHC proposal lands).

@shlevy shlevy removed their request for review October 13, 2022 12:02
@sorki
Copy link
Member

sorki commented Nov 19, 2023

I would like to salvage this, it bothers me it's sitting here for so long. Lots of pieces added here landed in core in some form.

Some random remarks, I won't add anymore inline comments as it makes the code hard to read:

import qualified System.Linux.Mount
import qualified System.Linux.Namespaces

makeStoreWriteable :: IO ()
makeStoreWriteable = do
  System.Linux.Namespaces.unshare [System.Linux.Namespaces.Mount]
  System.Linux.Mount.rebind "/nix/store" []

It actually doesn't seem that hard, I might try cleaning up the PR after I'm done with #233 #235 #238

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants