Skip to content
This repository has been archived by the owner on Dec 10, 2022. It is now read-only.

try supporting local tarballs #6

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

ParetoOptimalDev
Copy link

@ParetoOptimalDev ParetoOptimalDev commented Sep 13, 2022

I came across input-output-hk/haskell.nix#1550 today and it said haskell-nix-extra-hackage supports being able to add local tarballs somehow?

I tried that from main with this modification:

And got:

error: opening directory '/nix/store/lq5j79n24h01s9r4n5c9cl5yc703yg4l-source/amazonka-1.6.1.tar.gz': Not a directory

Browsing through the code, I see this package assumes the library is in a directory, not already a tarball.

This PR:

  • Allows using local tarballs that were already tarred up
  • Fixes parsing bugs when cabal files contain carriage returns

fails with:

```
$ nix build --show-trace
warning: Git tree '/home/cody/org-roam/data/8b/42ad14-944b-4c40-b083-3de8b2db86e8/haskell-nix-extra-hackage' is dirty
trace: haskell-project-plan-to-nix-pkgs: To make project.plan-nix for haskell-project a fixed-output derivation but not materialized, set `plan-sha256` to the output of the 'calculateMaterializedSha' script in 'passthru'.
trace: haskell-project-plan-to-nix-pkgs: To materialize project.plan-nix for haskell-project entirely, pass a writable path as the `materialized` argument and run the 'updateMaterialized' script in 'passthru'.
trace: untarring file: /nix/store/1fzb3r9cifq4vnqiscq5syn1ms5k5g7h-amazonka-1.6.1.tar.gz
error: builder for '/nix/store/vz0dzg2vg7lpq9qhc7kc2if5zgycbsj3-dot-cabal-_amazonka--hackage.haskell.org-at-2022-05-04T000000Z.drv' failed with exit code 1;
       last 1 log lines:
       > open: does not exist (No such file or directory)
       For full logs, run 'nix log /nix/store/vz0dzg2vg7lpq9qhc7kc2if5zgycbsj3-dot-cabal-_amazonka--hackage.haskell.org-at-2022-05-04T000000Z.drv'.
error: 1 dependencies of derivation '/nix/store/gb3lqf26bkgvysm3m375zr01wb7azm9x-dot-cabal-_amazonka--hackage.haskell.org-at-2022-05-04T000000Z.drv' failed to build
error: 1 dependencies of derivation '/nix/store/9sk1c16yrz98vy5kl7lcwq7d5kgqpacj-haskell-project-plan-to-nix-pkgs.drv' failed to build

       … while realising the context of path '/nix/store/lxyaigcc85cpvqzm1qi9d5qnl34a0w8k-haskell-project-plan-to-nix-pkgs'

       at /nix/store/5c3r0m8x3z9d1lfw3lh8nx1lbvvna03b-source/lib/import-and-filter-project.nix:18:13:

           17|   projectSubDir'' = if projectSubDir == "" then "" else projectSubDir + "/"; # With trailing /
           18|   project = import "${projectNix}${projectSubDir'}";
             |             ^
           19| in project // {

       … while evaluating anonymous lambda

       at /nix/store/5c3r0m8x3z9d1lfw3lh8nx1lbvvna03b-source/lib/import-and-filter-project.nix:5:1:

            4| { pkgs, haskellLib }:
            5| { projectNix, sourceRepos, src }:
             | ^
            6| let

       … from call site

       at /nix/store/5c3r0m8x3z9d1lfw3lh8nx1lbvvna03b-source/overlays/haskell.nix:513:27:

          512|               callProjectResults = callCabalProjectToNix args;
          513|               plan-pkgs = importAndFilterProject {
             |                           ^
          514|                 inherit (callProjectResults) projectNix sourceRepos src;

       … while evaluating the attribute 'hsPkgs'

       at /nix/store/5c3r0m8x3z9d1lfw3lh8nx1lbvvna03b-source/overlays/haskell.nix:539:43:

          538|               project = addProjectAndPackageAttrs rec {
          539|                   inherit (pkg-set.config) hsPkgs;
             |                                           ^
          540|                   inherit pkg-set;

       … while evaluating the attribute 'hsPkgs'

       at /nix/store/5c3r0m8x3z9d1lfw3lh8nx1lbvvna03b-source/overlays/haskell.nix:569:15:

          568|               # Haskell packages
          569|               hsPkgs = final.lib.mapAttrs (packageName: package':
             |               ^
          570|                 if package' == null

       … while evaluating 'filterAttrs'

       at /nix/store/l4ysisamwr0jdf6w2za4zygj9ajlf0wb-source/lib/attrsets.nix:224:23:

          223|   */
          224|   filterAttrs = pred: set:
             |                       ^
          225|     listToAttrs (concatMap (name: let v = set.${name}; in if pred name v then [(nameValuePair name v)] else []) (attrNames set));

       … from call site

       at /nix/store/5c3r0m8x3z9d1lfw3lh8nx1lbvvna03b-source/lib/default.nix:108:31:

          107|   isProjectPackage = p: p.isProject or false;
          108|   selectProjectPackages = ps: lib.filterAttrs (n: p: p != null && isLocalPackage p && isProjectPackage p) ps;
             |                               ^
          109|

       … while evaluating 'selectProjectPackages'

       at /nix/store/5c3r0m8x3z9d1lfw3lh8nx1lbvvna03b-source/lib/default.nix:108:27:

          107|   isProjectPackage = p: p.isProject or false;
          108|   selectProjectPackages = ps: lib.filterAttrs (n: p: p != null && isLocalPackage p && isProjectPackage p) ps;
             |                           ^
          109|

       … from call site

       at /nix/store/5c3r0m8x3z9d1lfw3lh8nx1lbvvna03b-source/overlays/haskell.nix:741:63:

          740|               }:
          741|               let packageNames = project: builtins.attrNames (packages project.hsPkgs);
             |                                                               ^
          742|                   packagesForProject = prefix: project:

       … while evaluating 'packageNames'

       at /nix/store/5c3r0m8x3z9d1lfw3lh8nx1lbvvna03b-source/overlays/haskell.nix:741:34:

          740|               }:
          741|               let packageNames = project: builtins.attrNames (packages project.hsPkgs);
             |                                  ^
          742|                   packagesForProject = prefix: project:

       … from call site

       at /nix/store/5c3r0m8x3z9d1lfw3lh8nx1lbvvna03b-source/overlays/haskell.nix:759:24:

          758|                           (package.components.benchmarks)
          759|                     ) (packageNames project);
             |                        ^
          760|                   checksForProject = prefix: project:

       … while evaluating 'packagesForProject'

       at /nix/store/5c3r0m8x3z9d1lfw3lh8nx1lbvvna03b-source/overlays/haskell.nix:742:48:

          741|               let packageNames = project: builtins.attrNames (packages project.hsPkgs);
          742|                   packagesForProject = prefix: project:
             |                                                ^
          743|                     final.lib.concatMap (packageName:

       … from call site

       at /nix/store/5c3r0m8x3z9d1lfw3lh8nx1lbvvna03b-source/overlays/haskell.nix:778:21:

          777|                 attrsForAllProjects = f: builtins.listToAttrs (
          778|                     f "" project
             |                     ^
          779|                   ++ final.lib.concatMap (project:

       … while evaluating 'attrsForAllProjects'

       at /nix/store/5c3r0m8x3z9d1lfw3lh8nx1lbvvna03b-source/overlays/haskell.nix:777:39:

          776|                     ) (packageNames project);
          777|                 attrsForAllProjects = f: builtins.listToAttrs (
             |                                       ^
          778|                     f "" project

       … from call site

       at /nix/store/5c3r0m8x3z9d1lfw3lh8nx1lbvvna03b-source/overlays/haskell.nix:789:28:

          788|                 #   `nix build .#pkg-name:test:test-name`
          789|                 packages = attrsForAllProjects packagesForProject;
             |                            ^
          790|                 # Used by:

       … while evaluating the attribute 'packages."myapp:exe:myapp"'

       at /nix/store/5c3r0m8x3z9d1lfw3lh8nx1lbvvna03b-source/overlays/haskell.nix:789:17:

          788|                 #   `nix build .#pkg-name:test:test-name`
          789|                 packages = attrsForAllProjects packagesForProject;
             |                 ^
          790|                 # Used by:
```
@ParetoOptimalDev
Copy link
Author

This was broken because that package had \r\n and the package name was parsed wrong as amazonka\r.

Now it seems to be working.

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

Successfully merging this pull request may close these issues.

1 participant