2021-01-29 17:43:49 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
testScript = pkgs.writeText "test.el" ''
|
|
|
|
;; Emacs won't automatically load default.el when --script is specified
|
|
|
|
(load "default")
|
2022-04-30 11:04:08 +02:00
|
|
|
(let* ((test-load-config (eq hm 'home-manager))
|
|
|
|
(test-load-package (eq (hm-test-fn) 'success))
|
|
|
|
(is-ok (and test-load-config test-load-package)))
|
|
|
|
(kill-emacs (if is-ok 0 1)))
|
2021-01-29 17:43:49 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
emacsBin = "${config.programs.emacs.finalPackage}/bin/emacs";
|
|
|
|
|
2022-04-30 11:04:08 +02:00
|
|
|
mkTestPackage = epkgs:
|
|
|
|
epkgs.trivialBuild {
|
|
|
|
pname = "hm-test";
|
2023-09-13 16:10:36 +02:00
|
|
|
version = "0.1.0";
|
2022-04-30 11:04:08 +02:00
|
|
|
src = pkgs.writeText "hm-test.el" ''
|
|
|
|
(defun hm-test-fn () 'success)
|
|
|
|
(provide 'hm-test)
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2022-01-02 10:22:50 +01:00
|
|
|
in lib.mkIf config.test.enableBig {
|
2021-01-29 17:43:49 +01:00
|
|
|
programs.emacs = {
|
|
|
|
enable = true;
|
|
|
|
package = pkgs.emacs-nox;
|
2022-04-30 11:04:08 +02:00
|
|
|
extraConfig = ''
|
|
|
|
(require 'hm-test)
|
|
|
|
(setq hm 'home-manager)
|
|
|
|
'';
|
|
|
|
extraPackages = epkgs: [ (mkTestPackage epkgs) ];
|
2021-01-29 17:43:49 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
# running emacs with --script would enable headless mode
|
|
|
|
nmt.script = ''
|
|
|
|
if ! ${emacsBin} --script ${testScript}; then
|
|
|
|
fail "Failed to load default.el."
|
|
|
|
fi
|
|
|
|
'';
|
|
|
|
}
|