-
Notifications
You must be signed in to change notification settings - Fork 233
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
Expose srcSubDir and srcSubDirPath in the derivation #1077
Comments
I assume it is Could you make the files you need available to the component by adding a relative path to
This should make them available to all components in
That should result in |
Both haskell.nix/builder/comp-builder.nix Lines 291 to 292 in 96d7693
|
Oh! I see you want them as env vars when the builder runs. |
Have you tried:
|
Right, so we can use |
The paths in the libs/exes that were created by TH would still be pointing at |
Hmm this is also a problem with |
keepSource should use the haskell.nix/builder/comp-builder.nix Lines 339 to 343 in 4245567
|
There That is something we had to address in the I am not happy with that fix though because it has to remove all the paths that point to $out first (IIRC the cabal generated I also wonder if |
Oooh 👍 . I completely missed that change of directory before building. I'll give it a try! Thanks! |
It looks like we can't make |
Looks like maybe https://github.com/Simspace/haskell.nix/blob/9d63e57aba2ede9e80cfd7d25a4093785453c400/lib/check.nix#L33 should be
|
Oof patched that up and the next thing I'm running into is nix reporting a cycle.
Looks like this is because the library derivation output has a reference to the source output, and the source output contains a Update: I changed https://github.com/Simspace/haskell.nix/blob/9d63e57aba2ede9e80cfd7d25a4093785453c400/builder/comp-builder.nix#L459 to |
This was fixed in #427 (which I have just merged) by moving the |
Now I have merged #427 it might be better to change this bit... haskell.nix/builder/comp-builder.nix Lines 484 to 499 in 6c627b4
So that to |
Not entirely sure I follow. Do you mean that we should change that to something more like |
Yes, that was what I had in mind. I think it is reasonable that |
@hamishmack Opened up #1080. I've tested it out and with that change Thanks! |
Our project (over?)uses
file-path-th
to get paths to files, mostly in tests. It uses some template haskell to get absolute paths to files in the project at compile time. When used with stack and cabal, this is fine. With nix, this poses a problem, because the path that existed at compile time won't exist at runtime. In the past, I applied a patch tofile-path-th
to lookup thesrc
environment variable and use that instead of the current working directory of the build. That worked great.But we are trying to update the version of haskell.nix we're using and some of the restructuring has broken that method. Now, instead of component source being at
/nix/store/xxxxxxx-mypackage-lib-mycomponent
, it is instead at/nix/store/xxxxxxx-mypackage-lib-mycomponent/mycomponent
.I've come up with two approaches to solves this problem:
file-path-th
patch to find the subdirectory by finding the subdir that contains either apackage.yaml
file or a.cabal
file. This appears to work just fine, but it does incur a slight performance penalty at compile time that I'd like to avoid. This brings me to the reason for this request...srcSubDir
andsrcSubDirPath
(or, even just one of them), as I've done here https://github.com/Simspace/haskell.nix/commit/5c6363a32bbc23970bc1c583450333285ee3d2e7, then thefile-path-th
can be changed to use those and we avoid the need to search for the component directory.This is kind of a special case, which is why I'm opening an issue before a PR, to see if it would be generally acceptable or if there is another way I might be missing.
The text was updated successfully, but these errors were encountered: