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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
{
description = "getchoo's website";
inputs = {
nixpkgs.url = "nixpkgs/nixpkgs-unstable";
nix-deno = {
url = "github:nekowinston/nix-deno";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = {
nixpkgs,
nix-deno,
self,
...
}: let
systems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
forSystem = system: fn:
fn rec {
pkgs = import nixpkgs {
inherit system;
overlays = [nix-deno.overlays.default];
};
inherit (pkgs) lib;
self' = lib.mapAttrs (_: v: v.${system} or {}) self;
};
forAllSystems = fn: nixpkgs.lib.genAttrs systems (system: forSystem system fn);
in {
checks = forAllSystems ({
lib,
pkgs,
self',
...
}: {
check-nil =
pkgs.runCommand "check-nil" {
nativeBuildInputs = with pkgs; [fd nil];
} ''
cd ${./.}
fd . -e "nix" | while read -r file; do
nil diagnostics "$file" || exit 1
done
touch $out
'';
"check-${self'.formatter.pname}" = pkgs.runCommand "check-${self'.formatter.pname}" {} ''
${lib.getExe self'.formatter} --check ${./.}
touch $out
'';
check-statix =
pkgs.runCommand "check-statix" {
nativeBuildInputs = [pkgs.statix];
} ''
statix check ${./.}
touch $out
'';
check-actionlint =
pkgs.runCommand "check-actionlint" {
nativeBuildInputs = [pkgs.actionlint];
} ''
actionlint ${./.github/workflows}/**
touch $out
'';
check-denofmt =
pkgs.runCommand "check-denofmt" {
nativeBuildInputs = [pkgs.deno];
} ''
cd ${./.}
export DENO_DIR="$(mktemp -d)"
deno fmt --check
touch $out
'';
check-denolint =
pkgs.runCommand "check-denolint" {
nativeBuildInputs = [pkgs.deno];
} ''
cd ${./.}
export DENO_DIR="$(mktemp -d)"
deno lint
touch $out
'';
});
devShells = forAllSystems ({
pkgs,
self',
...
}: {
default = pkgs.mkShellNoCC {
packages = with pkgs; [
deno
actionlint
self'.formatter
nil
statix
];
};
});
formatter = forAllSystems ({pkgs, ...}: pkgs.alejandra);
packages = forAllSystems ({
lib,
pkgs,
self',
...
}: {
website = pkgs.denoPlatform.mkDenoDerivation {
name = "website";
stdenv = pkgs.stdenvNoCC;
src = lib.cleanSource ./.;
buildPhase = ''
runHook preBuild
deno task build
runHook postBuild
'';
installPhase = ''
cp -r _site $out
'';
};
default = self'.packages.website;
});
};
}
|