Sites statiques, my
This commit is contained in:
parent
dec8f0d43d
commit
72bde6e8d8
8 changed files with 107 additions and 26 deletions
|
@ -10,12 +10,17 @@
|
||||||
./hardware-configuration.nix
|
./hardware-configuration.nix
|
||||||
./physical.nix
|
./physical.nix
|
||||||
../../profiles/core-hackens
|
../../profiles/core-hackens
|
||||||
|
./hackens-my.nix
|
||||||
|
#Services
|
||||||
./wiki.nix
|
./wiki.nix
|
||||||
./webpass.nix
|
./webpass.nix
|
||||||
|
./test-static.nix
|
||||||
# ./bridge.nix
|
# ./bridge.nix
|
||||||
# ./gha.nix
|
# ./gha.nix
|
||||||
# ./sync.nix
|
# ./sync.nix
|
||||||
|
#Modules
|
||||||
./misc
|
./misc
|
||||||
|
./modules
|
||||||
];
|
];
|
||||||
|
|
||||||
networking.hostName = "hackens-org"; # Define your hostname.
|
networking.hostName = "hackens-org"; # Define your hostname.
|
||||||
|
|
10
hosts/hackens-org/hackens-my.nix
Normal file
10
hosts/hackens-org/hackens-my.nix
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
# Inspire du club reseau
|
||||||
|
{ ... }:
|
||||||
|
{
|
||||||
|
imports = [ ./my.nix ];
|
||||||
|
|
||||||
|
my = {
|
||||||
|
email = "hackens@clipper.ens.fr";
|
||||||
|
acmeStaging = true;
|
||||||
|
};
|
||||||
|
}
|
13
hosts/hackens-org/modules/acme-ssl.nix
Normal file
13
hosts/hackens-org/modules/acme-ssl.nix
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
# Issue du club reseau
|
||||||
|
{ config, ... }:
|
||||||
|
let
|
||||||
|
my = config.my;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
security.acme.acceptTerms = true;
|
||||||
|
security.acme.email = my.email;
|
||||||
|
security.acme.server =
|
||||||
|
if my.acmeStaging
|
||||||
|
then "https://acme-staging-v02.api.letsencrypt.org/directory"
|
||||||
|
else null;
|
||||||
|
}
|
9
hosts/hackens-org/modules/default.nix
Normal file
9
hosts/hackens-org/modules/default.nix
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
{ pkgs, ... }:
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
./my.nix
|
||||||
|
./acme-ssl.nix
|
||||||
|
./staticWebsite.nix
|
||||||
|
./nginx.nix
|
||||||
|
];
|
||||||
|
}
|
27
hosts/hackens-org/modules/my.nix
Normal file
27
hosts/hackens-org/modules/my.nix
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
# Inspiré du club réseau
|
||||||
|
{ config, lib, ... }:
|
||||||
|
with lib;
|
||||||
|
{
|
||||||
|
options.my = {
|
||||||
|
email = mkOption {
|
||||||
|
description = "Admin email";
|
||||||
|
type = str;
|
||||||
|
default = "";
|
||||||
|
example = "hackens@clipper.ens.fr";
|
||||||
|
};
|
||||||
|
acmeStaging = mkOption {
|
||||||
|
description = "Enable staging servers";
|
||||||
|
type = bool;
|
||||||
|
default = false;
|
||||||
|
};
|
||||||
|
subZone = mkOption {
|
||||||
|
description = "Sub zone for hosting the services";
|
||||||
|
type = str
|
||||||
|
|
||||||
|
debug = mkOption {
|
||||||
|
description = "Debug mode";
|
||||||
|
type = bool;
|
||||||
|
default = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
|
@ -1,26 +0,0 @@
|
||||||
{ lib, config }:
|
|
||||||
|
|
||||||
with lib;
|
|
||||||
let
|
|
||||||
cfg = config.services.static-website.config;
|
|
||||||
l = builtins.split cfg.name "/";
|
|
||||||
name = lists.last l;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
services.static-website.config = lib.mkOption {
|
|
||||||
type = with types; attrsOf (submodule {
|
|
||||||
options.name = mkOption path;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
config = {
|
|
||||||
services.nginx.enable = cfg.enable;
|
|
||||||
virtualHosts."${cfg.name}" = {
|
|
||||||
root = "/var/lib/nginx/static/${name}";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/* TODO
|
|
||||||
ACME
|
|
||||||
*/
|
|
39
hosts/hackens-org/modules/staticWebsite.nix
Normal file
39
hosts/hackens-org/modules/staticWebsite.nix
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
{ lib, config }:
|
||||||
|
with lib;
|
||||||
|
let
|
||||||
|
eachSite = config.services.static-website;
|
||||||
|
website = { pkgs, config, name, ... }: {
|
||||||
|
options = {
|
||||||
|
root = mkOption {
|
||||||
|
type = types.path;
|
||||||
|
default = "/var/lib/nginx/static/${name}";
|
||||||
|
description = "Static files path for the website";
|
||||||
|
};
|
||||||
|
hostname = mkOption {
|
||||||
|
type = str;
|
||||||
|
default = name;
|
||||||
|
description = "Website hostname";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
debug = config.my.debug;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
services.staticWebsite = lib.mkOption {
|
||||||
|
type = types.attrsOf (types.submodule website;)
|
||||||
|
description = "Specification of one or more static-websites to serve";
|
||||||
|
};
|
||||||
|
|
||||||
|
config = (mkIf eachSite != {}) {
|
||||||
|
services.nginx.enable = cfg;
|
||||||
|
virtualHosts = mapAttrs ( hostName: conf: {
|
||||||
|
serverName = conf.path;
|
||||||
|
root = conf.root;
|
||||||
|
forceSSL = if debug then false else true;
|
||||||
|
}) eachSite;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/* TODO
|
||||||
|
ACME
|
||||||
|
*/
|
4
hosts/hackens-org/test-static.nix
Normal file
4
hosts/hackens-org/test-static.nix
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
{ config, ... }:
|
||||||
|
{
|
||||||
|
services.staticWebsite.testStatic.hostname = "test.${my.subZone}";
|
||||||
|
}
|
Loading…
Reference in a new issue