-
Notifications
You must be signed in to change notification settings - Fork 0
/
shell.nix
82 lines (74 loc) · 2.19 KB
/
shell.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
{
sources ? import ./sources.nix,
nixpkgs ? sources.nixpkgs,
niv ? sources.niv,
mkCli ? sources.mkCli,
}: let
niv-overlay = self: _: {
niv = self.symlinkJoin {
name = "niv";
paths = [niv];
buildInputs = [self.makeWrapper];
postBuild = ''
wrapProgram $out/bin/niv \
--add-flags "--sources-file ${toString ./sources.json}"
'';
};
};
mkCli-overlay = import "${mkCli}/overlay.nix";
pkgs = import nixpkgs {
overlays = [
niv-overlay
mkCli-overlay
];
config = {};
};
# This has to be a command with no arguments because the changeset github
# action we use to publish splits the command on spaces (see
# https://github.com/changesets/action/blob/595655c3eae7136ff5ba18200406898904362926/src/run.ts#L281),
# which means running something like `nix-shell --run 'foo bar'` will break
# the 'foo bar' argument to nix-shell.
publish = pkgs.writeShellScriptBin "publish" ''
set -e
for package in packages/*; do
mv "$package" "$package-old"
mv "$package-old/dist" "$package"
rm -rf "$package-old"
done
${pkgs.nodePackages.pnpm}/bin/pnpm exec changeset publish
'';
cli = pkgs.lib.mkCli "cli" {
_noAll = true;
build = "${pkgs.turbo}/bin/turbo run build";
build-docs = "${pkgs.turbo}/bin/turbo run build:docs";
check-commits = "${pkgs.nodePackages.pnpm}/bin/pnpm exec commitlint --";
test = {
nix = {
lint = "${pkgs.statix}/bin/statix check --ignore node_modules .";
dead-code = "${pkgs.deadnix}/bin/deadnix .";
format = "${pkgs.alejandra}/bin/alejandra --exclude ./node_modules --check .";
};
turbo = "${pkgs.turbo}/bin/turbo run test";
};
fix = {
nix = {
lint = "${pkgs.statix}/bin/statix fix --ignore node_modules .";
dead-code = "${pkgs.deadnix}/bin/deadnix -e .";
format = "${pkgs.alejandra}/bin/alejandra --exclude ./node_modules .";
};
turbo = "${pkgs.turbo}/bin/turbo run fix";
};
};
in
pkgs.mkShell {
FORCE_COLOR = 1;
buildInputs = [
cli
publish
pkgs.git
pkgs.niv
pkgs.nodePackages.pnpm
pkgs.nodejs
pkgs.turbo
];
}