mirror of
https://github.com/nix-community/home-manager.git
synced 2026-10-02 19:49:18 +00:00
Re-scrub derivations returned by override and overrideAttrs so package modules cannot restore real dependency graphs during test evaluation. Adapt affected tests with explicit runtime dependencies, executable mocks, and absence assertions.
52 lines
1.1 KiB
Nix
52 lines
1.1 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
realPkgs,
|
|
...
|
|
}:
|
|
|
|
let
|
|
|
|
testScript = pkgs.writeText "test.el" ''
|
|
;; Emacs won't automatically load default.el when --script is specified
|
|
(load "default")
|
|
(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)))
|
|
'';
|
|
|
|
emacsBin = "${config.programs.emacs.finalPackage}/bin/emacs";
|
|
|
|
mkTestPackage =
|
|
epkgs:
|
|
epkgs.trivialBuild {
|
|
pname = "hm-test";
|
|
version = "0.1.0";
|
|
src = pkgs.writeText "hm-test.el" ''
|
|
(defun hm-test-fn () 'success)
|
|
(provide 'hm-test)
|
|
'';
|
|
};
|
|
|
|
in
|
|
lib.mkIf config.test.enableBig {
|
|
programs.emacs = {
|
|
enable = true;
|
|
package = realPkgs.emacs-nox;
|
|
extraConfig = ''
|
|
(require 'hm-test)
|
|
(setq hm 'home-manager)
|
|
'';
|
|
extraPackages = epkgs: [ (mkTestPackage epkgs) ];
|
|
};
|
|
|
|
# running emacs with --script would enable headless mode
|
|
nmt.script = ''
|
|
if ! ${emacsBin} --script ${testScript}; then
|
|
fail "Failed to load default.el."
|
|
fi
|
|
'';
|
|
}
|