From 5514618d21453f204511db1f4443b5e985ec5185 Mon Sep 17 00:00:00 2001 From: catvayor Date: Wed, 11 Jun 2025 17:14:30 +0200 Subject: [PATCH] feat(nimbolus): init a http terraform backend --- machines/nixos/compute01/_configuration.nix | 1 + machines/nixos/compute01/nimbolus/default.nix | 42 ++++++++ machines/nixos/compute01/nimbolus/module.nix | 96 ++++++++++++++++++ .../nixos/compute01/secrets/nimbolus-kms_key | Bin 0 -> 1804 bytes .../compute01/secrets/nimbolus-s3_secret | Bin 0 -> 1743 bytes machines/nixos/compute01/secrets/secrets.nix | 2 + modules/nixos/default.nix | 2 +- 7 files changed, 142 insertions(+), 1 deletion(-) create mode 100644 machines/nixos/compute01/nimbolus/default.nix create mode 100644 machines/nixos/compute01/nimbolus/module.nix create mode 100644 machines/nixos/compute01/secrets/nimbolus-kms_key create mode 100644 machines/nixos/compute01/secrets/nimbolus-s3_secret diff --git a/machines/nixos/compute01/_configuration.nix b/machines/nixos/compute01/_configuration.nix index 7e45eea..6689130 100644 --- a/machines/nixos/compute01/_configuration.nix +++ b/machines/nixos/compute01/_configuration.nix @@ -28,6 +28,7 @@ lib.extra.mkConfig { "mastodon" # "netbox" "nextcloud" + "nimbolus" "ollama-proxy" "opengist" "outline" diff --git a/machines/nixos/compute01/nimbolus/default.nix b/machines/nixos/compute01/nimbolus/default.nix new file mode 100644 index 0000000..5150323 --- /dev/null +++ b/machines/nixos/compute01/nimbolus/default.nix @@ -0,0 +1,42 @@ +# SPDX-FileCopyrightText: 2025 Lubin Bailly +# +# SPDX-License-Identifier: EUPL-1.2 + +{ + pkgs, + sources, + config, + ... +}: +let + host = "nimbolus.dgnum.eu"; + port = 9008; +in +{ + import = [ ./module.nix ]; + services.nimbolus-tf = { + enable = true; + package = (import sources.kat-pkgs { inherit pkgs; }).nimbolus-tf-backend; + settings = { + LISTEN_ADDR = "127.0.0.1:${toString port}"; + KMS_KEY_PATH = config.age.secrets."nimbolus-kms_key".path; + + STORAGE_BACKEND = "s3"; + STORAGE_S3_ENDPOINT = "s3.dgnum.eu"; + STORAGE_S3_USE_SSL = "true"; + STORAGE_S3_BUCKET = "nimbolus-dgnum"; + STORAGE_S3_ACCESS_KEY = "GKefa111701f349de3988f0010"; + STORAGE_S3_SECRET_KEY_FILE = config.age.secrets."nimbolus-s3_secret".path; + + # TODO: configure openBAO + # AUTH_BASIC_ENABLED = "false"; + # AUTH_JWT_OIDC_ISSUER_URL = "https://vault.dgnum.eu/v1/identity/oidc"; + }; + }; + + age-secrets.autoMatch = [ "nimbolus" ]; + + dgn-web.simpleProxies.nimbolus = { + inherit host port; + }; +} diff --git a/machines/nixos/compute01/nimbolus/module.nix b/machines/nixos/compute01/nimbolus/module.nix new file mode 100644 index 0000000..10d1bcc --- /dev/null +++ b/machines/nixos/compute01/nimbolus/module.nix @@ -0,0 +1,96 @@ +# SPDX-FileCopyrightText: 2025 Lubin Bailly +# +# SPDX-License-Identifier: EUPL-1.2 + +{ + lib, + config, + sources, + pkgs, + ... +}: +let + inherit (lib) + getExe + mapAttrsToList + mkEnableOption + mkIf + mkPackageOption + mkOption + ; + inherit (lib.types) + attrsOf + str + ; + + cfg = config.services.nimbolus-tf; +in +{ + options.services.nimbolus-tf = { + enable = mkEnableOption "the nimbolus terraform http backend" { pkgsText = "kat-pkgs"; }; + package = mkPackageOption (import sources.kat-pkgs { inherit pkgs; }) "nimbolus-tf-backend"; + user = mkOption { + type = str; + description = '' + User used by the nimbolus server. + ''; + default = "nimbolus"; + }; + group = mkOption { + type = str; + description = '' + Group used by the nimbolus server. + ''; + default = "nimbolus"; + }; + settings = mkOption { + type = attrsOf str; + default = { }; + description = '' + Environment variables for nimbolus configuration. + ''; + }; + }; + config = mkIf cfg.enable { + users = { + users.${cfg.user}.isSystemUser = true; + groups.${cfg.group} = { }; + }; + systemd.services."nimbolus-tf" = { + description = "Nimbolus terraform http backend"; + wantedBy = [ "multi-user.target" ]; + serviceConfig = { + ExecStart = getExe cfg.package; + Environment = mapAttrsToList (name: value: "${name}=${value}") cfg.settings; + User = cfg.user; + Group = cfg.group; + + StateDirectory = "nimbolus-tf"; + StateDirectoryMode = "0700"; + WorkingDirectory = "/var/lib/nimbolus-tf"; + + # Hardening + CapabilityBoundingSet = ""; + PrivateDevices = true; + ProtectClock = true; + ProtectKernelLogs = true; + ProtectControlGroups = true; + ProtectKernelModules = true; + RestrictNamespaces = true; + ProtectHostname = true; + LockPersonality = true; + RestrictRealtime = true; + ProtectHome = true; + ProtectProc = "noaccess"; + ProcSubset = "pid"; + PrivateUsers = true; + UMask = "0077"; + ProtectKernelTunables = true; + RestrictAddressFamilies = "AF_INET AF_INET6"; + SystemCallFilter = "~@clock @cpu-emulation @debug @module @mount @obsolete @privileged @raw-io @reboot @resources @swap"; + MemoryDenyWriteExecute = true; + SystemCallArchitectures = "native"; + }; + }; + }; +} diff --git a/machines/nixos/compute01/secrets/nimbolus-kms_key b/machines/nixos/compute01/secrets/nimbolus-kms_key new file mode 100644 index 0000000000000000000000000000000000000000..323599072b3853d415189c01168ab67f7ae8e010 GIT binary patch literal 1804 zcmZXUxvu;M8O7-$3_=7c{q)0)cYEBR*dBYljQ8E5@pwF5$NL^BLP#_q0jW~t1>gw~ zqKTB`1yUfWD50VS2?{R7pW@Pf&F?!$=bR`_UXnWQw|2~%`opGA!5Ic#esmay>?OG) zI1W>XP;9VrIRqf%?IMwb%#oG_jTwwg-*q<#?b(5|fl@Wi4pyXgl@@4vU#%Ec$S?=vgZ+QF@#qf+raBu(!0fSGj>c z2ur15!ou?VL=ozJB8p2^Q%BKe^P7j#Px36V5YAt4W&x_0PSaC1nTFoNO|}K*NS~im z>CcLSL+jmG3zRlVxxu)%v_kYBI(=vrEAq0bQ!B>_ueng{kx5-GNx3n@#E*^PSKF*i znzK0oS9t!A9$&>0d=+3rf_53aUlrzwXAl?>W}LfGjahu20N=Vt~PEnbNX3&z3SX4s%tXSWuny@ZQ#Na%or{ zVj&aZI5c=m>yNbz8ixkFDP;o9%OebUqQ~zWuG|t0c^t=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z zB#9>#A*uI4eXR{(BSXeP5|~@4IH4W5+m$*VCF`tLwgn&S(;4*h6iGPKlGdw^ssNc; z6UAeA=xC#w?6`DC@!nBZa87AVN3swn&V#Xg1Ni?-4r6#I2aiz+~r42L&c<^TmKOo9f|coJ&9y6CHYuQ*FKVRW0P=S$(%H_ zD1;Y^#$$Oq`zey3Og4sO07u`M76?Aq5AskWx(Wm&AD^-QB- z@{lh&q^mAy1!Gh+NGXZ0HP|GHw=Jo;D0CKjwmsbE2w!m!#I{`@vLWACJJn;du?iVw zC94vce{qA<&hGiGfOrBu<(74F z7*ODa-WssiyWO3l$kW3>gic?SkfG(Q46~JKj4>2bM;liO&w$dV5s`;&z)1rGQl^Um zw9!GdU3+t2cdJB<7B`3%ca1{0cqlfhODJ>GS8|)!UNX~z{^VAUQW_zBifNG0ezYzX z6>ig`y2~g2tZAvr?$yl_R$zKK)uQ6`Io_p)u`K-ϓAOj>OS?_uGzL50@aka-4P zUS19oeS-~e2!{xAYbG3xphNb6&lU?~RP-7zwAk$K!wHuX`0U4j{>HC<^YQUJzx~_4 z-lYG`rw_ef2Y>j}8?*Y}Uw@?iE`0C5ZT`z&{Ns!5{ZF)ajGuq|>pwF-{jT#F@j3Z} uFR4HN{`tiZ{~mwz<+uJ5ecrO!Jog`&9|+c`U;F;{%{M>!_fPG=c>e?G2SDrq literal 0 HcmV?d00001 diff --git a/machines/nixos/compute01/secrets/secrets.nix b/machines/nixos/compute01/secrets/secrets.nix index 38fd800..442f9ad 100644 --- a/machines/nixos/compute01/secrets/secrets.nix +++ b/machines/nixos/compute01/secrets/secrets.nix @@ -25,6 +25,8 @@ "netbox-environment_file" "nextcloud-adminpass_file" "nextcloud-s3_secret_file" + "nimbolus-kms_key" + "nimbolus-s3_secret" "opengist-environment_file" "outline-oidc_client_secret_file" "outline-smtp_password_file" diff --git a/modules/nixos/default.nix b/modules/nixos/default.nix index 0485145..1477855 100644 --- a/modules/nixos/default.nix +++ b/modules/nixos/default.nix @@ -37,8 +37,8 @@ "dgn-web" "django-apps" "extranix" - "openbao" "forgejo-multiuser-nix-runners" + "openbao" ]) ++ [ "${sources.agenix}/modules/age.nix"