1{
2 lib,
3 pkgs,
4 config,
5 ...
6}:
7
8let
9 cfg = config.services.fediwall;
10 pkg = cfg.package.override { conf = cfg.settings; };
11 format = pkgs.formats.json { };
12in
13{
14 options.services.fediwall = {
15 enable = lib.mkEnableOption "fediwall, a social media wall for the fediverse";
16 package = lib.mkPackageOption pkgs "fediwall" { };
17 hostName = lib.mkOption {
18 type = lib.types.str;
19 default = config.networking.fqdnOrHostName;
20 defaultText = lib.literalExpression "config.networking.fqdnOrHostName";
21 example = "fediwall.example.org";
22 description = "The hostname to serve fediwall on.";
23 };
24 settings = lib.mkOption {
25 default = { };
26 description = ''
27 Fediwall configuration. See
28 https://github.com/defnull/fediwall/blob/main/public/wall-config.json.example
29 for information on supported values.
30 '';
31 type = lib.types.submodule {
32 freeformType = format.type;
33 options = {
34 servers = lib.mkOption {
35 type = with lib.types; listOf str;
36 default = [ "mastodon.social" ];
37 description = "Servers to load posts from";
38 };
39 tags = lib.mkOption {
40 type = with lib.types; listOf str;
41 default = [ ];
42 example = lib.literalExpression "[ \"cats\" \"dogs\"]";
43 description = "Tags to follow";
44 };
45 loadPublic = lib.mkOption {
46 type = lib.types.bool;
47 default = false;
48 description = "Load public posts";
49 };
50 loadFederated = lib.mkOption {
51 type = lib.types.bool;
52 default = false;
53 description = "Load federated posts";
54 };
55 loadTrends = lib.mkOption {
56 type = lib.types.bool;
57 default = false;
58 description = "Load trending posts";
59 };
60 hideSensitive = lib.mkOption {
61 type = lib.types.bool;
62 default = true;
63 description = "Hide sensitive (potentially NSFW) posts";
64 };
65 hideBots = lib.mkOption {
66 type = lib.types.bool;
67 default = true;
68 description = "Hide posts from bot accounts";
69 };
70 hideReplies = lib.mkOption {
71 type = lib.types.bool;
72 default = true;
73 description = "Hide replies";
74 };
75 hideBoosts = lib.mkOption {
76 type = lib.types.bool;
77 default = false;
78 description = "Hide boosts";
79 };
80 showMedia = lib.mkOption {
81 type = lib.types.bool;
82 default = true;
83 description = "Show media in posts";
84 };
85 playVideos = lib.mkOption {
86 type = lib.types.bool;
87 default = true;
88 description = "Autoplay videos in posts";
89 };
90 };
91 };
92 };
93 nginx = lib.mkOption {
94 type = lib.types.submodule (
95 lib.recursiveUpdate (import ../web-servers/nginx/vhost-options.nix { inherit config lib; }) { }
96 );
97 default = { };
98 example = lib.literalExpression ''
99 {
100 serverAliases = [
101 "fedi.''${config.networking.domain}"
102 ];
103 # Enable TLS and use let's encrypt for ACME
104 forceSSL = true;
105 enableACME = true;
106 }
107 '';
108 description = "Allows customizing the nginx virtualHost settings";
109 };
110 };
111
112 config = lib.mkIf cfg.enable {
113 services.nginx = {
114 enable = lib.mkDefault true;
115 virtualHosts."${cfg.hostName}" = lib.mkMerge [
116 cfg.nginx
117 {
118 root = lib.mkForce "${pkg}";
119 locations = {
120 "/" = {
121 index = "index.html";
122 };
123 };
124 }
125 ];
126 };
127 };
128}