-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
537 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,7 @@ in { | |
gnupatch | ||
gnumake | ||
gawk | ||
just | ||
] | ||
++ optionals cfg.nix | ||
[statix alejandra] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
{ | ||
config, | ||
lib, | ||
... | ||
}: let | ||
inherit (lib) mkIf; | ||
inherit (lib.options) mkEnableOption; | ||
inherit (lib.lists) optional; | ||
cfg = config.my.www; | ||
in { | ||
options.my.www = { | ||
adventofcode = mkEnableOption "adventofcode"; | ||
aftgraphs = mkEnableOption "aftgraphs"; | ||
blog = mkEnableOption "blog"; | ||
}; | ||
|
||
config = mkIf cfg.blog { | ||
systemd.tmpfiles.rules = | ||
[ | ||
"d ${cfg.root}/${cfg.hostname} 0775 ${cfg.user} ${cfg.group} -" | ||
] | ||
++ optional cfg.adventofcode "d ${cfg.root}/advent2023 0775 ${cfg.user} ${cfg.group} -" | ||
++ optional cfg.aftgraphs "d ${cfg.root}/simulations 0775 ${cfg.user} ${cfg.group} -"; | ||
|
||
services.nginx.virtualHosts.${cfg.hostname} = { | ||
root = "${cfg.root}/${cfg.hostname}"; | ||
serverName = "${cfg.hostname} www.${cfg.hostname}"; | ||
kTLS = true; | ||
forceSSL = true; | ||
useACMEHost = cfg.hostname; | ||
|
||
locations = | ||
{ | ||
"/".tryFiles = "$uri $uri/ =404"; | ||
|
||
"/searx/${cfg.searx.subdomain}".return = mkIf cfg.searx.enable "https://${cfg.searx.subdomain}.${cfg.hostname}/static/?$args"; | ||
"/searx".return = mkIf cfg.searx.enable "https://${cfg.searx.subdomain}.${cfg.hostname}/?$args"; | ||
|
||
"/advent2023/" = mkIf cfg.adventofcode { | ||
alias = "${cfg.root}/advent2023/"; | ||
extraConfig = '' | ||
fancyindex on; | ||
fancyindex_exact_size off; | ||
fancyindex_localtime on; | ||
''; | ||
}; | ||
|
||
"/aftgraphs/" = mkIf cfg.aftgraphs { | ||
alias = "${cfg.root}/simulations/"; | ||
extraConfig = '' | ||
fancyindex on; | ||
fancyindex_exact_size off; | ||
fancyindex_localtime on; | ||
add_header "Cross-Origin-Opener-Policy" "same-origin"; | ||
add_header "Cross-Origin-Embedder-Policy" "require-corp"; | ||
''; | ||
}; | ||
} | ||
// cfg.acme-location-block; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
{ | ||
lib, | ||
config, | ||
pkgs, | ||
... | ||
}: let | ||
inherit (lib.options) mkOption; | ||
cfg = config.my.www; | ||
in { | ||
imports = [ | ||
./blog.nix | ||
./searx.nix | ||
]; | ||
|
||
options.my.www = { | ||
hostname = mkOption { | ||
default = "aftix.xyz"; | ||
type = lib.types.str; | ||
}; | ||
|
||
root = mkOption { | ||
default = "/srv"; | ||
type = lib.types.str; | ||
}; | ||
|
||
user = mkOption { | ||
default = "www"; | ||
type = lib.types.str; | ||
}; | ||
|
||
group = mkOption { | ||
default = "www"; | ||
type = lib.types.str; | ||
}; | ||
|
||
acme-location-block = mkOption { | ||
default = { | ||
"^~ /.well-known/acme-challenge".extraConfig = '' | ||
location ^~ /.well-known/acme-challenge/ { | ||
default_type "text/plain"; | ||
root ${cfg.root}/acme; | ||
} | ||
''; | ||
}; | ||
readOnly = true; | ||
}; | ||
}; | ||
|
||
config = { | ||
users = { | ||
users.${cfg.user} = { | ||
inherit (cfg) group; | ||
password = ""; | ||
shell = "/run/current-system/sw/bin/nologin"; | ||
isSystemUser = true; | ||
}; | ||
|
||
groups.${cfg.group} = {}; | ||
}; | ||
|
||
networking.firewall = { | ||
allowedTCPPorts = [80 443]; | ||
allowedUDPPorts = [80 443]; | ||
}; | ||
|
||
services.nginx = { | ||
inherit (cfg) user group; | ||
enable = true; | ||
enableReload = true; | ||
|
||
additionalModules = with pkgs.nginxModules; [fancyindex]; | ||
}; | ||
|
||
systemd.tmpfiles.rules = [ | ||
"d ${cfg.root} 0775 ${cfg.user} ${cfg.group} -" | ||
"d ${cfg.root}/acme 0775 ${cfg.user} ${cfg.group} -" | ||
]; | ||
|
||
security.acme = { | ||
acceptTerms = true; | ||
defaults = { | ||
email = "[email protected]"; | ||
webroot = cfg.root + "/acme"; | ||
}; | ||
|
||
certs.${cfg.hostname} = { | ||
inherit (cfg) group; | ||
extraDomainNames = ["www.${cfg.hostname}"]; | ||
}; | ||
}; | ||
}; | ||
} |
Oops, something went wrong.