-
Notifications
You must be signed in to change notification settings - Fork 28
/
site.nix
94 lines (88 loc) · 2.41 KB
/
site.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
_: {
perSystem =
{
pkgs,
lib,
mkCi,
jsPkgs,
ensureAtRepositoryRoot,
...
}:
let
deps = with jsPkgs; [
pkg-config
nodePackages_latest.nodejs
];
packageJSON = lib.importJSON ./package.json;
in
{
packages = {
site = mkCi false (
jsPkgs.buildNpmPackage {
npmDepsHash = "sha256-Q9HbeXkrLI3aomqLxcpIAk+f72KWHOusQdQjRoz/tj4=";
src = ./.;
sourceRoot = "site";
pname = packageJSON.name;
inherit (packageJSON) version;
nativeBuildInputs = deps;
buildInputs = deps;
installPhase = ''
mkdir -p $out
cp -r ./.vercel/output/* $out
'';
doDist = false;
PUPPETEER_SKIP_DOWNLOAD = 1;
ASTRO_TELEMETRY_DISABLED = 1;
NODE_OPTIONS = "--no-warnings";
}
);
};
apps = {
site-dev-server = {
type = "app";
program = pkgs.writeShellApplication {
name = "site-dev-server";
runtimeInputs = deps;
text = ''
${ensureAtRepositoryRoot}
cd site/
export PUPPETEER_SKIP_DOWNLOAD=1
npm install
npm run dev
'';
};
};
fmt-site = {
type = "app";
program = pkgs.writeShellApplication {
name = "fmt-site";
runtimeInputs = deps;
text = ''
${ensureAtRepositoryRoot}
cd site/
export PUPPETEER_SKIP_DOWNLOAD=1
npm install
# This formats the non-frontmatter portion of .astro files
# TODO: move to treefmt https://treefmt.com/usage
./node_modules/prettier/bin/prettier.cjs --plugin=prettier-plugin-astro --write ./**/*.astro || true
cd ..
# this re-formats the frontmatter portion, using our biome config
nix fmt
'';
};
};
site-check = {
type = "app";
program = pkgs.writeShellApplication {
name = "site-check";
runtimeInputs = deps;
text = ''
${ensureAtRepositoryRoot}
cd site/
npm_config_yes=true npx astro check
'';
};
};
};
};
}