I want to install a package from pkgs
defined in a overlay and propagate the change in pkgs
to a home-manager.services call.
Here’s what I have. A module installing emacsGit
from a overlay and then using home-manager
to install a emacs.service
file. But home-manager uses the original pkgs.emacs
package, not the “alias”/overlay emacs = emacsGit
.
{ config, pkgs, inputs, ... }:
let cfg = config.modules.emacs;
in options.modules.emacs = {
enable = mkBoolOpt false;
};
config = mkIf cfg.enable {
nixpkgs.overlays = [
inputs.emacs-overlay.overlay
(final: previous: {
emacs = pkgs.emacsGit;
})
];
user.packages = with pkgs; [
emacs;
];
home-manager.users.${config.user.name}.services.emacs.enable = true;
}
The home-manager service is using the pkgs.emacs=nixpkgs.emacs
not the pkgs.emacs=emacsGit
.
emacs --version
GNU Emacs 30.0.50
systemctl --user cat emacs.service | grep ExecStart
ExecStart=/nix/store/k32c6vzr9g1nln6v0gypz6ar6lqjb63l-bash-5.2-p15/bin/bash -l -c "/nix/store/0m2axb8lbpj9sqfiy4ys6pgyxmafb64b-emacs-28.2/bin/emacs --fg-daemon "
How do I define pkgs.emacs
in such a way that the change is propagated to home-manager?[1]
[1]
I am aware I can do something like this, but I ask out of curiosity so I can learn a bit more.
{ config, lib, pkgs, inputs, ... }:
let
emacs = pkgs.emacsGit
in {
user.packages = [ emacs ];
services.emacs.package = emacs;
services.emacs.enable = true;
}