aboutsummaryrefslogblamecommitdiff
path: root/nixops/modules/websites/capitaines/default.nix
blob: 08f6dd3985de5894707047f7445ce54ecd19f8d0 (plain) (tree)
1
2
3
4
5
6



                                                

                                                       








                                                                
                                                                                     
                                        
                                                 
      



                                                 
 

                                                                     
                                                 
                         


                                     
                           






                                                            











                                                            

    
{ lib, pkgs, config, myconfig, mylibs, ... }:
let
    cfg = config.services.myWebsites.Capitaines;
    env = myconfig.env.websites.capitaines;
    webappName = "capitaines_mastodon";
    root = "/run/current-system/webapps/${webappName}";
    siteDir = ./mastodon_static;
in {
  options.services.myWebsites.Capitaines = {
    production = {
      enable = lib.mkEnableOption "enable Capitaines's website";
    };
  };

  config = lib.mkIf cfg.production.enable {
    security.acme.certs."capitaines" = config.services.myCertificates.certConfig // {
      domain = "mastodon.capitaines.fr";
      extraDomains = { "capitaines.fr" = null; };
    };
    system.extraSystemBuilderCmds = ''
      mkdir -p $out/webapps
      ln -s ${siteDir} $out/webapps/${webappName}
      '';

    services.myWebsites.production.vhostConfs.capitaines_mastodon = {
      certName    = "capitaines";
      hosts       = [ "mastodon.capitaines.fr" ];
      root        = root;
      extraConfig = [
        ''
        ErrorDocument 404 /index.html
        <Directory ${root}>
          DirectoryIndex index.html
          Options Indexes FollowSymLinks MultiViews Includes
          Require all granted
        </Directory>
          ''
      ];
    };

    services.myWebsites.production.vhostConfs.capitaines = {
      certName = "capitaines";
      hosts    = [ "capitaines.fr" ];
      root     = "/run/current-system/webapps/_www";
      extraConfig = [ ''
        <Directory /run/current-system/webapps/_www>
          DirectoryIndex index.htm
          Require all granted
        </Directory>
        '' ];
    };
  };
}