Skip to content

Commit 6dc8b18

Browse files
committed
hack: fix new prisma commit parsing failure
1 parent 54b13e3 commit 6dc8b18

File tree

2 files changed

+74
-76
lines changed

2 files changed

+74
-76
lines changed

flake.nix

Lines changed: 43 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -5,39 +5,35 @@
55
treefmt-nix.url = "github:numtide/treefmt-nix";
66
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
77
};
8-
outputs =
9-
{
10-
self,
11-
nixpkgs,
12-
flake-utils,
13-
treefmt-nix,
14-
}:
15-
let
16-
prisma-factory = import ./prisma.nix;
17-
in
8+
outputs = {
9+
self,
10+
nixpkgs,
11+
flake-utils,
12+
treefmt-nix,
13+
}: let
14+
prisma-factory = import ./prisma.nix;
15+
in
1816
flake-utils.lib.eachDefaultSystem (
19-
system:
20-
let
17+
system: let
2118
pkgs = nixpkgs.legacyPackages.${system};
2219

2320
yarn-v1 = pkgs.writeShellApplication {
2421
name = "yarn-v1";
2522
checkPhase = "";
26-
runtimeInputs = [ pkgs.yarn ];
23+
runtimeInputs = [pkgs.yarn];
2724
text = "yarn $@";
2825
};
2926
yarn-berry = pkgs.writeShellApplication {
3027
name = "yarn-berry";
3128
checkPhase = "";
32-
runtimeInputs = [ pkgs.yarn-berry ];
29+
runtimeInputs = [pkgs.yarn-berry];
3330
text = "yarn $@";
3431
};
3532
treefmt = treefmt-nix.lib.evalModule pkgs {
3633
# nixfmt is nixfmt-rfc-style
3734
programs.nixfmt.enable = true;
3835
};
39-
in
40-
{
36+
in {
4137
formatter = treefmt.config.build.wrapper;
4238
checks =
4339
(pkgs.callPackages ./tests.nix {
@@ -60,46 +56,47 @@
6056
})
6157
// {
6258
format = treefmt.config.build.check self;
63-
fetcher-assert-npm =
64-
let
65-
# force download debian for consistent hash across systems
66-
binaryTargetBySystem = {
67-
x86_64-linux = "debian";
68-
aarch64-linux = "debian";
69-
x86_64-darwin = "debian";
70-
aarch64-darwin = "debian";
71-
};
72-
prisma-legacy = prisma-factory {
59+
fetcher-assert-npm = let
60+
# force download debian for consistent hash across systems
61+
binaryTargetBySystem = {
62+
x86_64-linux = "debian";
63+
aarch64-linux = "debian";
64+
x86_64-darwin = "debian";
65+
aarch64-darwin = "debian";
66+
};
67+
prisma-legacy = prisma-factory {
68+
inherit pkgs binaryTargetBySystem;
69+
hash = "sha256-R9PG286KQTbzF0r/PPcShUkMiYam2prRh/JICjmhCZA=";
70+
};
71+
prisma-new = lockName: lockFile:
72+
prisma-factory {
7373
inherit pkgs binaryTargetBySystem;
7474
hash = "sha256-R9PG286KQTbzF0r/PPcShUkMiYam2prRh/JICjmhCZA=";
75+
${lockName} = lockFile;
7576
};
76-
prisma-new =
77-
lockName: lockFile:
78-
prisma-factory {
79-
inherit pkgs binaryTargetBySystem;
80-
hash = "sha256-R9PG286KQTbzF0r/PPcShUkMiYam2prRh/JICjmhCZA=";
81-
${lockName} = lockFile;
82-
};
83-
in
84-
assert
85-
(prisma-legacy.fromNpmLock ./npm/package-lock.json).env
86-
== (prisma-new "npmLock" ./npm/package-lock.json).env;
87-
pkgs.hello;
77+
in
78+
assert (prisma-legacy.fromNpmLock ./npm/package-lock.json).env
79+
== (prisma-new "npmLock" ./npm/package-lock.json).env;
80+
pkgs.hello;
81+
prisma-next =
82+
(self.lib.prisma-factory {
83+
inherit pkgs;
84+
_commit = "next-0c19ccc313cf9911a90d99d2ac2eb0280c76c513";
85+
}).package;
8886
};
8987
packages.default =
9088
(prisma-factory {
9189
inherit pkgs;
9290
hash = "sha256-R9PG286KQTbzF0r/PPcShUkMiYam2prRh/JICjmhCZA=";
9391
_commit = "6a3747c37ff169c90047725a05a6ef02e32ac97e";
9492
}).package;
95-
devShells.default =
96-
let
97-
prisma = prisma-factory {
98-
inherit pkgs;
99-
hash = "sha256-R9PG286KQTbzF0r/PPcShUkMiYam2prRh/JICjmhCZA=";
100-
_commit = "6a3747c37ff169c90047725a05a6ef02e32ac97e";
101-
};
102-
in
93+
devShells.default = let
94+
prisma = prisma-factory {
95+
inherit pkgs;
96+
hash = "sha256-R9PG286KQTbzF0r/PPcShUkMiYam2prRh/JICjmhCZA=";
97+
_commit = "6a3747c37ff169c90047725a05a6ef02e32ac97e";
98+
};
99+
in
103100
pkgs.mkShell {
104101
buildInputs = [
105102
pkgs.nodejs-18_x

prisma.nix

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,18 @@
2525
x86_64-darwin = "darwin";
2626
aarch64-darwin = "darwin-arm64";
2727
},
28-
}:
29-
let
28+
}: let
3029
inherit (pkgs) lib;
31-
parsers = pkgs.callPackage ./lib/parsers.nix { };
30+
parsers = pkgs.callPackage ./lib/parsers.nix {};
3231
binaryTarget = binaryTargetBySystem.${pkgs.system};
33-
fromCommit =
34-
commit:
35-
if builtins.stringLength commit != 40 then
36-
throw "invalid commit: got ${commit}"
37-
else if hash != null then
32+
fromCommit = _commit: let
33+
# HACK: _commit may be "next-0c19ccc313cf9911a90d99d2ac2eb0280c76c513" instead of "0c19ccc313cf9911a90d99d2ac2eb0280c76c513"
34+
commit = lib.lists.last (lib.splitString "-" _commit);
35+
in
36+
if builtins.stringLength commit != 40
37+
then throw "invalid commit: got ${commit}"
38+
else if hash != null
39+
then
3840
pkgs.callPackage ./lib/fetcher.nix {
3941
inherit
4042
commit
@@ -66,33 +68,32 @@ let
6668
fromYarnLock = file: fromCommit (parsers.parseYarnLock file);
6769
fromBunLock = file: fromCommit (parsers.parseBunLock file);
6870
in
69-
lib.warnIf (nixpkgs != null)
71+
lib.warnIf (nixpkgs != null)
7072
''
7173
`nixpkgs` argument in nix-prisma-utils is deprecated. please replace it with `pkgs`.
7274
examples:
7375
if your code has `inherit nixpkgs;`, replace it with `pkgs = nixpkgs;`.
7476
if your code has `nixpkgs = pkgs;`, replace it with `pkgs = pkgs;` or `inherit pkgs;`.
7577
''
7678
(
77-
if _commit != null then
78-
fromCommit _commit
79-
else if npmLock != null then
80-
fromNpmLock npmLock
81-
else if yarnLock != null then
82-
fromYarnLock yarnLock
83-
else if pnpmLock != null then
84-
fromPnpmLock pnpmLock
85-
else if bunLock != null then
86-
fromBunLock bunLock
87-
else
88-
{
89-
# builder pattern
90-
inherit
91-
fromCommit
92-
fromNpmLock
93-
fromYarnLock
94-
fromPnpmLock
95-
fromBunLock
96-
;
97-
}
79+
if _commit != null
80+
then fromCommit _commit
81+
else if npmLock != null
82+
then fromNpmLock npmLock
83+
else if yarnLock != null
84+
then fromYarnLock yarnLock
85+
else if pnpmLock != null
86+
then fromPnpmLock pnpmLock
87+
else if bunLock != null
88+
then fromBunLock bunLock
89+
else {
90+
# builder pattern
91+
inherit
92+
fromCommit
93+
fromNpmLock
94+
fromYarnLock
95+
fromPnpmLock
96+
fromBunLock
97+
;
98+
}
9899
)

0 commit comments

Comments
 (0)