Skip to content

Purix fails to read lockfile #110

@williamyaoh

Description

@williamyaoh

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions