Sites statique #5

Open
sinavir wants to merge 12 commits from static_website into master
2 changed files with 42 additions and 7 deletions
Showing only changes of commit 083b638d77 - Show all commits

View file

@ -0,0 +1,15 @@
{ config, pkgs, ... }:
{
staticWebsites.sites = {
"2048" = {
root = pkgs.fetchFromGitHub {
owner = "hackEns";
repo = "2048NdS";
rev = "1df6db154ca22c380eb52844c7a6a7f888fb5610";
sha256 = "087471kpbpcg5920wy6fgcx6jz613zbyy0jn5iiimwjk1im1wa4q";
};
hostname = config.my.subZone;
location = "/2048";
};
};
}

View file

@ -1,7 +1,7 @@
{ lib, config , ... }:
with lib;
let
eachSite = config.services.staticWebsites;
eachSite = config.services.staticWebsites.sites;
website = { name, ... }: {
options = {
root = mkOption {
@ -14,6 +14,11 @@ let
default = name;
description = "Website hostname";
};
location = mkOption {
type = types.nullOr types.str;
default = null;
description = "Add a location rule if not null";
};
};
};
in
@ -31,12 +36,27 @@ in
config = mkIf (eachSite != {}) {
services.nginx = {
enable = true;
virtualHosts = mapAttrs ( hostName: conf: {
virtualHosts = mapAttrs ( hostName: conf: (mkMerge [
{
serverName = conf.hostname;
root = conf.root;
forceSSL = if debug then false else true;
enableACME = if debug then false else true;
}) eachSite;
}
(mkIf (conf.location == null) {
root = conf.root;
})
(mkIf (conf.location != null) {
location = {
"~ ^${conf.location}" = {
alias = conf.root;
};
};
})
])
) eachSite;
};
};
}