2024-09-29 08:48:38 -07:00
|
|
|
{ config, lib, pkgs, user, home-manager, ... }:
|
|
|
|
|
|
|
|
let cfg = config.modules.programs.chezmoi;
|
|
|
|
in {
|
|
|
|
options.modules.programs.chezmoi = with lib; {
|
2024-09-30 10:35:46 -07:00
|
|
|
enable = lib.mkOption {
|
|
|
|
type = with types; bool;
|
|
|
|
default = true;
|
|
|
|
};
|
2024-09-29 08:48:38 -07:00
|
|
|
apply = lib.mkOption {
|
|
|
|
type = with types; bool;
|
|
|
|
default = false;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
environment.systemPackages = with pkgs; [
|
2024-09-30 10:35:46 -07:00
|
|
|
chezmoi
|
2024-09-29 08:48:38 -07:00
|
|
|
];
|
|
|
|
# Optionally apply chezmoi dotfiles with home-manager activation
|
|
|
|
home-manager.users.${user} = lib.mkIf cfg.apply {
|
|
|
|
home.activation.chezmoi = home-manager.lib.hm.dag.entryAfter [ "installPackages" ] ''
|
2024-09-29 09:18:01 -07:00
|
|
|
_saved_path=$PATH
|
|
|
|
PATH="${pkgs.git}/bin:$PATH"
|
2024-09-29 08:48:38 -07:00
|
|
|
run ${pkgs.chezmoi}/bin/chezmoi apply --force
|
2024-09-29 09:18:01 -07:00
|
|
|
PATH=$_saved_path
|
2024-09-29 08:48:38 -07:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|