Sites statique #5
2 changed files with 42 additions and 7 deletions
15
hosts/hackens-org/2048.nix
Normal file
15
hosts/hackens-org/2048.nix
Normal 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";
|
||||
};
|
||||
};
|
||||
}
|
|
@ -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: {
|
||||
serverName = conf.hostname;
|
||||
root = conf.root;
|
||||
forceSSL = if debug then false else true;
|
||||
enableACME = if debug then false else true;
|
||||
}) eachSite;
|
||||
virtualHosts = mapAttrs ( hostName: conf: (mkMerge [
|
||||
{
|
||||
serverName = conf.hostname;
|
||||
forceSSL = if debug then false else true;
|
||||
enableACME = if debug then false else true;
|
||||
}
|
||||
|
||||
(mkIf (conf.location == null) {
|
||||
root = conf.root;
|
||||
})
|
||||
|
||||
(mkIf (conf.location != null) {
|
||||
location = {
|
||||
"~ ^${conf.location}" = {
|
||||
alias = conf.root;
|
||||
};
|
||||
};
|
||||
})
|
||||
|
||||
])
|
||||
) eachSite;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue