-
-
Notifications
You must be signed in to change notification settings - Fork 70
Expand file tree
/
Copy pathflake.nix
More file actions
112 lines (103 loc) · 3.45 KB
/
flake.nix
File metadata and controls
112 lines (103 loc) · 3.45 KB
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
{
description = "emacs-async - Asynchronous processing in Emacs";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
emacs = pkgs.emacs-nox;
emacsWithPackages = (pkgs.emacsPackagesFor emacs).emacsWithPackages
(epkgs: [
epkgs.package-lint
epkgs.buttercup
]);
sourceFiles =
"async.el async-bytecomp.el async-package.el dired-async.el smtpmail-async.el";
copySrc = ''
cp $src/*.el .
chmod +w *.el
if [ -d $src/tests ]; then
mkdir -p tests
cp $src/tests/*.el tests/
chmod +w tests/*.el
fi
'';
in {
checks = {
compile = pkgs.runCommand "async-compile" {
nativeBuildInputs = [ emacsWithPackages ];
src = self;
} ''
${copySrc}
HOME=$TMPDIR emacs -Q --batch -L . \
--eval '(setq byte-compile-error-on-warn t)' \
-f batch-byte-compile \
${sourceFiles}
touch $out
'';
lint = pkgs.runCommand "async-lint" {
nativeBuildInputs = [ emacsWithPackages ];
src = self;
} ''
${copySrc}
HOME=$TMPDIR emacs -Q --batch -L . \
-l package-lint \
--eval '
(progn
(require (quote cl-lib))
(find-file "async.el")
(let* ((issues (package-lint-buffer))
(errors (cl-remove-if-not
(lambda (i) (eq (nth 2 i) (quote error)))
issues)))
(dolist (i issues)
(message "%s:%d:%d: %s: %s"
(buffer-file-name) (nth 0 i) (nth 1 i)
(nth 2 i) (nth 3 i)))
(when errors
(kill-emacs 1))))'
touch $out
'';
format = pkgs.runCommand "async-format-check" {
nativeBuildInputs = [ emacsWithPackages ];
src = self;
} ''
${copySrc}
for f in ${sourceFiles}; do
HOME=$TMPDIR emacs -Q --batch "$f" --eval '
(progn
(require (quote cl-lib))
(setq-default indent-tabs-mode nil)
(let ((original (buffer-string)))
(indent-region (point-min) (point-max))
(unless (string= original (buffer-string))
(message "Formatting differs: %s" buffer-file-name)
(kill-emacs 1))))'
done
touch $out
'';
test = pkgs.runCommand "async-test" {
nativeBuildInputs = [ emacsWithPackages ];
src = self;
} ''
${copySrc}
HOME=$TMPDIR emacs -Q --batch -L . \
-l buttercup \
-f buttercup-run-discover
touch $out
'';
};
devShells.default = pkgs.mkShell {
buildInputs = [
emacsWithPackages
pkgs.lefthook
];
shellHook = ''
lefthook install 2>/dev/null || true
'';
};
});
}