IFD-embracing Nix expression to import pnpm-lock.yaml files in Nix derivations
nixpkgs nix flake pnpm
3
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: add lock file format assertions

This definitely works with lock file version 9.0. <9.0 has a different
format for the packages list, so it will need additional work, if there
is a need for it.

Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>

authored by

Sefa Eyeoglu and committed by tangled.org bc72e545 5f1ef2be

+21
+21
importPnpmLock.nix
··· 15 15 manualEntries ? { }, 16 16 }: 17 17 let 18 + supportedLockFileVersions = [ 19 + "9.0" 20 + ]; 21 + 18 22 importYAML = 19 23 file: 20 24 let ··· 63 67 lib.nameValuePair url { 64 68 hash = integrity; 65 69 }; 70 + 71 + lockFileVersion = data.lockfileVersion or null; 66 72 in 73 + assert lib.assertMsg (lockFileVersion != null) '' 74 + lockFile ${lockFile} does not look like a supported lock file. 75 + Unable to read lock file version. 76 + ''; 77 + assert lib.assertMsg (builtins.elem lockFileVersion supportedLockFileVersions) '' 78 + File ${lockFile} is not a supported lock file. 79 + 80 + Supported versions are ${lib.concatStrings supportedLockFileVersions} 81 + 82 + Found version ${lockFileVersion} 83 + ''; 84 + assert lib.assertMsg (data ? packages) '' 85 + File ${lockFile} does not contain a list of locked packages. 86 + Is it a valid lock file? 87 + ''; 67 88 mitm-cache.fetch { 68 89 name = "${pname}-pnpm-mitm-cache-${version}"; 69 90 data = lib.mapAttrs' mapPackageToMitmCacheEntry data.packages;