Skip to content

Commit 8184bb2

Browse files
author
jared
committed
Draft of all facilities
1 parent 609e8e2 commit 8184bb2

24 files changed

+4664
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.pre-commit-config.yaml
12
# Logs
23
logs
34
*.log

flake.lock

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

flake.nix

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
{
2+
inputs = {
3+
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
4+
flake-parts.url = "github:hercules-ci/flake-parts";
5+
pre-commit-hooks-nix.url = "github:cachix/pre-commit-hooks.nix";
6+
pre-commit-hooks-nix.inputs.nixpkgs.follows = "nixpkgs";
7+
hercules-ci-effects.url = "github:hercules-ci/hercules-ci-effects";
8+
};
9+
10+
outputs = inputs@{ flake-parts, ... }:
11+
flake-parts.lib.mkFlake { inherit inputs; }
12+
{
13+
systems = [ "x86_64-linux" "x86_64-darwin" ];
14+
imports = [
15+
inputs.pre-commit-hooks-nix.flakeModule
16+
inputs.hercules-ci-effects.flakeModule
17+
18+
./pre-commit.nix
19+
];
20+
perSystem = { pkgs, config, ... }:
21+
{
22+
packages = {
23+
default =
24+
let
25+
packageJson = builtins.fromJSON (builtins.readFile ./package.json);
26+
in
27+
pkgs.buildNpmPackage {
28+
# See: https://github.com/NixOS/nixpkgs/tree/master/pkgs/build-support/node/build-npm-package
29+
# for helpful documentation
30+
pname = packageJson.name;
31+
version = packageJson.version;
32+
src = ./.;
33+
npmDepsHash = "sha256-wSSYPXAfsoqghsYu5quUZCyimVHtWu+Cp7yee7qAi7E=";
34+
};
35+
36+
# Tarball created from `npm pack`
37+
tgz = config.packages.default.overrideAttrs (_self: (super: {
38+
name = "${super.pname}-${super.version}.tgz";
39+
makeCacheWritable = true;
40+
installPhase =
41+
''
42+
tgzFile=$(npm --log-level=verbose pack | tail -n 1)
43+
mv $tgzFile $out
44+
'';
45+
}));
46+
47+
};
48+
49+
# Provides a development environment
50+
devShells = {
51+
default = config.packages.default.overrideAttrs (_self: (_super: {
52+
# What does this do?
53+
# `buildNpmPackage` is creates an npm cache in the
54+
# directory `$npmDeps`, so we tell `npm` to use that cache
55+
# when building things.
56+
# Unfortunately, that cache is in the nix store (and hence
57+
# cannot be written to), so we copy it out to a temporary
58+
# directory and point npm to the temporary directory.
59+
shellHook =
60+
''
61+
# Copy the cache produced by nix somewhere else
62+
# s.t. npm may write to it
63+
TMP_DIR=$(mktemp -d)
64+
cp -r $npmDeps/. $TMP_DIR
65+
export NPM_CONFIG_CACHE=$TMP_DIR
66+
'';
67+
}));
68+
};
69+
70+
# Runs `npm test`
71+
checks.default =
72+
config.packages.default.overrideAttrs (_self: (_super: {
73+
postBuild =
74+
''
75+
npm --log-level=verbose test
76+
'';
77+
}));
78+
};
79+
};
80+
}

package-lock.json

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

0 commit comments

Comments
 (0)