diff options
| author | Jakub Stachurski <jakub@wilkuu.nl> | 2026-07-12 23:07:38 +0200 |
|---|---|---|
| committer | Jakub Stachurski <jakub@wilkuu.nl> | 2026-07-12 23:07:38 +0200 |
| commit | 21daf43ebc2403ce6991390478dd31fad8d9f10e (patch) | |
| tree | f6bdea69f9394b8baf8d439e9d23ac8e3a79638a /modules/mjmap.nix | |
| parent | c4ac6a0b88ff83a90a3c957034b52bedbe4d5868 (diff) | |
I am very not sure what all of this is :3
Diffstat (limited to '')
| -rw-r--r-- | modules/mjmap.nix | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/modules/mjmap.nix b/modules/mjmap.nix new file mode 100644 index 0000000..b826469 --- /dev/null +++ b/modules/mjmap.nix @@ -0,0 +1,51 @@ +{pkgs, config, lib, ...}: let + cfg = config.wilkuu.mjmap; + inherit (lib) mkEnableOption mkOption types mkIf; + # TODO: Once the mjmap patch is upstreamed, use this. + #mjmap_wrap = (pkgs.writeScriptBin "mjmap" '' + # #! ${pkgs.bash}/bin/bash + # export MJMAP_CONFIG=${config.sops.secrets."mjmap-creds".path}; + # exec ${pkgs.mjmap} "$@" + # ''); + + # Workaround since the current version does not support setting config path; + mjmap_wrap = (pkgs.writeScriptBin "mjmap-send" '' + #! ${pkgs.bash}/bin/bash + export XDG_CONFIG_DIR=/etc/; + exec ${pkgs.mjmap}/bin/mjmap "$@" + ''); + + sendmail_wrap = pkgs.symlinkJoin { + name = "sendmail-wrapper"; + paths = [ mjmap_wrap ]; + postBuild = '' + ln -s $out/bin/mjmap-send $out/bin/sendmail + ''; + }; + +in { + options.wilkuu.mjmap = { + enable = mkEnableOption "mjmap jmap email"; + users = mkOption { + type = types.listOf types.str; + description = "users that are allowed to view the credentials file and thus use mjmail"; + }; + }; + + config = mkIf cfg.enable{ + users.groups.mjmap = mkIf (cfg.users != []) {}; + users.users = lib.genAttrs cfg.users (_: { + extraGroups = ["mjmap"]; + packages = [mjmap_wrap sendmail_wrap]; + }); + sops.secrets."mjmap-creds" = mkIf (cfg.users != []) { + sopsFile = ../secrets/${config.networking.hostName}/mjmap.scfg.bin; + key = ""; + format = "binary"; + group = "mjmap"; + mode = "440"; + }; + environment.etc."mjmap/config.scfg" = mkIf (cfg.users != []) { source = config.sops.secrets."mjmap-creds".path; }; + environment.systemPackages = [ pkgs.mjmap ]; + }; +} |
