-
Notifications
You must be signed in to change notification settings - Fork 71
Expand file tree
/
Copy pathflake.nix
More file actions
130 lines (117 loc) · 4.14 KB
/
Copy pathflake.nix
File metadata and controls
130 lines (117 loc) · 4.14 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
{
description = "Alert - Growl-style notification system for 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;
# Runtime dependencies only
emacsWithDeps = (pkgs.emacsPackagesFor emacs).emacsWithPackages (epkgs: [
epkgs.gntp
epkgs.log4e
]);
# Runtime + CI/lint dependencies
emacsForCI = (pkgs.emacsPackagesFor emacs).emacsWithPackages (epkgs: [
epkgs.gntp
epkgs.log4e
epkgs.package-lint
epkgs.relint
]);
src = pkgs.lib.cleanSource self;
in {
packages.default = pkgs.stdenv.mkDerivation {
pname = "emacs-alert";
version = "1.2";
inherit src;
nativeBuildInputs = [ emacsWithDeps ];
buildPhase = ''
emacs -Q --batch \
-f batch-byte-compile \
alert.el
'';
installPhase = ''
mkdir -p $out/share/emacs/site-lisp
cp alert.el alert.elc $out/share/emacs/site-lisp/
'';
};
checks = {
# Ensure the package builds successfully
build = self.packages.${system}.default;
# Byte-compile with all warnings treated as errors
byte-compile = pkgs.runCommand "check-byte-compile" {
nativeBuildInputs = [ emacsWithDeps ];
} ''
cp ${src}/alert.el .
emacs -Q --batch \
--eval '(setq byte-compile-error-on-warn t)' \
-f batch-byte-compile \
alert.el
touch $out
'';
# Run ERT test suite
test = pkgs.runCommand "check-test" {
nativeBuildInputs = [ emacsWithDeps ];
} ''
cp ${src}/alert.el ${src}/alert-test.el .
emacs -Q --batch \
-L . \
-l alert-test \
-f ert-run-tests-batch-and-exit
touch $out
'';
# Check regexp patterns for correctness
relint = pkgs.runCommand "check-relint" {
nativeBuildInputs = [ emacsForCI ];
} ''
cp ${src}/alert.el .
emacs -Q --batch \
-l relint \
--eval '(setq relint-batch-highlight nil)' \
-f relint-batch \
alert.el
touch $out
'';
# NOTE: indent check is available via: nix run .#format -- alert.el
# It is excluded from blocking checks because alert.el has
# legacy indentation that would require a large reformatting diff.
#
# NOTE: The following checks are not applicable to Emacs Lisp:
#
# - Code coverage: ERT lacks practical coverage tooling
# - Performance profiling: not meaningful as a build gate for a library
# - Fuzz testing: not practical for Emacs Lisp
# - Memory sanitizer: Emacs uses garbage collection
#
# package-lint is excluded from nix checks because it requires
# network access to verify package archives. Run it locally via:
# emacs -Q --batch -l package-lint -f package-lint-batch-and-exit alert.el
};
# Format all Elisp files to canonical Emacs indentation
apps.format = flake-utils.lib.mkApp {
drv = pkgs.writeShellScriptBin "alert-format" ''
files="''${@:-alert.el}"
for f in $files; do
${emacsWithDeps}/bin/emacs -Q --batch \
"$f" \
--eval '(progn (emacs-lisp-mode) (indent-region (point-min) (point-max)))' \
-f save-buffer
echo "Formatted: $f"
done
'';
};
devShells.default = pkgs.mkShell {
buildInputs = [
emacsForCI
pkgs.lefthook
];
shellHook = ''
lefthook install 2>/dev/null || true
'';
};
}
);
}