moves site to ily.rs, guestbook to ily.rs/guestbook/, and shlink to ily.rs/fallback
This commit is contained in:
parent
15ff8fc5fe
commit
ae62b54e46
6 changed files with 97 additions and 58 deletions
20
flake.lock
generated
20
flake.lock
generated
|
|
@ -40,11 +40,11 @@
|
||||||
"nixpkgs": "nixpkgs"
|
"nixpkgs": "nixpkgs"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1777387836,
|
"lastModified": 1777423248,
|
||||||
"narHash": "sha256-TdD6RNAAYA3KurypwKdSb1sMhK8TZBcHy+68dKsaM/Y=",
|
"narHash": "sha256-2ucoklbxRyOSUUW4W0hDQ3enWYJmpcLSvO52k9Xm5Kw=",
|
||||||
"ref": "refs/heads/main",
|
"ref": "refs/heads/main",
|
||||||
"rev": "b784f4dd9c3708d64288c11dbcffcb41c02a1478",
|
"rev": "6ca40e23219c34994cceeb358fe36a8dab06cea2",
|
||||||
"revCount": 109,
|
"revCount": 110,
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://git.ily.rs/lew/guestbook"
|
"url": "https://git.ily.rs/lew/guestbook"
|
||||||
},
|
},
|
||||||
|
|
@ -71,11 +71,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs_2": {
|
"nixpkgs_2": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1775002709,
|
"lastModified": 1777077449,
|
||||||
"narHash": "sha256-d3Yx83vSrN+2z/loBh4mJpyRqr9aAJqlke4TkpFmRJA=",
|
"narHash": "sha256-AIiMJiqvGrN4HyLEbKAoCSRRYn0rnlW5VbKNIMIYqm4=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "bcd464ccd2a1a7cd09aa2f8d4ffba83b761b1d0e",
|
"rev": "a4bf06618f0b5ee50f14ed8f0da77d34ecc19160",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -99,11 +99,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1775188331,
|
"lastModified": 1777338324,
|
||||||
"narHash": "sha256-/0BoSi0Dg0ON7IW0oscM12WSPBaMSCn36XTt0lHZoy8=",
|
"narHash": "sha256-bc+ZZCmOTNq86/svGnw0tVpH7vJaLYvGLLKFYP08Q8E=",
|
||||||
"owner": "Mic92",
|
"owner": "Mic92",
|
||||||
"repo": "sops-nix",
|
"repo": "sops-nix",
|
||||||
"rev": "8f093d0d2f08f37317778bd94db5951d6cce6c46",
|
"rev": "8eaee5c45428b28b8c47a83e4c09dccec5f279b5",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
||||||
|
|
@ -14,16 +14,7 @@
|
||||||
group = "guestbook";
|
group = "guestbook";
|
||||||
|
|
||||||
siteTitle = "ily [dot] rs";
|
siteTitle = "ily [dot] rs";
|
||||||
caddy = {
|
basePath = "/guestbook";
|
||||||
enable = true;
|
|
||||||
domain = "g.ily.rs";
|
|
||||||
forwardAuth = {
|
|
||||||
enable = true;
|
|
||||||
address = "localhost:3002";
|
|
||||||
uri = "/api/auth/caddy";
|
|
||||||
copyHeaders = [ "Remote-User" "Remote-Name" "Remote-Email" "Remote-Groups" ];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
submissions.enable = true;
|
submissions.enable = true;
|
||||||
websites.enable = true;
|
websites.enable = true;
|
||||||
|
|
|
||||||
|
|
@ -38,13 +38,6 @@
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
services.caddy.virtualHosts."ily.rs" = {
|
|
||||||
extraConfig = ''
|
|
||||||
reverse_proxy localhost:8080
|
|
||||||
encode zstd gzip
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
services.caddy.virtualHosts."links.ily.rs" = {
|
services.caddy.virtualHosts."links.ily.rs" = {
|
||||||
extraConfig = ''
|
extraConfig = ''
|
||||||
@health path /health-ping
|
@health path /health-ping
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,10 @@
|
||||||
# redirectDomains — domains that 301 to the primary domain (default: [])
|
# redirectDomains — domains that 301 to the primary domain (default: [])
|
||||||
# branch — git branch to track (default: "main")
|
# branch — git branch to track (default: "main")
|
||||||
# packageManager — "npm" or "pnpm" (default: "pnpm")
|
# packageManager — "npm" or "pnpm" (default: "pnpm")
|
||||||
|
# installCommand — override install command, "" skips, null derives from packageManager (default: null)
|
||||||
|
# buildCommand — override build command, null derives from packageManager (default: null)
|
||||||
|
# extraBuildPackages — extra packages on PATH during build, e.g. zola (default: [])
|
||||||
|
# caddyConfig — override Caddy extraConfig for primary domain, null uses default (default: null)
|
||||||
# entryPoint — Node.js entry point relative to repo root (default: "dist/server/entry.mjs")
|
# entryPoint — Node.js entry point relative to repo root (default: "dist/server/entry.mjs")
|
||||||
# environment — env vars for the running server (default: {})
|
# environment — env vars for the running server (default: {})
|
||||||
# buildEnvironment — env vars for building (default: {})
|
# buildEnvironment — env vars for building (default: {})
|
||||||
|
|
@ -26,24 +30,40 @@
|
||||||
# Forgejo repo -> settings -> Webhooks -> Add webhook
|
# Forgejo repo -> settings -> Webhooks -> Add webhook
|
||||||
# - preview webhook: http://localhost:4323/hooks/${name}-preview-rebuild
|
# - preview webhook: http://localhost:4323/hooks/${name}-preview-rebuild
|
||||||
|
|
||||||
{ ... }:
|
{ pkgs, ... }:
|
||||||
let
|
|
||||||
websiteData = "/srv/website/data";
|
|
||||||
in
|
|
||||||
{
|
{
|
||||||
services.site.website = {
|
services.site.website = {
|
||||||
enable = true;
|
enable = true;
|
||||||
domain = "wynne.rs";
|
domain = "ily.rs";
|
||||||
|
redirectDomains = [ "wynne.rs" ];
|
||||||
repo = "https://git.ily.rs/lew/website";
|
repo = "https://git.ily.rs/lew/website";
|
||||||
branch = "master";
|
branch = "master";
|
||||||
port = 4322;
|
static = true;
|
||||||
environment = {
|
buildOutputDir = "public";
|
||||||
ASTRO_DB_REMOTE_URL = "file:${websiteData}/guestbook.db";
|
installCommand = "";
|
||||||
};
|
buildCommand = "zola build";
|
||||||
buildEnvironment = {
|
extraBuildPackages = [ pkgs.zola ];
|
||||||
ASTRO_DB_REMOTE_URL = "file:${websiteData}/guestbook.db";
|
caddyConfig = ''
|
||||||
};
|
root * /srv/website/repo/public
|
||||||
readWritePaths = [ websiteData ];
|
encode zstd gzip
|
||||||
|
|
||||||
|
@guestbook path /guestbook /guestbook/*
|
||||||
|
handle @guestbook {
|
||||||
|
reverse_proxy localhost:8123
|
||||||
|
}
|
||||||
|
|
||||||
|
@site_file file {
|
||||||
|
try_files {path} {path}/index.html
|
||||||
|
}
|
||||||
|
handle @site_file {
|
||||||
|
try_files {path} {path}/index.html
|
||||||
|
file_server
|
||||||
|
}
|
||||||
|
|
||||||
|
handle {
|
||||||
|
reverse_proxy localhost:8080
|
||||||
|
}
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
services.site.penfield = {
|
services.site.penfield = {
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
<div class="page-container">
|
<div class="page-container">
|
||||||
Thanks! Your message is pending approval.
|
Thanks! Your message is pending approval.
|
||||||
|
|
||||||
<a href="/">← back</a>
|
<a href="{{base}}/">← back</a>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,30 @@ let
|
||||||
default = "pnpm";
|
default = "pnpm";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
installCommand = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = null;
|
||||||
|
description = "Override install command. Empty string skips install. Null derives from packageManager.";
|
||||||
|
};
|
||||||
|
|
||||||
|
buildCommand = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = null;
|
||||||
|
description = "Override build command. Null derives from packageManager (`<pm> run build`).";
|
||||||
|
};
|
||||||
|
|
||||||
|
extraBuildPackages = mkOption {
|
||||||
|
type = types.listOf types.package;
|
||||||
|
default = [];
|
||||||
|
description = "Extra packages on PATH during build (e.g. zola).";
|
||||||
|
};
|
||||||
|
|
||||||
|
caddyConfig = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = null;
|
||||||
|
description = "Override Caddy extraConfig for the primary domain. Null uses the default static or reverse_proxy block.";
|
||||||
|
};
|
||||||
|
|
||||||
entryPoint = mkOption {
|
entryPoint = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "dist/server/entry.mjs";
|
default = "dist/server/entry.mjs";
|
||||||
|
|
@ -120,12 +144,19 @@ let
|
||||||
if site.packageManager == "pnpm"
|
if site.packageManager == "pnpm"
|
||||||
then "${pkgs.pnpm}/bin/pnpm"
|
then "${pkgs.pnpm}/bin/pnpm"
|
||||||
else "${pkgs.nodejs}/bin/npm";
|
else "${pkgs.nodejs}/bin/npm";
|
||||||
installCmd =
|
defaultInstall =
|
||||||
if site.packageManager == "pnpm"
|
if site.packageManager == "pnpm"
|
||||||
then "${pmBin} install --frozen-lockfile"
|
then "${pmBin} install --frozen-lockfile"
|
||||||
else "${pmBin} ci";
|
else "${pmBin} ci";
|
||||||
|
defaultBuild = "${pmBin} run build";
|
||||||
|
installCmd =
|
||||||
|
if site.installCommand == null then defaultInstall
|
||||||
|
else site.installCommand;
|
||||||
|
buildCmd =
|
||||||
|
if site.buildCommand == null then defaultBuild
|
||||||
|
else site.buildCommand;
|
||||||
in
|
in
|
||||||
{ inherit pmBin installCmd; dataDir = site.dataDir; };
|
{ inherit pmBin installCmd buildCmd; dataDir = site.dataDir; };
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.services.site = mkOption {
|
options.services.site = mkOption {
|
||||||
|
|
@ -142,7 +173,9 @@ in
|
||||||
|
|
||||||
services.caddy.virtualHosts = mkMerge ((mapAttrsToList (name: site:
|
services.caddy.virtualHosts = mkMerge ((mapAttrsToList (name: site:
|
||||||
{
|
{
|
||||||
${site.domain}.extraConfig = if site.static then ''
|
${site.domain}.extraConfig =
|
||||||
|
if site.caddyConfig != null then site.caddyConfig
|
||||||
|
else if site.static then ''
|
||||||
root * ${site.dataDir}/repo/${site.buildOutputDir}
|
root * ${site.dataDir}/repo/${site.buildOutputDir}
|
||||||
encode zstd gzip
|
encode zstd gzip
|
||||||
try_files {path} /index.html
|
try_files {path} /index.html
|
||||||
|
|
@ -191,7 +224,8 @@ in
|
||||||
description = "Clone/pull and build ${site.domain}";
|
description = "Clone/pull and build ${site.domain}";
|
||||||
after = [ "network-online.target" ] ++ site.afterServices;
|
after = [ "network-online.target" ] ++ site.afterServices;
|
||||||
path = [ pkgs.nodejs pkgs.bash ]
|
path = [ pkgs.nodejs pkgs.bash ]
|
||||||
++ optional (site.packageManager == "pnpm") pkgs.pnpm;
|
++ optional (site.packageManager == "pnpm") pkgs.pnpm
|
||||||
|
++ site.extraBuildPackages;
|
||||||
environment = site.buildEnvironment;
|
environment = site.buildEnvironment;
|
||||||
wants = [ "network-online.target" ];
|
wants = [ "network-online.target" ];
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
|
@ -210,8 +244,8 @@ in
|
||||||
cd ${h.dataDir}/repo
|
cd ${h.dataDir}/repo
|
||||||
${pkgs.git}/bin/git fetch origin
|
${pkgs.git}/bin/git fetch origin
|
||||||
${pkgs.git}/bin/git reset --hard origin/${site.branch}
|
${pkgs.git}/bin/git reset --hard origin/${site.branch}
|
||||||
${h.installCmd}
|
${lib.optionalString (h.installCmd != "") h.installCmd}
|
||||||
${h.pmBin} run build
|
${h.buildCmd}
|
||||||
'';
|
'';
|
||||||
ExecStartPost = lib.mkIf (!site.static)
|
ExecStartPost = lib.mkIf (!site.static)
|
||||||
"+/run/current-system/sw/bin/systemctl restart ${name}";
|
"+/run/current-system/sw/bin/systemctl restart ${name}";
|
||||||
|
|
@ -247,7 +281,8 @@ in
|
||||||
description = "Clone/pull and build preview of ${site.domain}";
|
description = "Clone/pull and build preview of ${site.domain}";
|
||||||
after = [ "network-online.target" ] ++ site.afterServices;
|
after = [ "network-online.target" ] ++ site.afterServices;
|
||||||
path = [ pkgs.nodejs pkgs.bash ]
|
path = [ pkgs.nodejs pkgs.bash ]
|
||||||
++ optional (site.packageManager == "pnpm") pkgs.pnpm;
|
++ optional (site.packageManager == "pnpm") pkgs.pnpm
|
||||||
|
++ site.extraBuildPackages;
|
||||||
environment = site.buildEnvironment;
|
environment = site.buildEnvironment;
|
||||||
wants = [ "network-online.target" ];
|
wants = [ "network-online.target" ];
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
|
@ -266,8 +301,8 @@ in
|
||||||
cd ${previewDataDir}/repo
|
cd ${previewDataDir}/repo
|
||||||
${pkgs.git}/bin/git fetch origin
|
${pkgs.git}/bin/git fetch origin
|
||||||
${pkgs.git}/bin/git reset --hard origin/${site.preview.branch}
|
${pkgs.git}/bin/git reset --hard origin/${site.preview.branch}
|
||||||
${h.installCmd}
|
${lib.optionalString (h.installCmd != "") h.installCmd}
|
||||||
${h.pmBin} run build
|
${h.buildCmd}
|
||||||
'';
|
'';
|
||||||
ExecStartPost = lib.mkIf (!site.static)
|
ExecStartPost = lib.mkIf (!site.static)
|
||||||
"+/run/current-system/sw/bin/systemctl restart ${previewUser}";
|
"+/run/current-system/sw/bin/systemctl restart ${previewUser}";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue