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

Use foreign haskell.nix project as dependency in local haskell.nix project #2151

Open
collinarnett opened this issue Jan 28, 2024 · 1 comment
Labels
bug Something isn't working wontfix

Comments

@collinarnett
Copy link

This template is a guide only, feel free add or omit sections as appropriate.

I have a haskell.nix overlay that I want to include as a dependency to another haskell.nix project. The reason I can't do this purely in cabal is because nix helps with bundling cuda so I want my current project to use the package from nix rather than trying to hit hackage.

Here is my fork of the package I want to consume in this minimal example.

Ideally I want to include both projects like this where haskell-skeleton finds it's dependencies via the hasktorch overlay:

          _module.args.pkgs = import inputs.nixpkgs {                                                                                                                                        
            inherit system;                                                                                                                                                                  
            config.cudaSupport = true;                                                                                                                                                       
            config.allowUnfree = true;                                                                                                                                                       
            overlays = [                                                                                                                                                                     
              haskell-nix.overlay                                                                                                                                                            
              tokenizers.overlay                                                                                                                                                             
              hasktorch.overlays.default                                                                                                                                                     
              (final: prev: {                                                                                                                                                                
                hasktorch-skeleton = final.haskell-nix.cabalProject' {                                                                                                                       
                  src = ./.;                                                                                                                                                                 
                  compiler-nix-name = "ghc924";                                                                                                                                              
                };                                                                                                                                                                           
              })                                                                                                                                                                             
            ];                                                                                                                                                                               
          }; 
          devShells.default = pkgs.hasktorch-skeleton.shellFor {                                                                                                                             
            exactDeps = true;                                                                                                                                                                
            tools = {                                                                                                                                                                        
              cabal = {};                                                                                                                                                                    
              haskell-language-server = {};                                                                                                                                                  
            };                                                                                                                                                                               
          }; 

However I get the following error once I enter the devshell and run cabal build.

Configuring library for libtorch-ffi-helper-1.11.0.0..
Preprocessing library for libtorch-ffi-helper-1.11.0.0..
Building library for libtorch-ffi-helper-1.11.0.0..
[1 of 2] Compiling GHC.NotExport.Plugin ( src/GHC/NotExport/Plugin.hs, dist/build/GHC/NotExport/Plugin.o, dist/build/GHC/NotExport/Plugin.dyn_o )
[2 of 2] Compiling Torch.Internal.Unmanaged.Helper ( src/Torch/Internal/Unmanaged/Helper.hs, dist/build/Torch/Internal/Unmanaged/Helper.o, dist/build/Torch/Internal/Unmanaged/Helper.dyn_o )
Installing library in /home/collin/.local/state/cabal/store/ghc-9.2.4/incoming/new-588851/home/collin/.local/state/cabal/store/ghc-9.2.4/libtorch-ffi-helper-1.11.0.0-8a62205e3db5600df6991b7110dc8b0b5f20d741bb4b5915ed045ef5d6c630c8/lib
Error: cabal: Failed to build libtorch-ffi-helper-1.11.0.0 (which is required
by hasktorch-skeleton-0.0.0.0). The failure occurred during the final install
step. The exception was:
/home/collin/.local/state/cabal/store/ghc-9.2.4/package.db/:
openBinaryTempFileWithDefaultPermissions: does not exist (No such file or
directory)

This seems to be cause by the same issue as here.
#1608

To avoid this error I tried making a minimal cabal.project file with no source-repository-package and this results in another error:

Warning: The package list for 'hackage.haskell.org' is 19750 days old.
Run 'cabal update' to get the latest list of available packages.
Resolving dependencies...
make-install-plan: dieVerbatim: user error (Error: make-install-plan: Could not resolve dependencies:
[__0] trying: hasktorch-skeleton-0.0.0.0 (user goal)
[__1] next goal: hasktorch (dependency of hasktorch-skeleton)
[__1] rejecting: hasktorch-0.0.1.0 (conflict: hasktorch-skeleton =>
hasktorch>=0.2 && <0.3)
[__1] fail (backjumping, conflict set: hasktorch, hasktorch-skeleton)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: hasktorch-skeleton, hasktorch
)

Here I would like to explicitly specify for the project to use hasktorch from nix in the modules section but I can't figure out how to do that.

@collinarnett collinarnett added the bug Something isn't working label Jan 28, 2024
Copy link

stale bot commented May 27, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working wontfix
Projects
None yet
Development

No branches or pull requests

1 participant