Skip to content

Commit 88dcffe

Browse files
Merge branch 'master' into trh/compilers-in-metadata
2 parents 67c7cb5 + 00000a7 commit 88dcffe

20 files changed

Lines changed: 3820 additions & 1997 deletions

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/node_modules
22
/output
3+
/output-es
34
/scratch
45
/.vscode
56

@@ -14,6 +15,7 @@ result
1415
*.sqlite3
1516
*.sqlite3-wal
1617
*.sqlite3-shm
18+
.spec-results
1719

1820
# Keep it secret, keep it safe.
1921
.env

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ nix flake check -L
7878
There is an integration test that will deploy the registry server and make requests to the API, which you can run if you are on a Linux machine. It is included in the `nix flake check` command by default, but it can be convenient to run standalone as well:
7979

8080
```sh
81-
nix build checks.x86_64-linux.integration
81+
nix build .#checks.x86_64-linux.integration
8282
```
8383

8484
You can "deploy" the registry server to a local VM and manually hit the API as if it were the production server:

app/default.nix

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
makeWrapper,
33
lib,
44
stdenv,
5-
purix,
6-
purs-backend-es,
5+
purs-backend-es-unstable,
76
esbuild,
87
writeText,
98
nodejs,
@@ -32,16 +31,27 @@ let
3231
"buildPhase"
3332
"installPhase"
3433
];
35-
nativeBuildInputs = [ purs-backend-es ];
34+
nativeBuildInputs = [ purs-backend-es-unstable ];
3635
buildPhase = ''
3736
ln -s ${package-lock}/js/node_modules .
38-
cp -r ${spago-lock.registry-app}/output .
37+
ln -s ${spago-lock}/output .
3938
echo "Optimizing with purs-backend-es..."
4039
purs-backend-es build
4140
'';
4241
installPhase = ''
43-
mkdir $out
44-
mv output-es $out/output
42+
mkdir $out;
43+
cp -r output-es $out/output;
44+
# This for loop exists because purs-backend-es finds the corefn.json files
45+
# just fine, but doesn't find the foreign.js files.
46+
# I suspect this is because of a quirky interaction between Nix and `copyFile`,
47+
# but I'm not sure how to fix it so we work around it by copying the foreign
48+
# modules by hand.
49+
for dir in output/*/; do
50+
subdir=$(basename "$dir")
51+
if [ -f "output/$subdir/foreign.js" ]; then
52+
cp "output/$subdir/foreign.js" "$out/output/$subdir/" || true;
53+
fi
54+
done
4555
'';
4656
};
4757
in

app/spago.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,6 @@ package:
7575
test:
7676
main: Test.Registry.Main
7777
dependencies:
78+
- registry-test-utils
7879
- spec
80+
- spec-node

app/test/Main.purs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@ import Test.Registry.App.Legacy.PackageSet as Test.Legacy.PackageSet
1818
import Test.Registry.App.Manifest.SpagoYaml as Test.Manifest.SpagoYaml
1919
import Test.Spec as Spec
2020
import Test.Spec.Reporter.Console (consoleReporter)
21-
import Test.Spec.Runner (defaultConfig, runSpec')
21+
import Test.Spec.Runner.Node (runSpecAndExitProcess')
22+
import Test.Spec.Runner.Node.Config as Cfg
2223

2324
main :: Effect Unit
24-
main = launchAff_ $ runSpec' (defaultConfig { timeout = Just $ Milliseconds 300_000.0 }) [ consoleReporter ] do
25+
main = runSpecAndExitProcess' config [ consoleReporter ] do
2526
Spec.describe "Registry.App.API" do
2627
Test.API.spec
2728

@@ -48,3 +49,8 @@ main = launchAff_ $ runSpec' (defaultConfig { timeout = Just $ Milliseconds 300_
4849

4950
Spec.describe "Registry.App.Manifest" do
5051
Spec.describe "SpagoYaml" Test.Manifest.SpagoYaml.spec
52+
where
53+
config =
54+
{ defaultConfig: Cfg.defaultConfig { timeout = Just $ Milliseconds 300_000.0 }
55+
, parseCLIOptions: false
56+
}

flake.lock

Lines changed: 74 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
description = "The PureScript Registry";
33

44
inputs = {
5-
nixpkgs.url = "github:nixos/nixpkgs/release-24.05";
5+
nixpkgs.url = "github:nixos/nixpkgs/release-25.05";
66
flake-utils.url = "github:numtide/flake-utils";
77

88
flake-compat.url = "github:edolstra/flake-compat";
@@ -11,16 +11,20 @@
1111
purescript-overlay.url = "github:thomashoneyman/purescript-overlay";
1212
purescript-overlay.inputs.nixpkgs.follows = "nixpkgs";
1313

14+
mkSpagoDerivation.url = "github:jeslie0/mkSpagoDerivation";
15+
mkSpagoDerivation.inputs.nixpkgs.follows = "nixpkgs";
16+
mkSpagoDerivation.inputs.ps-overlay.follows = "purescript-overlay";
17+
1418
slimlock.url = "github:thomashoneyman/slimlock";
1519
slimlock.inputs.nixpkgs.follows = "nixpkgs";
1620
};
1721

1822
outputs =
1923
{
20-
self,
2124
nixpkgs,
2225
flake-utils,
2326
purescript-overlay,
27+
mkSpagoDerivation,
2428
slimlock,
2529
...
2630
}:
@@ -34,16 +38,14 @@
3438
"aarch64-darwin"
3539
];
3640

37-
# Users authorized to deploy to the registry.
38-
deployers = import ./nix/deployers.nix;
39-
4041
pureScriptFileset = fileset.intersection (fileset.gitTracked ./.) (
4142
fileset.unions [
4243
./app
4344
(fileset.maybeMissing ./check)
4445
./foreign
4546
./lib
4647
./scripts
48+
./test-utils
4749
./spago.lock
4850
./spago.yaml
4951
]
@@ -81,7 +83,7 @@
8183
# We don't want to force everyone to update their configs if they aren't
8284
# normally on flakes.
8385
nixFlakes = prev.writeShellScriptBin "nixFlakes" ''
84-
exec ${prev.nixFlakes}/bin/nix --experimental-features "nix-command flakes" "$@"
86+
exec ${prev.nixVersions.stable}/bin/nix --experimental-features "nix-command flakes" "$@"
8587
'';
8688

8789
# Detects arguments to 'git' containing a URL and replaces them with a
@@ -149,12 +151,15 @@
149151
# Packages associated with the registry, ie. in this repository.
150152
registry =
151153
let
152-
spago-lock = prev.purix.buildSpagoLock {
153-
src = fileset.toSource {
154-
root = ./.;
155-
fileset = pureScriptFileset;
156-
};
157-
corefn = true;
154+
spago-lock = prev.mkSpagoDerivation {
155+
name = "registry";
156+
src = ./.;
157+
nativeBuildInputs = [
158+
prev.pkgs.spago-bin.spago-0_93_44
159+
prev.pkgs.purescript
160+
];
161+
buildPhase = "spago build";
162+
installPhase = "mkdir $out; cp -r * $out";
158163
};
159164

160165
package-lock =
@@ -250,6 +255,7 @@
250255
inherit system;
251256
overlays = [
252257
purescript-overlay.overlays.default
258+
mkSpagoDerivation.overlays.default
253259
slimlock.overlays.default
254260
registryOverlay
255261
];
@@ -270,19 +276,20 @@
270276
set -euo pipefail
271277
WORKDIR=$(mktemp -d)
272278
cp spago.yaml spago.lock $WORKDIR
273-
cp -a app foreign lib scripts types $WORKDIR
279+
cp -a app foreign lib scripts test-utils types $WORKDIR
274280
ln -s ${pkgs.registry.package-lock}/js/node_modules $WORKDIR/node_modules
275281
276282
pushd $WORKDIR
277283
export HEALTHCHECKS_URL=${defaultEnv.HEALTHCHECKS_URL}
278-
${pkgs.spago-bin.spago-0_93_19}/bin/spago test
284+
${pkgs.spago-bin.spago-0_93_44}/bin/spago test
279285
280286
popd
281287
'';
282288

283289
mkAppOutput = drv: {
284290
type = "app";
285291
program = "${drv}/bin/${drv.name}";
292+
meta.description = drv.meta.description or "PureScript Registry ${drv.name}";
286293
};
287294

288295
# A full set of environment variables, each set to their default values
@@ -327,6 +334,7 @@
327334
{
328335
nixpkgs.overlays = [
329336
purescript-overlay.overlays.default
337+
mkSpagoDerivation.overlays.default
330338
slimlock.overlays.default
331339
registryOverlay
332340
];
@@ -357,8 +365,11 @@
357365
packages = pkgs.registry.apps // pkgs.registry.scripts;
358366

359367
apps = pkgs.lib.mapAttrs (_: drv: mkAppOutput drv) packages // {
360-
default.type = "app";
361-
default.program = "${run-vm}";
368+
default = {
369+
type = "app";
370+
program = "${run-vm}";
371+
meta.description = "Run the registry server in a NixOS VM";
372+
};
362373
};
363374

364375
checks = {
@@ -868,7 +879,7 @@
868879

869880
# Development tooling
870881
purs
871-
spago-bin.spago-0_93_19 # until new lockfile format supported by overlay
882+
spago-bin.spago-0_93_44
872883
purs-tidy-unstable
873884
purs-backend-es-unstable
874885
];
@@ -885,6 +896,7 @@
885896
system = "x86_64-linux";
886897
overlays = [
887898
purescript-overlay.overlays.default
899+
mkSpagoDerivation.overlays.default
888900
slimlock.overlays.default
889901
registryOverlay
890902
];

0 commit comments

Comments
 (0)