1
1
Fork 0
nixos/options/custom/services/agenix.nix
Myned 53c8575116
git: migrate to forgejo
Squashes 1,331 commits

Signed-off-by: Myned <dev@bjork.tech>
2024-09-12 19:41:21 -05:00

47 lines
1.1 KiB
Nix

{
config,
lib,
pkgs,
...
}:
with lib;
let
cat = "${pkgs.coreutils}/bin/cat";
sed = "${pkgs.gnused}/bin/sed";
cfg = config.custom.services.agenix;
in
{
options.custom.services.agenix.enable = mkOption { default = false; };
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 = {
WantedBy = [ "default.target" ];
};
};
};
}