From c37dc0dbf1d43b2c4ed4adf7c57db8dcb670b9f3 Mon Sep 17 00:00:00 2001 From: Adithya Nair Date: Sat, 28 Oct 2023 04:31:09 +0530 Subject: [PATCH] move adtya.xyz and refactor --- flake.lock | 77 ++++++++++++++++--- flake.nix | 6 ++ hosts/rico2/containers/default.nix | 2 +- .../{containers => services}/adtya.xyz.nix | 19 +++-- hosts/rico2/services/caddy.nix | 9 --- hosts/rico2/services/default.nix | 2 +- hosts/rico2/services/if3.nix | 15 ++++ 7 files changed, 100 insertions(+), 30 deletions(-) rename hosts/rico2/{containers => services}/adtya.xyz.nix (71%) create mode 100644 hosts/rico2/services/if3.nix diff --git a/flake.lock b/flake.lock index b6d21e4..d6a4ac0 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,26 @@ { "nodes": { + "adtya-xyz": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1698447246, + "narHash": "sha256-CfbEtQHk2l+zprXNSpyYu+gNl3cJX9h9qz23SWfxWBM=", + "owner": "adtya", + "repo": "adtya.xyz", + "rev": "db0a9ddacdc10a7441de375f8f11824f38923677", + "type": "github" + }, + "original": { + "owner": "adtya", + "repo": "adtya.xyz", + "type": "github" + } + }, "beautysh": { "inputs": { "nixpkgs": [ @@ -120,11 +141,11 @@ "systems": "systems_2" }, "locked": { - "lastModified": 1689068808, - "narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=", + "lastModified": 1694529238, + "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", "owner": "numtide", "repo": "flake-utils", - "rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4", + "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", "type": "github" }, "original": { @@ -138,11 +159,11 @@ "systems": "systems_3" }, "locked": { - "lastModified": 1694529238, - "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", + "lastModified": 1689068808, + "narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=", "owner": "numtide", "repo": "flake-utils", - "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", + "rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4", "type": "github" }, "original": { @@ -173,6 +194,24 @@ "inputs": { "systems": "systems_5" }, + "locked": { + "lastModified": 1694529238, + "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_6": { + "inputs": { + "systems": "systems_6" + }, "locked": { "lastModified": 1685518550, "narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=", @@ -253,7 +292,7 @@ }, "if3": { "inputs": { - "flake-utils": "flake-utils_2", + "flake-utils": "flake-utils_3", "nixpkgs": [ "nixpkgs" ] @@ -292,7 +331,7 @@ "crane": "crane", "flake-compat": "flake-compat", "flake-parts": "flake-parts", - "flake-utils": "flake-utils_3", + "flake-utils": "flake-utils_4", "nixpkgs": [ "nixpkgs" ], @@ -364,7 +403,7 @@ "nixvim": { "inputs": { "beautysh": "beautysh", - "flake-utils": "flake-utils_4", + "flake-utils": "flake-utils_5", "nixpkgs": [ "nixpkgs" ], @@ -414,7 +453,7 @@ "pre-commit-hooks": { "inputs": { "flake-compat": "flake-compat_2", - "flake-utils": "flake-utils_5", + "flake-utils": "flake-utils_6", "gitignore": "gitignore_2", "nixpkgs": [ "nixvim", @@ -469,7 +508,8 @@ }, "root": { "inputs": { - "flake-utils": "flake-utils", + "adtya-xyz": "adtya-xyz", + "flake-utils": "flake-utils_2", "home-manager": "home-manager", "if3": "if3", "impermanence": "impermanence", @@ -578,6 +618,21 @@ "type": "github" } }, + "systems_6": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, "utils": { "locked": { "lastModified": 1678901627, diff --git a/flake.nix b/flake.nix index 36de339..7f304e6 100644 --- a/flake.nix +++ b/flake.nix @@ -29,6 +29,11 @@ inputs.nixpkgs.follows = "nixpkgs"; }; + adtya-xyz = { + url = "github:adtya/adtya.xyz"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + if3 = { url = "github:adtya/if3-docs"; inputs.nixpkgs.follows = "nixpkgs"; @@ -43,6 +48,7 @@ impermanence, lanzaboote, nixvim, + adtya-xyz, if3, } @ inputs: let secrets = import ./secrets.nix; diff --git a/hosts/rico2/containers/default.nix b/hosts/rico2/containers/default.nix index 27576c2..dd5a697 100644 --- a/hosts/rico2/containers/default.nix +++ b/hosts/rico2/containers/default.nix @@ -1,5 +1,5 @@ {...}: { - imports = [./adtya.xyz.nix]; + imports = []; virtualisation.oci-containers = { backend = "podman"; diff --git a/hosts/rico2/containers/adtya.xyz.nix b/hosts/rico2/services/adtya.xyz.nix similarity index 71% rename from hosts/rico2/containers/adtya.xyz.nix rename to hosts/rico2/services/adtya.xyz.nix index 15c11c2..ae19722 100644 --- a/hosts/rico2/containers/adtya.xyz.nix +++ b/hosts/rico2/services/adtya.xyz.nix @@ -1,14 +1,10 @@ -_: { - virtualisation.oci-containers.containers."adtya.xyz" = { - image = "ghcr.io/adtya/adtya.xyz:latest"; - ports = ["3000:80"]; - }; - +{ + config, + adtya-xyz, +}: { services.caddy.virtualHosts."adtya.xyz" = { serverAliases = ["www.adtya.xyz"]; extraConfig = '' - reverse_proxy http://127.0.0.1:3000 - handle /.well-known/matrix/server { header Content-Type application/json header Access-Control-Allow-Origin * @@ -20,6 +16,13 @@ _: { header Access-Control-Allow-Origin * respond `{"m.homeserver": {"base_url": "https://matrix.adtya.xyz:443"}}` } + + handle { + root * ${adtya-xyz.packages.${config.nixpkgs.system}.default}/share/web + encode gzip + try_files {path} /index.html + file_server + } ''; }; } diff --git a/hosts/rico2/services/caddy.nix b/hosts/rico2/services/caddy.nix index b4b1bae..cfaed5b 100644 --- a/hosts/rico2/services/caddy.nix +++ b/hosts/rico2/services/caddy.nix @@ -14,15 +14,6 @@ redir https://keyoxide.org/hkp/${secrets.users.primary.pgpFingerprint} ''; }; - - "if3.adtya.xyz" = { - extraConfig = '' - root * ${if3.packages.${config.nixpkgs.system}.default}/share/web - encode gzip - try_files {path} /index.html - file_server - ''; - }; }; }; } diff --git a/hosts/rico2/services/default.nix b/hosts/rico2/services/default.nix index 46968a6..e151181 100644 --- a/hosts/rico2/services/default.nix +++ b/hosts/rico2/services/default.nix @@ -1,3 +1,3 @@ {...}: { - imports = [./caddy.nix ./frpc.nix ./ssh.nix]; + imports = [./adtya.xyz.nix ./caddy.nix ./frpc.nix ./if3.nix ./ssh.nix]; } diff --git a/hosts/rico2/services/if3.nix b/hosts/rico2/services/if3.nix new file mode 100644 index 0000000..21d0c09 --- /dev/null +++ b/hosts/rico2/services/if3.nix @@ -0,0 +1,15 @@ +{ + config, + if3, +}: { + services.caddy.virtualHosts = { + "if3.adtya.xyz" = { + extraConfig = '' + root * ${if3.packages.${config.nixpkgs.system}.default}/share/web + encode gzip + try_files {path} /index.html + file_server + ''; + }; + }; +}