-
Notifications
You must be signed in to change notification settings - Fork 0
/
devshells.nix
103 lines (100 loc) · 2.87 KB
/
devshells.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
95
96
97
98
99
100
101
102
103
{ lib, ... }:
{
perSystem =
{
config,
inputs',
pkgs,
...
}:
{
devshells.ci = {
packages = [
inputs'.mozilla-addons-to-nix.packages.default
];
};
devshells.default = {
devshell.name = "firefox-addons";
packages = [
inputs'.mozilla-addons-to-nix.packages.default
pkgs.fd
pkgs.jq
pkgs.nixfmt-rfc-style
pkgs.nodePackages.prettier
];
commands = [
{
package = pkgs.just;
category = "tools";
}
{
name = "fmt";
category = "tools";
help = "format all (non-generated) nix files";
command = ''
${lib.getExe pkgs.fd} \
--type file \
--extension nix \
--exclude '*.generated.*' \
--exec-batch ${lib.getExe config.formatter} '{}'
'';
}
{
# TODO: accept moz url input
name = "add-addon";
category = "maintenance";
command = ''
SLUG="$1"
PNAME="''${2:-}"
MANIFEST="$PRJ_ROOT/src/addons.json"
cp "$MANIFEST" "$MANIFEST.tmp"
cat "$MANIFEST" \
| ${pkgs.jq}/bin/jq \
--arg slug "$SLUG" \
--arg pname "$PNAME" \
'. + [(
{slug: $slug}
+ if ($pname != "")
then {pname: $pname}
else {} end
)]
| sort_by(.slug)' \
> "''${MANIFEST}.tmp"
mv $MANIFEST.tmp $MANIFEST
'';
}
{
name = "rm-addon";
category = "maintenance";
help = "Remove an addon by its slug :: SYNOPSIS: <slug>";
command = ''
SLUG="$1"
MANIFEST="$PRJ_ROOT/src/addons.json"
cp "$MANIFEST" "$MANIFEST.tmp"
# TODO: return error if not found
cat "$MANIFEST" \
| ${pkgs.jq}/bin/jq \
--arg slug "$SLUG" \
'map(select(.slug != $slug))' \
> "''${MANIFEST}.tmp"
mv $MANIFEST.tmp $MANIFEST
'';
}
{
name = "update-addons";
category = "maintenance";
help = "Update the addons listed in the manifest";
command = ''
mozilla-addons-to-nix $PRJ_ROOT/src/addons.json $PRJ_ROOT/src/addons.generated.nix
'';
}
{
name = "update-flake";
category = "maintenance";
help = "Update the flake dependencies";
command = "nix flake update";
}
];
};
};
}