Compare commits

..

No commits in common. "review" and "main" have entirely different histories.
review ... main

5 changed files with 4 additions and 31 deletions

View file

@ -2,7 +2,7 @@
This repo is, for now, an attempt to familiarize myself with NixOS options for Fediverse applications, and build up a configuration layer that will set most of the relevant options for you (in a semi-opinionated way) given some high-level configuration. The goal is something in the same vein as [nixos-mailserver](https://gitlab.com/simple-nixos-mailserver/nixos-mailserver) but for fediversity.
Eventually, this will be tailored to high-throughput multi-machine setups. For now, it's just a small set of configurations to run in VMs.
Eventually, this will be tailored to high-throughput multi-machine setups. For now, it's just a small configuration to run in VMs.
## Running the VMs
@ -76,10 +76,6 @@ NOTE: it sometimes takes a while for the services to start up, and in the meanti
When mastodon is running in production mode, we have a few problems:
- you have to click "accept the security risk"
- it takes a while for the webpage to come online. Until then you see "502 Bad Gateway"
- reverse proxy should produce a user friendly page regardless
- might be needed for upgrade downtime too?
- don't send users over until it's up
- email sent from the mastodon instance (e.g. for account confirmation) should be accessible at <https://mastodon.localhost:55001/letter_opener>, but it's not working.
- maybe the admin account should be managed entirely by fediversity anyway?

View file

@ -1,6 +1,4 @@
{ pkgs, ... }: {
# Customize nixos-rebuild build-vm to be a bit more convenient
virtualisation.vmVariant = {
# let us log in
users.mutableUsers = false;

View file

@ -55,7 +55,6 @@ in
type = types.str;
};
# TODO: assert at least one of these is true
# currently, needs to be done in the top level module
ensureAccess = mkOption {
type = types.attrsOf (types.submodule {
options = {
@ -107,8 +106,6 @@ in
settings = {
replication_mode = "none";
# TODO: use a secret file
# I'd like to have a NixOS module that declares the need for a secret file
# that way, the need can be met by any secrets solution (agenix, sops-nix, colmena, a nixops4 module, ...)
rpc_secret = "d576c4478cc7d0d94cfc127138cbb82018b0155c037d1c827dfb6c36be5f6625";
# TODO: why does this have to be set? is there not a sensible default?
rpc_bind_addr = "[::]:3901";
@ -136,7 +133,6 @@ in
# also, it's crazy that we have to parse command output like this
# TODO: talk to garage maintainer about making this nicer to work with in Nix
# before I do that though, I should figure out how setting it up across multiple machines will work
# You could ask for a change or `--json` flag anyway, and maybe tell them what you're working on.
GARAGE_ID=$(garage node id 2>/dev/null | perl -ne '/(.*)@.*/ && print $1')
garage layout assign -z g1 -c 1G $GARAGE_ID
LAYOUT_VER=$(garage layout show | perl -ne '/Current cluster layout version: (\d*)/ && print $1')
@ -155,7 +151,7 @@ in
# TODO: should this --deny the website if `website` is false?
${lib.optionalString website ''
garage bucket website --allow ${/* more robust: */ lib.strings.escapeShellArg bucket}
garage bucket website --allow ${bucket}
''}
${lib.concatStringsSep "\n" (map (alias: ''
@ -164,8 +160,6 @@ in
${lib.optionalString corsRules.enable ''
# TODO: can i turn this whole thing into one builtins.toJSON?
# why not :D
# we also have `lib.strings.escapeShellArg` for the quoting
export CORS=${lib.concatStrings [
"'"
''{"CORSRules":[{''
@ -181,7 +175,6 @@ in
garage bucket deny --read --write --owner ${bucket} --key tmp
''}
'') config.services.garage.ensureBuckets)
# probably nice to factor this out into a function
}
${
lib.concatStringsSep "\n" (lib.mapAttrsToList (key: {id, secret, ensureAccess}: ''

View file

@ -101,8 +101,9 @@ in
# but it also must be a positive integer
streamingProcesses = let
ncores = config.virtualisation.cores;
max = x: y: if x > y then x else y;
in
lib.max 1 (ncores - 1);
max 1 (ncores - 1);
};
security.acme = {
@ -159,10 +160,7 @@ in
};
# run rails db:seed so that mastodon sets up the databases for us
# iirc the postgresql module can also do this kind of thing
systemd.services.mastodon-init-db.script = lib.mkForce ''
# This conditional freaks me out
# Maybe configure psql to output in a more machine-readable format?
if [ `psql -c \
"select count(*) from pg_class c \
join pg_namespace s on s.oid = c.relnamespace \

View file

@ -1,12 +0,0 @@
# `ensureBuckets`
Should be replaced by a resource that creates the bucket, so that we can manage its whole lifecycle, including updates (authz?) and deletion; possibly a generic S3 bucket resource? - we'll see.
Fine solution for now.
Perhaps also useful in a NixOS module, but could also be tech debt if nobody uses it.
# More exploration
- Use NixOS test framework?
- Write test that upgrades garage