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

Purix fails to read lockfile #110

Closed
williamyaoh opened this issue Jan 5, 2025 · 3 comments
Closed

Purix fails to read lockfile #110

williamyaoh opened this issue Jan 5, 2025 · 3 comments

Comments

@williamyaoh
Copy link
Contributor

williamyaoh commented Jan 5, 2025

Attempting to build the Purescript dependencies of a project in Nix using Purix fails when reading the spago.lock file. The issue seems to be that since purescript/spago#1280, recent versions of Spago write the lockfile as JSON instead of YAML; Purix then fails inside its fromYaml utility.

Big ol stack trace from a `nix build`
       … from call site
         at /nix/store/frvg258rdvg9xs6d70vsax5q53mj2bny-source/frontend/client/purix-test.nix:9:18:
            8|   let npmDependencies = slimlock.buildPackageLock { src = ./.; };
            9|       packages = purix.buildSpagoLock {
             |                  ^
           10|         src = ./.;

       … while calling 'buildSpagoLock'
         at /nix/store/7jj6mx9ldjk1ybiyxa7gih9bc13kfw9b-source/nix/build-spago-lock.nix:298:20:
          297|
          298|   buildSpagoLock = {
             |                    ^
          299|     src,

       … from call site
         at /nix/store/7jj6mx9ldjk1ybiyxa7gih9bc13kfw9b-source/nix/build-spago-lock.nix:317:5:
          316|   in
          317|     fixDependencies {inherit purs corefn;}
             |     ^
          318|     (lockedPackages filteredSrc lock // workspacePackages filteredSrc extraSrcs lock);

       … while calling 'fixDependencies'
         at /nix/store/7jj6mx9ldjk1ybiyxa7gih9bc13kfw9b-source/nix/build-spago-lock.nix:167:6:
          166|     corefn,
          167|   }: deps:
             |      ^
          168|     lib.fix (self:

       … from call site
         at /nix/store/7jj6mx9ldjk1ybiyxa7gih9bc13kfw9b-source/nix/build-spago-lock.nix:168:5:
          167|   }: deps:
          168|     lib.fix (self:
             |     ^
          169|       lib.mapAttrs (name: drv: let

       … while calling 'fix'
         at /nix/store/ndliyv9wgywibbj3wyqiwwx4i7snzyxb-source/lib/fixed-points.nix:93:5:
           92|   fix =
           93|     f:
             |     ^
           94|     let

       … from call site
         at /nix/store/ndliyv9wgywibbj3wyqiwwx4i7snzyxb-source/lib/fixed-points.nix:95:11:
           94|     let
           95|       x = f x;
             |           ^
           96|     in

       … while calling anonymous lambda
         at /nix/store/7jj6mx9ldjk1ybiyxa7gih9bc13kfw9b-source/nix/build-spago-lock.nix:168:14:
          167|   }: deps:
          168|     lib.fix (self:
             |              ^
          169|       lib.mapAttrs (name: drv: let

       … while calling the 'mapAttrs' builtin
         at /nix/store/7jj6mx9ldjk1ybiyxa7gih9bc13kfw9b-source/nix/build-spago-lock.nix:169:7:
          168|     lib.fix (self:
          169|       lib.mapAttrs (name: drv: let
             |       ^
          170|         get-dep = dep: self.${dep};

       … in the left operand of the update (//) operator
         at /nix/store/7jj6mx9ldjk1ybiyxa7gih9bc13kfw9b-source/nix/build-spago-lock.nix:318:38:
          317|     fixDependencies {inherit purs corefn;}
          318|     (lockedPackages filteredSrc lock // workspacePackages filteredSrc extraSrcs lock);
             |                                      ^
          319| }

       … from call site
         at /nix/store/7jj6mx9ldjk1ybiyxa7gih9bc13kfw9b-source/nix/build-spago-lock.nix:318:6:
          317|     fixDependencies {inherit purs corefn;}
          318|     (lockedPackages filteredSrc lock // workspacePackages filteredSrc extraSrcs lock);
             |      ^
          319| }

       … while calling 'lockedPackages'
         at /nix/store/7jj6mx9ldjk1ybiyxa7gih9bc13kfw9b-source/nix/build-spago-lock.nix:97:25:
           96|   # Read all the locked packages
           97|   lockedPackages = src: lock:
             |                         ^
           98|     lib.mapAttrs (readLockedPackage src) lock.packages;

       … while calling the 'mapAttrs' builtin
         at /nix/store/7jj6mx9ldjk1ybiyxa7gih9bc13kfw9b-source/nix/build-spago-lock.nix:98:5:
           97|   lockedPackages = src: lock:
           98|     lib.mapAttrs (readLockedPackage src) lock.packages;
             |     ^
           99|

       … from call site
         at /nix/store/7jj6mx9ldjk1ybiyxa7gih9bc13kfw9b-source/nix/build-spago-lock.nix:309:12:
          308|   }: let
          309|     lock = readSpagoLock lockfile;
             |            ^
          310|     workspaceDirs = builtins.attrValues (lib.mapAttrs (_: attr: attr.path) lock.workspace.packages);

       … while calling 'readSpagoLock'
         at /nix/store/7jj6mx9ldjk1ybiyxa7gih9bc13kfw9b-source/nix/build-spago-lock.nix:20:19:
           19|   # Read the Spago lock file
           20|   readSpagoLock = lockfile: fromYAML (builtins.readFile lockfile);
             |                   ^
           21|

       … while calling a functor (an attribute set with a '__functor' attribute)
         at /nix/store/7jj6mx9ldjk1ybiyxa7gih9bc13kfw9b-source/nix/build-spago-lock.nix:20:29:
           19|   # Read the Spago lock file
           20|   readSpagoLock = lockfile: fromYAML (builtins.readFile lockfile);
             |                             ^
           21|

       … from call site
         at /nix/store/ndliyv9wgywibbj3wyqiwwx4i7snzyxb-source/lib/trivial.nix:1000:7:
          999|     { # TODO: Should we add call-time "type" checking like built in?
         1000|       __functor = self: f;
             |       ^
         1001|       __functionArgs = args;

       … while calling 'fromYAML'
         at /nix/store/7jj6mx9ldjk1ybiyxa7gih9bc13kfw9b-source/nix/from-yaml.nix:8:14:
            7| {lib}: let
            8|   fromYAML = text: let
             |              ^
            9|     lines = lib.splitString "\n" text;

       … from call site
         at /nix/store/7jj6mx9ldjk1ybiyxa7gih9bc13kfw9b-source/nix/from-yaml.nix:205:5:
          204|   in
          205|     processLines filtered (-1);
             |     ^
          206| in

       … while calling 'processLines'
         at /nix/store/7jj6mx9ldjk1ybiyxa7gih9bc13kfw9b-source/nix/from-yaml.nix:95:27:
           94|     #  children, and the the type of the children's structure.
           95|     processLines = lines: index: let
             |                           ^
           96|       line = builtins.elemAt filtered index;

       … from call site
         at /nix/store/7jj6mx9ldjk1ybiyxa7gih9bc13kfw9b-source/nix/from-yaml.nix:141:9:
          140|       childrenMerged =
          141|         lib.foldl (all: currentObject: (
             |         ^
          142|           if builtins.isAttrs currentObject

       … while calling 'foldl'
         at /nix/store/ndliyv9wgywibbj3wyqiwwx4i7snzyxb-source/lib/lists.nix:178:20:
          177|   */
          178|   foldl = op: nul: list:
             |                    ^
          179|     let

       … from call site
         at /nix/store/ndliyv9wgywibbj3wyqiwwx4i7snzyxb-source/lib/lists.nix:184:8:
          183|         else op (foldl' (n - 1)) (elemAt list n);
          184|     in foldl' (length list - 1);
             |        ^
          185|

       … while calling 'foldl''
         at /nix/store/ndliyv9wgywibbj3wyqiwwx4i7snzyxb-source/lib/lists.nix:180:16:
          179|     let
          180|       foldl' = n:
             |                ^
          181|         if n == -1

       … while evaluating a branch condition
         at /nix/store/ndliyv9wgywibbj3wyqiwwx4i7snzyxb-source/lib/lists.nix:181:9:
          180|       foldl' = n:
          181|         if n == -1
             |         ^
          182|         then nul

       … while calling the 'sub' builtin
         at /nix/store/ndliyv9wgywibbj3wyqiwwx4i7snzyxb-source/lib/lists.nix:184:28:
          183|         else op (foldl' (n - 1)) (elemAt list n);
          184|     in foldl' (length list - 1);
             |                            ^
          185|

       … while calling the 'length' builtin
         at /nix/store/ndliyv9wgywibbj3wyqiwwx4i7snzyxb-source/lib/lists.nix:184:16:
          183|         else op (foldl' (n - 1)) (elemAt list n);
          184|     in foldl' (length list - 1);
             |                ^
          185|

       … while calling the 'map' builtin
         at /nix/store/7jj6mx9ldjk1ybiyxa7gih9bc13kfw9b-source/nix/from-yaml.nix:138:22:
          137|
          138|       childObjects = builtins.map (processLines lines) childIndices;
             |                      ^
          139|

       … while evaluating a branch condition
         at /nix/store/7jj6mx9ldjk1ybiyxa7gih9bc13kfw9b-source/nix/from-yaml.nix:134:9:
          133|       childIndices =
          134|         if childIndent == null
             |         ^
          135|         then []

       … while evaluating a branch condition
         at /nix/store/7jj6mx9ldjk1ybiyxa7gih9bc13kfw9b-source/nix/from-yaml.nix:129:9:
          128|       childIndent =
          129|         if nextMatch.indent > indent
             |         ^
          130|         then nextMatch.indent

       … while calling the 'lessThan' builtin
         at /nix/store/7jj6mx9ldjk1ybiyxa7gih9bc13kfw9b-source/nix/from-yaml.nix:129:29:
          128|       childIndent =
          129|         if nextMatch.indent > indent
             |                             ^
          130|         then nextMatch.indent

       … while selecting an attribute
         at /nix/store/7jj6mx9ldjk1ybiyxa7gih9bc13kfw9b-source/nix/from-yaml.nix:129:12:
          128|       childIndent =
          129|         if nextMatch.indent > indent
             |            ^
          130|         then nextMatch.indent

       error: expected a set but found null: null
@thomashoneyman
Copy link
Owner

@williamyaoh does https://github.com/jeslie0/mkSpagoDerivation work for you? I haven’t updated purix in some time and may end up deprecating it in favor of @jeslie0’s work

@williamyaoh
Copy link
Contributor Author

That works, yeah!

Would you accept a PR to add that recommendation to the README?

For anyone else who stumbles on this: I was upgrading a project that was using easy-purescript-nix with the legacy version of Spago to build under Nix, to now use purescript-overlay. I was able to get it bundling again using mkSpagoDerivation to handle pulling the Purescript dependencies, and node2nix to fetch the node_modules.

@thomashoneyman
Copy link
Owner

Sure, we can do that.

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

No branches or pull requests

2 participants