mirror of
https://gitlab.com/upRootNutrition/dotfiles.git
synced 2025-12-06 21:17:14 -06:00
feat: added midnight miner
This commit is contained in:
parent
ada1ed4b14
commit
5e24256bcf
11 changed files with 775 additions and 117 deletions
|
|
@ -1,31 +1,46 @@
|
|||
{ moduleFunctions }:
|
||||
let
|
||||
inherit (moduleFunctions.instancesFunctions)
|
||||
sslPath
|
||||
sopsPath
|
||||
domain0
|
||||
varPath
|
||||
mntPath
|
||||
;
|
||||
|
||||
label = "projectSite";
|
||||
label = "ProjectSite";
|
||||
name = "projectsite";
|
||||
domain = "${name}.${domain0}";
|
||||
in
|
||||
{
|
||||
label = label;
|
||||
name = name;
|
||||
short = "Project";
|
||||
sops = {
|
||||
path0 = "${sopsPath}/${name}";
|
||||
email = {
|
||||
address0 = "noreply@${domain0}";
|
||||
};
|
||||
domains = {
|
||||
url0 = domain;
|
||||
};
|
||||
tags = [
|
||||
"project"
|
||||
];
|
||||
paths = {
|
||||
path0 = "/var/lib/projectsite/dist";
|
||||
};
|
||||
subdomain = name;
|
||||
ports = {
|
||||
port0 = 1334;
|
||||
};
|
||||
ssl = {
|
||||
cert = sslPath;
|
||||
key = sslPath;
|
||||
interface = {
|
||||
id = "vm-project";
|
||||
mac = "02:00:00:00:52:22";
|
||||
idUser = "vmuser-project";
|
||||
macUser = "02:00:00:00:00:22";
|
||||
ip = "192.168.50.212";
|
||||
gate = "192.168.50.1";
|
||||
ssh = 2299;
|
||||
};
|
||||
varPaths = {
|
||||
path0 = "${varPath}/${name}";
|
||||
path1 = "${varPath}/${name}/dist";
|
||||
|
||||
};
|
||||
mntPaths = {
|
||||
path0 = "${mntPath}/${name}";
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,13 +2,15 @@
|
|||
let
|
||||
inherit (moduleFunctions.instancesFunctions)
|
||||
domain1
|
||||
varPath
|
||||
mntPath
|
||||
sslPath
|
||||
sopsPath
|
||||
;
|
||||
|
||||
label = "upRootNutrition";
|
||||
name = "uprootnutrition";
|
||||
ssl = "${sslPath}/${domain1}";
|
||||
in
|
||||
|
||||
{
|
||||
label = label;
|
||||
name = name;
|
||||
|
|
@ -16,9 +18,6 @@ in
|
|||
email = {
|
||||
address0 = "nick@${domain1}";
|
||||
};
|
||||
sops = {
|
||||
path0 = "${sopsPath}/${name}";
|
||||
};
|
||||
domains = {
|
||||
url0 = domain1;
|
||||
};
|
||||
|
|
@ -26,16 +25,26 @@ in
|
|||
name
|
||||
"blog"
|
||||
];
|
||||
paths = {
|
||||
path0 = "/var/lib/website/dist";
|
||||
path1 = "";
|
||||
path2 = "";
|
||||
};
|
||||
ports = {
|
||||
port0 = 1234;
|
||||
interface = {
|
||||
id = "vm-uproot";
|
||||
mac = "02:00:00:00:52:21";
|
||||
idUser = "vmuser-uproot";
|
||||
macUser = "02:00:00:00:00:21";
|
||||
ip = "192.168.50.211";
|
||||
gate = "192.168.50.1";
|
||||
ssh = 2300;
|
||||
};
|
||||
ssl = {
|
||||
cert = "${sslPath}/${domain1}/fullchain.pem";
|
||||
key = "${sslPath}/${domain1}/key.pem";
|
||||
path = ssl;
|
||||
cert = "${ssl}/fullchain.pem";
|
||||
key = "${ssl}/key.pem";
|
||||
};
|
||||
|
||||
varPaths = {
|
||||
path0 = "${varPath}/${name}";
|
||||
};
|
||||
mntPaths = {
|
||||
path0 = "${mntPath}/${name}";
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,12 +62,12 @@ in
|
|||
# minecraft
|
||||
# ollamaCeres
|
||||
# postgresCeres
|
||||
# projectSite
|
||||
projectSite
|
||||
# prompter
|
||||
sambaCeres
|
||||
# searx
|
||||
vaultwarden
|
||||
# website
|
||||
website
|
||||
# zookeeper
|
||||
;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -124,8 +124,9 @@ in
|
|||
caddy = {
|
||||
enable = true;
|
||||
virtualHosts = {
|
||||
"${serviceCfg.interface.ip}" = {
|
||||
":80" = {
|
||||
extraConfig = ''
|
||||
# Remove the outer http:// block wrapper
|
||||
handle_path /system/* {
|
||||
file_server * {
|
||||
root /var/lib/mastodon/public-system
|
||||
|
|
@ -198,6 +199,27 @@ in
|
|||
systemd = {
|
||||
services = {
|
||||
systemd-networkd.wantedBy = [ "multi-user.target" ];
|
||||
mastodon-web.wantedBy = [ "multi-user.target" ];
|
||||
mastodon-streaming-1.wantedBy = [ "multi-user.target" ];
|
||||
mastodon-streaming-2.wantedBy = [ "multi-user.target" ];
|
||||
mastodon-streaming-3.wantedBy = [ "multi-user.target" ];
|
||||
mastodon-streaming-4.wantedBy = [ "multi-user.target" ];
|
||||
mastodon-streaming-5.wantedBy = [ "multi-user.target" ];
|
||||
mastodon-streaming-6.wantedBy = [ "multi-user.target" ];
|
||||
mastodon-streaming-7.wantedBy = [ "multi-user.target" ];
|
||||
mastodon-sidekiq-all.wantedBy = [ "multi-user.target" ];
|
||||
mastodon-sidekiq-default.wantedBy = [ "multi-user.target" ];
|
||||
mastodon-sidekiq-ingress.wantedBy = [ "multi-user.target" ];
|
||||
mastodon-sidekiq-mailers.wantedBy = [ "multi-user.target" ];
|
||||
mastodon-sidekiq-push-pull.wantedBy = [ "multi-user.target" ];
|
||||
mastodon-init-db = {
|
||||
environment = {
|
||||
DISABLE_BOOTSNAP = "1";
|
||||
};
|
||||
serviceConfig = {
|
||||
TimeoutStartSec = "10min";
|
||||
};
|
||||
};
|
||||
copy-secrets-to-tmpfs = {
|
||||
description = "Copy secrets from virtiofs to tmpfs";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ in
|
|||
config =
|
||||
let
|
||||
macAddress = "02:00:00:00:00:${macOctet}";
|
||||
workers = deviceLogic 45 4 16 6;
|
||||
workers = deviceLogic 45 4 18 6;
|
||||
in
|
||||
{
|
||||
environment.systemPackages = [
|
||||
|
|
|
|||
94
modules/nixos/guests/projectSite/default.nix
Executable file
94
modules/nixos/guests/projectSite/default.nix
Executable file
|
|
@ -0,0 +1,94 @@
|
|||
{
|
||||
config,
|
||||
flake,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (flake.config.people) user0;
|
||||
inherit (flake.config.services) instances;
|
||||
serviceCfg = instances.projectSite;
|
||||
host = flake.inputs.linkpage.secrets.domains.projectsite;
|
||||
websitePkg = flake.inputs.linkpage.packages.${pkgs.system}.websiteFrontend;
|
||||
in
|
||||
{
|
||||
systemd.tmpfiles.rules = [
|
||||
"d ${serviceCfg.mntPaths.path0} 0755 microvm wheel - -"
|
||||
];
|
||||
|
||||
microvm.vms.${serviceCfg.name} = {
|
||||
autostart = true;
|
||||
config = {
|
||||
system.stateVersion = "25.05";
|
||||
|
||||
networking.firewall.allowedTCPPorts = [
|
||||
22
|
||||
8080
|
||||
];
|
||||
|
||||
services.openssh = {
|
||||
enable = true;
|
||||
settings.PasswordAuthentication = false;
|
||||
};
|
||||
|
||||
environment.etc."website".source = websitePkg;
|
||||
|
||||
users.users.root.openssh.authorizedKeys.keys = flake.config.people.users.${user0}.sshKeys;
|
||||
|
||||
systemd = {
|
||||
network = {
|
||||
enable = true;
|
||||
networks."10-enp" = {
|
||||
matchConfig.Name = "enp0s3";
|
||||
addresses = [ { Address = "${serviceCfg.interface.ip}/24"; } ];
|
||||
gateway = [ serviceCfg.interface.gate ];
|
||||
};
|
||||
};
|
||||
|
||||
services.website = {
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network.target" ];
|
||||
serviceConfig = {
|
||||
ExecStart = "${pkgs.miniserve}/bin/miniserve /etc/website --index index.html -p 8080";
|
||||
Restart = "always";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
microvm = {
|
||||
vcpu = 2;
|
||||
mem = 3072;
|
||||
hypervisor = "qemu";
|
||||
interfaces = [
|
||||
{
|
||||
type = "tap";
|
||||
id = serviceCfg.interface.id;
|
||||
mac = serviceCfg.interface.mac;
|
||||
}
|
||||
];
|
||||
shares = [
|
||||
{
|
||||
source = "/nix/store";
|
||||
mountPoint = "/nix/.ro-store";
|
||||
tag = "ro-store";
|
||||
proto = "virtiofs";
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
# Host Caddy
|
||||
services.caddy = {
|
||||
enable = true;
|
||||
virtualHosts.${host}.extraConfig = ''
|
||||
reverse_proxy ${serviceCfg.interface.ip}:8080
|
||||
'';
|
||||
};
|
||||
|
||||
# ACME cert
|
||||
security.acme.certs.${host} = {
|
||||
dnsProvider = instances.web.dns.provider1;
|
||||
environmentFile = config.sops.secrets."dns/${instances.web.dns.provider1}".path;
|
||||
};
|
||||
}
|
||||
97
modules/nixos/guests/website/default.nix
Executable file
97
modules/nixos/guests/website/default.nix
Executable file
|
|
@ -0,0 +1,97 @@
|
|||
{
|
||||
config,
|
||||
flake,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (flake.config.people) user0;
|
||||
inherit (flake.config.services) instances;
|
||||
serviceCfg = instances.upRootNutrition;
|
||||
host = serviceCfg.domains.url0;
|
||||
websitePkg = flake.inputs.upRootNutrition.packages.${pkgs.system}.websiteFrontend;
|
||||
in
|
||||
{
|
||||
microvm.vms.${serviceCfg.name} = {
|
||||
autostart = true;
|
||||
config = {
|
||||
system.stateVersion = "25.05";
|
||||
|
||||
networking.firewall.allowedTCPPorts = [
|
||||
22
|
||||
8080
|
||||
];
|
||||
|
||||
services.openssh = {
|
||||
enable = true;
|
||||
settings.PasswordAuthentication = false;
|
||||
};
|
||||
|
||||
environment.etc."website".source = websitePkg;
|
||||
|
||||
users.users.root.openssh.authorizedKeys.keys = flake.config.people.users.${user0}.sshKeys;
|
||||
|
||||
systemd = {
|
||||
network = {
|
||||
enable = true;
|
||||
networks."10-enp" = {
|
||||
matchConfig.Name = "enp0s3";
|
||||
addresses = [
|
||||
{ Address = "${serviceCfg.interface.ip}/24"; }
|
||||
];
|
||||
gateway = [ serviceCfg.interface.gate ];
|
||||
};
|
||||
};
|
||||
|
||||
services.website = {
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network.target" ];
|
||||
serviceConfig = {
|
||||
ExecStart = "${pkgs.miniserve}/bin/miniserve /etc/website --index index.html -p 8080";
|
||||
Restart = "always";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
microvm = {
|
||||
vcpu = 2;
|
||||
mem = 3072;
|
||||
hypervisor = "qemu";
|
||||
interfaces = [
|
||||
{
|
||||
type = "tap";
|
||||
id = serviceCfg.interface.id;
|
||||
mac = serviceCfg.interface.mac;
|
||||
}
|
||||
];
|
||||
shares = [
|
||||
{
|
||||
source = "/nix/store";
|
||||
mountPoint = "/nix/.ro-store";
|
||||
tag = "ro-store";
|
||||
proto = "virtiofs";
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
services.caddy = {
|
||||
enable = true;
|
||||
virtualHosts.${host}.extraConfig = ''
|
||||
reverse_proxy ${serviceCfg.interface.ip}:8080
|
||||
|
||||
tls ${serviceCfg.ssl.cert} ${serviceCfg.ssl.key}
|
||||
'';
|
||||
};
|
||||
|
||||
security.acme.certs.${host} = {
|
||||
dnsProvider = instances.web.dns.provider0;
|
||||
environmentFile = config.sops.secrets."dns/${instances.web.dns.provider0}".path;
|
||||
};
|
||||
|
||||
systemd.tmpfiles.rules = [
|
||||
"d ${serviceCfg.mntPaths.path0} 0755 microvm wheel - -"
|
||||
];
|
||||
|
||||
}
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
{ flake, config, ... }:
|
||||
let
|
||||
inherit (flake.config.services.instances)
|
||||
projectSite
|
||||
;
|
||||
service = projectSite;
|
||||
host = flake.inputs.linkpage.secrets.domains.projectsite;
|
||||
in
|
||||
{
|
||||
services = {
|
||||
caddy = {
|
||||
virtualHosts = {
|
||||
"${host}" = {
|
||||
extraConfig = ''
|
||||
root * ${service.paths.path0}
|
||||
|
||||
file_server
|
||||
|
||||
encode gzip
|
||||
|
||||
try_files {path} /index.html
|
||||
|
||||
tls ${service.ssl.cert}/${host}/fullchain.pem ${service.ssl.key}/${host}/key.pem
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
systemd.tmpfiles.rules = [
|
||||
"Z ${service.paths.path0} 755 caddy caddy -"
|
||||
];
|
||||
}
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
{ flake, pkgs, ... }:
|
||||
let
|
||||
inherit (flake.config.services.instances)
|
||||
upRootNutrition
|
||||
web
|
||||
;
|
||||
service = upRootNutrition;
|
||||
host = web.domains.url1;
|
||||
|
||||
websitePkg = flake.inputs.upRootNutrition.packages.${pkgs.system}.websiteFrontend;
|
||||
in
|
||||
{
|
||||
services = {
|
||||
caddy = {
|
||||
virtualHosts = {
|
||||
"${host}" = {
|
||||
extraConfig = ''
|
||||
root * ${websitePkg}
|
||||
|
||||
file_server
|
||||
|
||||
encode gzip
|
||||
|
||||
try_files {path} /index.html
|
||||
|
||||
tls ${service.ssl.cert} ${service.ssl.key}
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue