From 36629f6d02fe57d544925e27e95b05e4ceda1348 Mon Sep 17 00:00:00 2001 From: Chris Kruining Date: Tue, 23 Sep 2025 16:18:19 +0200 Subject: [PATCH] WIP: add customer-portal module --- clanServices/customer-portal/README.md | 0 clanServices/customer-portal/default.nix | 35 ++++ clanServices/customer-portal/flake-module.nix | 15 ++ .../customer-portal/tests/vm/default.nix | 37 +++++ flake.lock | 156 +++++++++++++++++- flake.nix | 4 + 6 files changed, 242 insertions(+), 5 deletions(-) create mode 100644 clanServices/customer-portal/README.md create mode 100644 clanServices/customer-portal/default.nix create mode 100644 clanServices/customer-portal/flake-module.nix create mode 100644 clanServices/customer-portal/tests/vm/default.nix diff --git a/clanServices/customer-portal/README.md b/clanServices/customer-portal/README.md new file mode 100644 index 0000000..e69de29 diff --git a/clanServices/customer-portal/default.nix b/clanServices/customer-portal/default.nix new file mode 100644 index 0000000..dbbe7e6 --- /dev/null +++ b/clanServices/customer-portal/default.nix @@ -0,0 +1,35 @@ +{ ... }: +let + inherit (builtins) readFile; +in +{ + _class = "clan.service"; + + manifest = { + name = "amarth-services/customer-portal"; + description = "Service to host Amarth Cloud's customer-portal"; + categories = [ "System" "Network" "Containers" "Virtualisation" ]; + readme = readFile ./README.md; + }; + + #============================================================================================================== + # Server configuration + #============================================================================================================== + roles.server = { + interface = { lib, ... }: + let + inherit (lib) mkOption types toString; + in + { + options = {}; + }; + + perInstance = { instanceName, settings, machine, roles, ... }: { + nixosModule = { config, pkgs, ... }: { + services.amarth-customer-portal = { + enable = true; + }; + }; + }; + }; +} diff --git a/clanServices/customer-portal/flake-module.nix b/clanServices/customer-portal/flake-module.nix new file mode 100644 index 0000000..fe21877 --- /dev/null +++ b/clanServices/customer-portal/flake-module.nix @@ -0,0 +1,15 @@ +{ ... }: +let + module = ./default.nix; +in +{ + clan.modules.customer-portal = module; + + perSystem = { ... }: { + clan.nixosTests.customer-portal = { + imports = [ ./tests/vm/default.nix ]; + + clan.modules."@amarth/customer-portal" = module; + }; + }; +} diff --git a/clanServices/customer-portal/tests/vm/default.nix b/clanServices/customer-portal/tests/vm/default.nix new file mode 100644 index 0000000..01c2fa1 --- /dev/null +++ b/clanServices/customer-portal/tests/vm/default.nix @@ -0,0 +1,37 @@ +{ pkgs, ... }: +{ + name = "service-customer-portal"; + + clan = { + directory = ./.; + + inventory = { + machines = { + node1 = {}; + }; + + instances = { + customer-portal = { + module = { + name = "@amarth/customer-portal"; + input = "self"; + }; + + roles.server.machines."node1" = {}; + }; + }; + }; + + machines = { + node1 = {}; + }; + }; + + nodes = { + node1 = {}; + }; + + testScript = '' + start_all() + ''; +} diff --git a/flake.lock b/flake.lock index 3f19c1b..f0513cb 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,76 @@ { "nodes": { + "amarth-customer-portal": { + "inputs": { + "bun2nix": "bun2nix", + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1758634522, + "narHash": "sha256-Y5J+yCAbNZnPhrCvrTjhGUTD5amONxH/R/MGqwm0uIc=", + "ref": "refs/heads/main", + "rev": "e7b0307690730781d9908cf3a48b9081b9ffe87c", + "revCount": 23, + "type": "git", + "url": "https://git.amarth.cloud/amarth/customer-portal" + }, + "original": { + "type": "git", + "url": "https://git.amarth.cloud/amarth/customer-portal" + } + }, + "blueprint": { + "inputs": { + "nixpkgs": [ + "amarth-customer-portal", + "bun2nix", + "nixpkgs" + ], + "systems": [ + "amarth-customer-portal", + "bun2nix", + "systems" + ] + }, + "locked": { + "lastModified": 1744632722, + "narHash": "sha256-0chvqUV1Kzf8BMQ7MsH3CeicJEb2HeCpwliS77FGyfc=", + "owner": "numtide", + "repo": "blueprint", + "rev": "49bbd5d072b577072f4a1d07d4b0621ecce768af", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "blueprint", + "type": "github" + } + }, + "bun2nix": { + "inputs": { + "blueprint": "blueprint", + "nixpkgs": [ + "amarth-customer-portal", + "nixpkgs" + ], + "systems": "systems", + "treefmt-nix": "treefmt-nix" + }, + "locked": { + "lastModified": 1758108094, + "narHash": "sha256-ZO7dOTEipchkK/2mX6uAGbe6zQXnvHr40ri6jOztNR4=", + "owner": "baileyluTCD", + "repo": "bun2nix", + "rev": "72c047583edc83e2c2eada6e348dfaa622781331", + "type": "github" + }, + "original": { + "owner": "baileyluTCD", + "repo": "bun2nix", + "type": "github" + } + }, "clan-core": { "inputs": { "data-mesher": "data-mesher", @@ -14,8 +85,8 @@ "nixpkgs" ], "sops-nix": "sops-nix", - "systems": "systems", - "treefmt-nix": "treefmt-nix" + "systems": "systems_2", + "treefmt-nix": "treefmt-nix_2" }, "locked": { "lastModified": 1758121565, @@ -78,6 +149,27 @@ } }, "flake-parts": { + "inputs": { + "nixpkgs-lib": [ + "amarth-customer-portal", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1756770412, + "narHash": "sha256-+uWLQZccFHwqpGqr2Yt5VsW/PbeJVTn9Dk6SHWhNRPw=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "4524271976b625a4a605beefd893f270620fd751", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-parts_2": { "inputs": { "nixpkgs-lib": [ "nixpkgs" @@ -147,6 +239,22 @@ } }, "nixpkgs": { + "locked": { + "lastModified": 1758035966, + "narHash": "sha256-qqIJ3yxPiB0ZQTT9//nFGQYn8X/PBoJbofA7hRKZnmE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "8d4ddb19d03c65a36ad8d189d001dc32ffb0306b", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { "locked": { "lastModified": 1757745802, "narHash": "sha256-hLEO2TPj55KcUFUU1vgtHE9UEIOjRcH/4QbmfHNF820=", @@ -164,10 +272,11 @@ }, "root": { "inputs": { + "amarth-customer-portal": "amarth-customer-portal", "clan-core": "clan-core", - "flake-parts": "flake-parts", - "nixpkgs": "nixpkgs", - "systems": "systems_2" + "flake-parts": "flake-parts_2", + "nixpkgs": "nixpkgs_2", + "systems": "systems_3" } }, "sops-nix": { @@ -221,7 +330,44 @@ "type": "github" } }, + "systems_3": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, "treefmt-nix": { + "inputs": { + "nixpkgs": [ + "amarth-customer-portal", + "bun2nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1748243702, + "narHash": "sha256-9YzfeN8CB6SzNPyPm2XjRRqSixDopTapaRsnTpXUEY8=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "1f3f7b784643d488ba4bf315638b2b0a4c5fb007", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } + }, + "treefmt-nix_2": { "inputs": { "nixpkgs": [ "clan-core", diff --git a/flake.nix b/flake.nix index abfce2a..21aecf7 100644 --- a/flake.nix +++ b/flake.nix @@ -15,6 +15,10 @@ inputs.flake-parts.follows = "flake-parts"; }; + amarth-customer-portal = { + url = "git+https://git.amarth.cloud/amarth/customer-portal"; + }; + systems = { url = "github:nix-systems/default"; };