Added nix-serve config
Could use some work, but it works for now.
This commit is contained in:
parent
4536c79c68
commit
2627bc30d5
2 changed files with 57 additions and 28 deletions
52
modules/services/nix-serve/default.nix
Normal file
52
modules/services/nix-serve/default.nix
Normal file
|
@ -0,0 +1,52 @@
|
|||
{
|
||||
options,
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
format,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
cfg = config.aa.services.nix-serve;
|
||||
in {
|
||||
options.aa.services.nix-serve = with types; {
|
||||
enable = mkEnableOption "nix-serve";
|
||||
domain_name = mkOption {
|
||||
type = str;
|
||||
description = "The domain to use.";
|
||||
};
|
||||
subdomain_name = mkOption {
|
||||
type = str;
|
||||
description = "The subdomain to use.";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
services = {
|
||||
nix-serve = {
|
||||
enable = true;
|
||||
# TODO: Document this or automate the inital creation.
|
||||
secretKeyFile = "/var/gospelCache";
|
||||
};
|
||||
|
||||
nginx = {
|
||||
enable = true;
|
||||
virtualHosts = {
|
||||
"${cfg.subdomain_name}.${cfg.domain_name}" = {
|
||||
serverAliases = [${cfg.subdomain_name}];
|
||||
locations."/".extraConfig = ''
|
||||
proxy_pass http://localhost:${toString config.services.nix-serve.port};
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
networking.firewall = {
|
||||
allowedTCPPorts = [80];
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue