-
Notifications
You must be signed in to change notification settings - Fork 19
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
Support relocated store; lightweight store module #82
Support relocated store; lightweight store module #82
Conversation
... when configured with the NIX_STORE_DIR and NIX_REMOTE environment variables.
14fe802
to
41a6ce9
Compare
src/Nix/Diff.hs
Outdated
let string = path | ||
text <- liftIO (readFileUtf8Lenient string) | ||
case Data.Attoparsec.Text.parse Nix.Derivation.parseDerivation text of | ||
let parser = Nix.Derivation.parseDerivationWith (StorePath <$> filepathParser) Nix.Derivation.textParser |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor suggestion: maybe have filepathParser
return a StorePath
(an rename it to storepathParser
src/Nix/Diff/Store.hs
Outdated
stripSlash :: FilePath -> FilePath | ||
stripSlash = reverse . dropWhile (== '/') . reverse | ||
|
||
replaceStart :: String -> String -> String -> String | ||
replaceStart pattern replacement text = | ||
case L.stripPrefix pattern text of | ||
Just rest -> replacement <> rest | ||
Nothing -> text |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both of these operations will simpler and more efficient if you convert to Text
(and then back to FilePath
when you're done).
Support relocated store when configured with the
NIX_STORE_DIR
andNIX_REMOTE
environment variables.This allows
nix-diff
to be used in the sandbox with instantiations in a store whose physical location is in the build directory rather than the logicalstoreDir
(/nix/store
).This is achieved by changing introducing a
newtype StorePath
to help distinguish paths that may be logical paths rather than physical ones.It is not a true abstraction in the sense that Nix's own store concept is, but that's ok. It makes this use case work, while still only relying on the ambient environment, requiring no types and variables for the store itself.
I plan to use this functionality for error reporting in evaluation tests that evaluate Nixpkgs for the purpose of testing Nix itself, in the context of Nixpkgs "passthru" tests and Nix's own CI setup.