2023-05-27 16:57:28 +01:00
|
|
|
{ lib, ... }:
|
|
|
|
let
|
|
|
|
inherit (lib.my) net;
|
2023-11-17 15:05:12 +00:00
|
|
|
inherit (lib.my.c) pubDomain;
|
2023-11-02 13:41:50 +00:00
|
|
|
inherit (lib.my.c.colony) domain prefixes;
|
2023-05-27 16:57:28 +01:00
|
|
|
in
|
|
|
|
{
|
2023-11-16 21:42:30 +00:00
|
|
|
nixos.systems.object = { config, ... }: {
|
2022-07-16 15:01:15 +01:00
|
|
|
system = "x86_64-linux";
|
|
|
|
nixpkgs = "mine";
|
2023-11-16 21:42:30 +00:00
|
|
|
rendered = config.configuration.config.my.asContainer;
|
2022-07-16 15:01:15 +01:00
|
|
|
|
|
|
|
assignments = {
|
|
|
|
internal = {
|
|
|
|
name = "object-ctr";
|
2023-05-27 16:57:28 +01:00
|
|
|
inherit domain;
|
|
|
|
ipv4.address = net.cidr.host 7 prefixes.ctrs.v4;
|
2022-07-16 15:01:15 +01:00
|
|
|
ipv6 = {
|
|
|
|
iid = "::7";
|
2023-05-27 16:57:28 +01:00
|
|
|
address = net.cidr.host 7 prefixes.ctrs.v6;
|
2022-07-16 15:01:15 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-01-08 17:32:10 +00:00
|
|
|
configuration = { lib, pkgs, config, assignments, ... }:
|
2022-07-16 15:01:15 +01:00
|
|
|
let
|
2023-11-17 15:05:12 +00:00
|
|
|
inherit (lib) mkMerge mkIf mkForce;
|
2023-02-19 16:49:07 +00:00
|
|
|
inherit (config.my.user.homeConfig.lib.file) mkOutOfStoreSymlink;
|
2023-02-19 17:39:15 +00:00
|
|
|
inherit (lib.my) networkdAssignment systemdAwaitPostgres;
|
2022-07-16 15:01:15 +01:00
|
|
|
in
|
|
|
|
{
|
|
|
|
config = mkMerge [
|
|
|
|
{
|
|
|
|
my = {
|
|
|
|
deploy.enable = false;
|
|
|
|
server.enable = true;
|
|
|
|
|
|
|
|
secrets = {
|
|
|
|
key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFdHbZErWLmTPO/aEWB1Fup/aGMf31Un5Wk66FJwTz/8";
|
2022-11-20 18:41:49 +00:00
|
|
|
files = {
|
|
|
|
"object/minio.env" = {};
|
|
|
|
"object/sharry.conf" = {
|
|
|
|
owner = "sharry";
|
|
|
|
group = "sharry";
|
|
|
|
};
|
2023-02-19 16:49:07 +00:00
|
|
|
"object/minio-client-config.json" = {
|
|
|
|
owner = config.my.user.config.name;
|
|
|
|
group = config.my.user.config.group;
|
|
|
|
};
|
2023-11-17 15:05:12 +00:00
|
|
|
"object/atticd.env" = {};
|
2022-11-20 18:41:49 +00:00
|
|
|
};
|
2022-07-16 15:01:15 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
firewall = {
|
2023-11-17 15:05:12 +00:00
|
|
|
tcp.allowed = [ 9000 9001 config.services.sharry.config.bind.port 8069 ];
|
2022-07-16 15:01:15 +01:00
|
|
|
};
|
2023-02-19 16:49:07 +00:00
|
|
|
|
|
|
|
user.homeConfig = {
|
|
|
|
home.file.".mc/config.json".source = mkOutOfStoreSymlink config.age.secrets."object/minio-client-config.json".path;
|
|
|
|
};
|
2022-07-16 15:01:15 +01:00
|
|
|
};
|
|
|
|
|
2023-11-17 22:14:19 +00:00
|
|
|
users = with lib.my.c.ids; let inherit (config.services.atticd) user group; in {
|
|
|
|
users."${user}" = {
|
|
|
|
isSystemUser = true;
|
|
|
|
uid = uids.atticd;
|
|
|
|
group = group;
|
|
|
|
};
|
|
|
|
groups."${user}".gid = gids.atticd;
|
|
|
|
};
|
|
|
|
|
2022-07-16 15:01:15 +01:00
|
|
|
systemd = {
|
|
|
|
network.networks."80-container-host0" = networkdAssignment "host0" assignments.internal;
|
2023-11-17 22:14:19 +00:00
|
|
|
|
|
|
|
services =
|
|
|
|
let
|
|
|
|
awaitPostgres = systemdAwaitPostgres pkgs.postgresql "colony-psql";
|
|
|
|
in
|
|
|
|
{
|
2022-07-16 15:01:15 +01:00
|
|
|
minio = {
|
|
|
|
environment = {
|
|
|
|
MINIO_ROOT_USER = "minioadmin";
|
|
|
|
MINIO_DOMAIN = "s3.nul.ie";
|
|
|
|
MINIO_SERVER_URL = "https://s3.nul.ie";
|
|
|
|
MINIO_BROWSER_REDIRECT_URL = "https://minio.nul.ie";
|
|
|
|
};
|
|
|
|
};
|
2023-11-17 22:14:19 +00:00
|
|
|
sharry = awaitPostgres;
|
|
|
|
atticd = mkMerge [
|
|
|
|
awaitPostgres
|
|
|
|
{
|
|
|
|
serviceConfig = {
|
|
|
|
# Needs to be able to access its data
|
|
|
|
DynamicUser = mkForce false;
|
|
|
|
BindPaths = [ "/mnt/atticd:/var/lib/atticd/storage" ];
|
|
|
|
};
|
|
|
|
}
|
|
|
|
];
|
2022-07-16 15:01:15 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-02-19 16:49:07 +00:00
|
|
|
environment = {
|
|
|
|
systemPackages = with pkgs; [
|
|
|
|
minio-client
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2022-07-16 15:01:15 +01:00
|
|
|
services = {
|
|
|
|
minio = {
|
|
|
|
enable = true;
|
|
|
|
region = "eu-central-1";
|
|
|
|
browser = true;
|
2022-11-20 18:41:49 +00:00
|
|
|
rootCredentialsFile = config.age.secrets."object/minio.env".path;
|
2022-07-16 21:01:18 +01:00
|
|
|
dataDir = [ "/mnt/minio" ];
|
2022-07-16 15:01:15 +01:00
|
|
|
};
|
2022-11-20 18:41:49 +00:00
|
|
|
|
|
|
|
sharry = {
|
|
|
|
enable = true;
|
|
|
|
configOverridesFile = config.age.secrets."object/sharry.conf".path;
|
|
|
|
|
|
|
|
config = {
|
2023-11-02 13:41:50 +00:00
|
|
|
base-url = "https://share.${lib.my.c.pubDomain}";
|
2023-04-15 21:17:27 +01:00
|
|
|
bind.address = "::";
|
2022-11-20 18:41:49 +00:00
|
|
|
alias-member-enabled = true;
|
|
|
|
webapp = {
|
|
|
|
chunk-size = "64M";
|
|
|
|
};
|
|
|
|
backend = {
|
|
|
|
auth = {
|
|
|
|
fixed = {
|
|
|
|
enabled = true;
|
|
|
|
user = "dev";
|
|
|
|
};
|
|
|
|
internal = {
|
|
|
|
enabled = true;
|
|
|
|
order = 50;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
jdbc = {
|
|
|
|
url = "jdbc:postgresql://colony-psql:5432/sharry";
|
|
|
|
user = "sharry";
|
|
|
|
};
|
|
|
|
files = {
|
|
|
|
default-store = "minio";
|
|
|
|
stores = {
|
|
|
|
database.enabled = false;
|
|
|
|
minio = {
|
|
|
|
enabled = true;
|
|
|
|
type = "s3";
|
|
|
|
endpoint = "https://s3.nul.ie";
|
|
|
|
access-key = "share";
|
|
|
|
bucket = "share";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
compute-checksum.parallel = 4;
|
|
|
|
signup.mode = "invite";
|
|
|
|
share = {
|
|
|
|
max-size = "128G";
|
|
|
|
max-validity = "3650 days";
|
|
|
|
};
|
|
|
|
mail = {
|
|
|
|
enabled = true;
|
|
|
|
smtp = {
|
|
|
|
host = "mail.nul.ie";
|
|
|
|
port = 587;
|
|
|
|
user = "sharry@nul.ie";
|
|
|
|
ssl-type = "starttls";
|
|
|
|
default-from = "Sharry <sharry@nul.ie>";
|
|
|
|
timeout = "30 seconds";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2023-11-17 15:05:12 +00:00
|
|
|
|
|
|
|
atticd = {
|
|
|
|
enable = true;
|
|
|
|
credentialsFile = config.age.secrets."object/atticd.env".path;
|
|
|
|
settings = {
|
|
|
|
listen = "[::]:8069";
|
|
|
|
allowed-hosts = [ "nix-cache.${pubDomain}" ];
|
|
|
|
api-endpoint = "https://nix-cache.${pubDomain}/";
|
|
|
|
database = mkForce {}; # blank to pull from env
|
|
|
|
storage = {
|
2023-11-17 22:14:19 +00:00
|
|
|
type = "local";
|
|
|
|
path = "/var/lib/atticd/storage";
|
2023-11-17 15:05:12 +00:00
|
|
|
};
|
|
|
|
chunking = {
|
|
|
|
nar-size-threshold = 65536;
|
|
|
|
min-size = 16384;
|
|
|
|
avg-size = 65536;
|
|
|
|
max-size = 262144;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2022-07-16 15:01:15 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
(mkIf config.my.build.isDevVM {
|
|
|
|
virtualisation = {
|
|
|
|
forwardPorts = [
|
|
|
|
{ from = "host"; host.port = 9000; guest.port = 9000; }
|
|
|
|
{ from = "host"; host.port = 9001; guest.port = 9001; }
|
2022-11-20 18:41:49 +00:00
|
|
|
{ from = "host"; guest.port = config.services.sharry.config.bind.port; }
|
2022-07-16 15:01:15 +01:00
|
|
|
];
|
|
|
|
};
|
|
|
|
})
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|