Skip to content
Merged
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 .agents/setup
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ time nix_env="$(nix print-dev-env --profile .direnv/flake-profile)"
eval "$nix_env"

echo "Installing locked npm dependencies..."
time npm ci --no-audit --no-fund
time npm ci --omit=optional --no-audit --no-fund

echo "Building the PureScript workspace..."
time spago build
Expand Down
28 changes: 7 additions & 21 deletions .github/workflows/dashboard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ name: Deploy Dashboard
on:
push:
branches: [master]
paths: ['dashboard/**']
paths: ['dashboard/**', '.github/workflows/dashboard.yml']
pull_request:
types: [opened, reopened, synchronize, closed]
paths: ['dashboard/**']
paths: ['dashboard/**', '.github/workflows/dashboard.yml']

permissions:
contents: write
Expand All @@ -20,31 +20,17 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Setup Node
- uses: DeterminateSystems/determinate-nix-action@v3
if: github.event.action != 'closed'
uses: actions/setup-node@v4
with:
node-version: 22

- name: Install tools
- uses: DeterminateSystems/magic-nix-cache-action@v14
if: github.event.action != 'closed'
run: npm install --no-save purescript@0.15.16 spago@1.0.4 esbuild
with:
use-flakehub: false

- name: Build dashboard
if: github.event.action != 'closed'
run: npm run dashboard:build

- name: Verify bundle
if: github.event.action != 'closed'
run: test -f dashboard/app.js

- name: Prepare deploy directory
if: github.event.action != 'closed'
run: |
mkdir -p _site
cp dashboard/index.html _site/
cp dashboard/app.js _site/
cp -r dashboard/static _site/
run: nix build .#dashboard --out-link _site

- name: Deploy to Pages
if: github.ref == 'refs/heads/master'
Expand Down
15 changes: 11 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,23 @@ You can get all the tools you need to work on this repository via Nix by enterin
nix develop
```

Then, you can treat this repository as an ordinary PureScript project:
If you have direnv with nix-direnv configured for your shell, run `direnv allow` to activate the environment automatically when entering this repository.

Install the locked JavaScript dependencies inside the Nix shell, then build and test:

```sh
# Install JavaScript dependencies
npm ci --omit=optional --no-audit --no-fund

# Build the source
spago build

# Run the tests
spago test
```

Repeat the npm install step when the dependencies or Node version change.

> NOTE: You don't strictly need Nix to work on the registry; if you are contributing PureScript changes only then you can get away with just `purs` and `spago`, but be aware that some tests will fail on your machine, you may see database errors, and you will not be able to run integration tests.

## Repository Structure
Expand Down Expand Up @@ -275,13 +282,13 @@ The `dashboard/` directory contains a Halogen (PureScript) application for monit

### Building

To produce a browser JS bundle:
To build the dashboard for deployment:

```sh
npm run dashboard:build
nix build .#dashboard
```

This outputs `dashboard/app.js`, which `dashboard/index.html` loads via `<script src="./app.js">`.
The `result/` directory contains `index.html`, `app.js`, and `static/`. To produce only the JS bundle in your checkout, run `npm run dashboard:build`.

### Local Development

Expand Down
5 changes: 5 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
pkgs.registry.apps
// pkgs.registry.scripts
// {
dashboard = pkgs.registry-dashboard;
test-env = testEnv.testEnvScript;
};

Expand All @@ -131,6 +132,8 @@
};

checks = {
dashboard = pkgs.registry-dashboard;

spago-test =
pkgs.runCommand "spago-test"
{
Expand Down Expand Up @@ -240,6 +243,8 @@
nixfmt-rfc-style
bash
nodejs
prefetch-npm-deps
esbuild
jq
dbmate
sqlite
Expand Down
16 changes: 15 additions & 1 deletion nix/overlay.nix
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ in
dontNpmBuild = true;
npmFlags = [ "--omit=optional" ];

# To update: run `nix build .#server` and copy the hash from the error
# To update: run `prefetch-npm-deps package-lock.json` in the dev shell.
npmDepsHash = "sha256-1PENsd/EzRYVZ6RxTssbSzPu7SVVGlWnP7Zjt6im5GI=";

installPhase = ''
Expand All @@ -176,6 +176,20 @@ in
'';
};

registry-dashboard =
prev.runCommand "registry-dashboard" { nativeBuildInputs = [ prev.esbuild ]; }
''
ln -s ${final.registry-spago-lock}/output .
ln -s ${final.registry-package-lock}/node_modules .
mkdir -p $out
esbuild --bundle --platform=browser --outfile=$out/app.js <<'EOF'
import { main } from "./output/Dashboard.Main/index.js";
main();
EOF
cp ${../dashboard/index.html} $out/index.html
cp -r ${../dashboard/static} $out/static
'';

# Compiler infrastructure

# All PureScript compilers we support (filtered from purs-bin overlay)
Expand Down
Loading