]> git.immae.eu Git - perso/Immae/Config/Nix.git/blob - nixops/modules/websites/capitaines/default.nix
Start moving websites configuration to modules
[perso/Immae/Config/Nix.git] / nixops / modules / websites / capitaines / default.nix
1 { lib, pkgs, config, myconfig, ... }:
2 let
3 cfg = config.services.myWebsites.Capitaines;
4 env = myconfig.env.websites.capitaines;
5 webappName = "capitaines_mastodon";
6 root = "/run/current-system/webapps/${webappName}";
7 siteDir = ./mastodon_static;
8 in {
9 options.services.myWebsites.Capitaines = {
10 production = {
11 enable = lib.mkEnableOption "enable Capitaines's website";
12 };
13 };
14
15 config = lib.mkIf cfg.production.enable {
16 security.acme.certs."capitaines" = config.services.myCertificates.certConfig // {
17 domain = "mastodon.capitaines.fr";
18 extraDomains = { "capitaines.fr" = null; };
19 };
20 system.extraSystemBuilderCmds = ''
21 mkdir -p $out/webapps
22 ln -s ${siteDir} $out/webapps/${webappName}
23 '';
24
25 services.websites.production.vhostConfs.capitaines_mastodon = {
26 certName = "capitaines";
27 hosts = [ "mastodon.capitaines.fr" ];
28 root = root;
29 extraConfig = [
30 ''
31 ErrorDocument 404 /index.html
32 <Directory ${root}>
33 DirectoryIndex index.html
34 Options Indexes FollowSymLinks MultiViews Includes
35 Require all granted
36 </Directory>
37 ''
38 ];
39 };
40
41 services.websites.production.vhostConfs.capitaines = {
42 certName = "capitaines";
43 hosts = [ "capitaines.fr" ];
44 root = "/run/current-system/webapps/_www";
45 extraConfig = [ ''
46 <Directory /run/current-system/webapps/_www>
47 DirectoryIndex index.htm
48 Require all granted
49 </Directory>
50 '' ];
51 };
52 };
53 }