2024-09-09 00:22:14 +00:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
2024-09-13 01:50:53 +00:00
|
|
|
with lib; let
|
2024-09-09 00:22:14 +00:00
|
|
|
cat = "${pkgs.coreutils}/bin/cat";
|
|
|
|
sed = "${pkgs.gnused}/bin/sed";
|
|
|
|
|
|
|
|
cfg = config.custom.services.agenix;
|
2024-09-13 01:50:53 +00:00
|
|
|
in {
|
|
|
|
options.custom.services.agenix.enable = mkOption {default = false;};
|
2024-09-09 00:22:14 +00:00
|
|
|
|
|
|
|
config.home-manager.users.${config.custom.username} = mkIf cfg.enable {
|
|
|
|
xdg.configFile."hypr/hyprland.conf".force = true;
|
|
|
|
|
|
|
|
# Replace placeholders with secrets after agenix user service starts
|
|
|
|
systemd.user.services.secrets = {
|
|
|
|
Unit = {
|
|
|
|
Description = "Replace agenix secrets in-place";
|
|
|
|
After = "agenix.service";
|
|
|
|
};
|
|
|
|
|
|
|
|
Service = {
|
|
|
|
ExecStart = pkgs.writeShellScript "secrets" ''
|
|
|
|
file="${config.custom.homeDirectory}/.config/hypr/hyprland.conf"
|
|
|
|
|
|
|
|
${sed} -i "s|@BW_CLIENTID@|$(${cat} ${
|
|
|
|
config.age.secrets."desktop/bitwarden/client_id".path
|
|
|
|
})|" "$file"
|
|
|
|
${sed} -i "s|@BW_CLIENTSECRET@|$(${cat} ${
|
|
|
|
config.age.secrets."desktop/bitwarden/client_secret".path
|
|
|
|
})|" "$file"
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
Install = {
|
2024-09-13 01:50:53 +00:00
|
|
|
WantedBy = ["default.target"];
|
2024-09-09 00:22:14 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|