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

Lockfile 6.0 #26

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.PHONY: all test

test:
nix-shell -p nixUnstable --run "nix-build --no-out-link ./tests/default.nix --show-trace"
nix-build --no-out-link ./tests/default.nix --show-trace

all: test
6 changes: 3 additions & 3 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ pkgs ? import <nixpkgs> {}
, nodejs ? pkgs.nodejs-8_x
, nodePackages ? pkgs.nodePackages_8_x
, nodejs ? pkgs.nodejs
, nodePackages ? pkgs.nodePackages
, node-gyp ? nodePackages.node-gyp
} @modArgs:

Expand Down Expand Up @@ -198,7 +198,7 @@ in {
};

in
assert (pnpmlock.lockfileVersion == 5 || pnpmlock.lockfileVersion == 5.1);
assert pnpmlock.lockfileVersion == "6.0";
(mkPnpmDerivation {
deps = (builtins.map
(attrName: packages."${attrName}")
Expand Down
4 changes: 2 additions & 2 deletions derivation.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ pkgs ? import <nixpkgs> {}
, nodejs ? pkgs.nodejs-8_x
, nodePackages ? pkgs.nodePackages_8_x
, nodejs ? pkgs.nodejs
, nodePackages ? pkgs.nodePackages
, node-gyp ? nodePackages.node-gyp
}:

Expand Down
7 changes: 2 additions & 5 deletions link-bin-outputs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
import itertools
import argparse
import os.path
Expand All @@ -21,7 +21,7 @@ def get_bin_attr_files(package_json):
except KeyError:
return tuple()
else:
if isinstance(bins, basestring):
if isinstance(bins, str):
return ((package_json['name'], bins),)
else:
return bins.items()
Expand Down Expand Up @@ -56,9 +56,6 @@ def resolve_bin_outputs(bin_out, lib_out, entries):
get_bin_attr_files(package_json),
get_directories_bin_attr_files(args.lib_out, package_json))):

fin = fin.encode("utf-8");
fout = fout.encode("utf-8");

os.symlink(fin, fout)
os.chmod(fout, 0o755)

Expand Down
10 changes: 5 additions & 5 deletions pnpmlock.nix
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ let
injectNameVersionAttrs = packageSet: let

getDrvVersionAttr = pkgAttr: (lib.elemAt
(builtins.match ".*/([0-9][A-Za-z\.0-9\.\-]+).*" pkgAttr) 0);
(builtins.match "[^(]*@([0-9][A-Za-z\.0-9\.\-]+).*" pkgAttr) 0);

addAttrs = (acc: pkgAttr: acc // (let
pkg = acc."${pkgAttr}";
in {
"${pkgAttr}" = (pkg // rec {
rawPname = lib.elemAt (builtins.match "/?(.+)/[0-9].*" pkgAttr) 0;
rawPname = lib.elemAt (builtins.match "/?([^(]+)@[0-9].*" pkgAttr) 0;
pname = if (lib.hasAttr "name" pkg)
then pkg.name
else rawPname;
Expand Down Expand Up @@ -131,7 +131,7 @@ let

# Find the attribute name for a pnpmlock package
findAttrName = attrSet: depName: depVersion: let
slashed = "/${depName}/${depVersion}";
slashed = "/${depName}@${depVersion}";
in if (lib.hasAttr slashed attrSet) then slashed else depVersion;

# Resolve dependencies to pnpmlock attribute names
Expand Down Expand Up @@ -177,8 +177,8 @@ let
attrSet = if (lib.hasAttr attr pnpmlock && pnpmlock."${attr}" != null)
then pnpmlock."${attr}"
else {};
in lib.mapAttrsToList (depName: depVersion:
(findAttrName packageSet depName depVersion)) attrSet;
in lib.mapAttrsToList (depName: dep:
(findAttrName packageSet depName dep.version)) attrSet;

in pnpmlock // {
dependencies = rewriteAttrs "dependencies";
Expand Down
3 changes: 1 addition & 2 deletions semver.nix
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,9 @@ let
operators."${ops.t}" version v;

satisfies = version: constraint:
# TODO: use a regex for the split
builtins.length (
builtins.filter (c: satisfiesSingle version c)
(lib.splitString " || " constraint)
(builtins.filter builtins.isString (builtins.split " *\\|\\| *" constraint))
) > 0;
in
{ inherit satisfies; }
8 changes: 4 additions & 4 deletions tests/default.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
with (import ((import <nixpkgs> {}).fetchFromGitHub {
repo = "nixpkgs-channels";
repo = "nixpkgs";
owner = "NixOS";
sha256 = "1bjq5gl08pni6q2nqv9w98ym3kybzf7qc6cx4js0388vg8zfgf2k";
rev = "49a16a290e68ebb1ef5acadf25cf149d0d530d05";
sha256 = "sha256-IiJ0WWW6OcCrVFl1ijE+gTaP0ChFfV6dNkJR05yStmw=";
rev = "eb751d65225ec53de9cf3d88acbf08d275882389";
}) { });
with lib.attrsets;
with lib;
Expand Down Expand Up @@ -58,7 +58,7 @@ lib.listToAttrs (map (drv: nameValuePair drv.name drv) [
(mkTest "impure" "${test-impure}/bin/testapn")

(mkTest "python-lint" ''
echo ${(python2.withPackages (ps: [ ps.flake8 ]))}/bin/flake8 ${pnpm2nix}/
echo ${(python3.withPackages (ps: [ ps.flake8 ]))}/bin/flake8 ${pnpm2nix}/
'')

# Check if nested directory structures work properly
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions tests/file-dependencies/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading