-
Notifications
You must be signed in to change notification settings - Fork 25
Implement 'addToStore' #53
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,8 @@ module System.Nix.Nar ( | |
| , Nar(..) | ||
| , getNar | ||
| , localPackNar | ||
| , localPackNar' | ||
| , FilePathFilter | ||
| , localUnpackNar | ||
| , narEffectsIO | ||
| , putNar | ||
|
|
@@ -240,10 +242,15 @@ localUnpackNar effs basePath (Nar fso) = localUnpackFSO basePath fso | |
|
|
||
| -- | Pack a NAR from a filepath | ||
| localPackNar :: Monad m => NarEffects m -> FilePath -> m Nar | ||
| localPackNar effs basePath = Nar <$> localPackFSO basePath | ||
| localPackNar effs basePath = localPackNar' effs basePath (const True) | ||
|
|
||
| where | ||
| type FilePathFilter = FilePath -> Bool | ||
|
|
||
| -- | Pack a NAR from a filepath, omitting the entries matching `filter` | ||
| localPackNar' :: Monad m => NarEffects m -> FilePath -> FilePathFilter -> m Nar | ||
| localPackNar' effs basePath pathFilter = Nar <$> localPackFSO basePath | ||
|
|
||
| where | ||
| localPackFSO path' = do | ||
| fType <- (,) <$> narIsDir effs path' <*> narIsSymLink effs path' | ||
| case fType of | ||
|
|
@@ -252,7 +259,7 @@ localPackNar effs basePath = Nar <$> localPackFSO basePath | |
| <*> narFileSize effs path' | ||
| <*> narReadFile effs path' | ||
| (True , _) -> fmap (Directory . Map.fromList) $ do | ||
| fs <- narListDir effs path' | ||
| fs <- filter (pathFilter . (path' </>)) <$> narListDir effs path' | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, I was not sure myself while wirting it, hence this confusion. But we have to scrape this whole implementation as the only filter that we want to use is a nix function, and hence wrapped in a MonadNix monad. This implementation cannot be used at all from what I have found. |
||
| forM fs $ \fp -> | ||
| (FilePathPart (BSC.pack $ fp),) <$> localPackFSO (path' </> fp) | ||
|
|
||
|
|
||
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.
This is just a matter of style, so feel free to ignore it! But, why add a type alias? I like to use them sparingly, since they are another thing for API users to have to learn, and they can pile up over time.
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.
Yep, style has definitely been overlooked while writing this. I wanted to achieve a minimal prototype while ignoring everything else. I would dare say this PR is not for merging, more for sharing ideas and POC implementation. Hopefully it will trigger some more progress HNix.