This repository has been archived by the owner on May 28, 2024. It is now read-only.
forked from prescientmoon/doffycup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
62 lines (51 loc) · 1.68 KB
/
flake.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
{
description = "Doffycup";
inputs.flake-utils.url = "github:numtide/flake-utils";
outputs = { nixpkgs, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
lib = pkgs.lib;
nodejs = pkgs.nodejs_18;
in
rec {
packages.doffycup = pkgs.buildNpmPackage.override
{ stdenv = pkgs.stdenvNoCC; }
{
name = "doffycup";
buildInputs = [ nodejs pkgs.gzip ];
src = lib.cleanSource ./.;
npmDepsHash = builtins.readFile ./npm-deps-hash;
ESBUILD_BASEURL = "";
postBuild = ''
# Github pages requires an additional 404.html file
cp dist/{index,404}.html
# -k = keeps the original files in place
# -r = recursive
# -9 = best compression
gzip -kr9 dist
'';
installPhase = ''
mkdir $out
cp -r dist $out/www
'';
};
# Github pages deploys to a subfolder
packages.doffycup-github-pages = packages.doffycup.overrideAttrs {
ESBUILD_BASEURL = "/doffycup";
};
packages.default = packages.doffycup;
devShells.default = pkgs.mkShell {
packages = [ nodejs ];
};
apps.compute-npm-dep-hash = {
type = "app";
program = pkgs.lib.getExe (pkgs.writeShellApplication {
name = "compute-npm-dep-hash";
runtimeInputs = [ pkgs.prefetch-npm-deps ];
text = "prefetch-npm-deps ./package-lock.json > ./npm-deps-hash";
});
};
}
);
}