Make use of sops templates

This commit is contained in:
SebastianStork 2024-06-26 17:21:09 +02:00
parent e2261da99b
commit 8805183553
4 changed files with 41 additions and 17 deletions

View file

@ -3,9 +3,17 @@
options.myConfig.geoclue.enable = lib.mkEnableOption "";
config = lib.mkIf config.myConfig.geoclue.enable {
sops.secrets.geoclue-location-service = {
owner = "geoclue";
path = "/etc/geoclue/conf.d/location-service.conf";
sops = {
secrets.geolocation-api-key = { };
templates."geoclue-location-service.conf" = {
owner = "geoclue";
path = "/etc/geoclue/conf.d/location-service.conf";
content = ''
[wifi]
url=https://www.googleapis.com/geolocation/v1/geolocate?key=${config.sops.placeholder.geolocation-api-key}
'';
};
};
services.geoclue2 = {

View file

@ -8,9 +8,23 @@
options.myConfig.wlan.enable = lib.mkEnableOption "";
config = lib.mkIf config.myConfig.wlan.enable {
sops.secrets = {
"iwd/WLAN-233151" = { };
"iwd/Fairphone4" = { };
sops = {
secrets = {
"wlan/WLAN-233151/key" = { };
"wlan/Fairphone4/key" = { };
};
templates =
let
mkPskFile = key: ''
[Security]
Passphrase=${key}
'';
in
{
"iwd/WLAN-233151.psk".content = mkPskFile "${config.sops.placeholder."wlan/WLAN-233151/key"}";
"iwd/Fairphone4.psk".content = mkPskFile "${config.sops.placeholder."wlan/Fairphone4/key"}";
};
};
networking.wireless.iwd = {
@ -24,8 +38,8 @@
};
systemd.tmpfiles.rules = [
"C /var/lib/iwd/WLAN-233151.psk 0600 root root - ${config.sops.secrets."iwd/WLAN-233151".path}"
"C /var/lib/iwd/Fairphone4.psk 0600 root root - ${config.sops.secrets."iwd/Fairphone4".path}"
"C /var/lib/iwd/WLAN-233151.psk 0600 root root - ${config.sops.templates."iwd/WLAN-233151.psk".path}"
"C /var/lib/iwd/Fairphone4.psk 0600 root root - ${config.sops.templates."iwd/Fairphone4.psk".path}"
];
environment.systemPackages = [ pkgs.iwgtk ];