Commit Graph

85 Commits

Author SHA1 Message Date
Jonas Heinrich
6af026c2bc nixos/mastodon: fix tootctl runtime path 2026-05-21 07:29:41 +02:00
NAHO
a2ed7e8d88 nixos: remove optional builtins prefixes from prelude functions
Remove optional builtins prefixes from prelude functions by running:

    builtins=(
      abort
      baseNameOf
      break
      derivation
      derivationStrict
      dirOf
      false
      fetchGit
      fetchMercurial
      fetchTarball
      fetchTree
      fromTOML
      import
      isNull
      map
      null
      placeholder
      removeAttrs
      scopedImport
      throw
      toString
      true
    )

    fd \
      --exclude doc/manual/release-notes \
      --type file \
      . \
      nixos \
      --exec-batch sed --in-place --regexp-extended "
        s/\<builtins\.($(
          printf '%s\n' "${builtins[@]}" |
            paste --delimiter '|' --serial -
        ))\>/\1/g
      "

    nix fmt
2026-01-15 16:07:55 +01:00
Kerstin Humm
226f0ae3f3 mastodon: 4.4.8 -> 4.5.0
Changelog: https://github.com/mastodon/mastodon/releases/tag/v4.5.0

Co-authored-by: Izorkin <izorkin@elven.pw>
2025-11-07 12:19:44 +01:00
Wolfgang Walther
91a8fee3aa treewide: remove redundant parentheses
Auto-fixed by nixf-diagnose.
2025-10-05 10:52:03 +02:00
h7x4
4ba3f60b8a various: use mkPackageOption 2025-09-22 02:46:54 +02:00
merrkry
f2a1154c65 nixos/mastodon: fix streaming path 2025-09-12 21:18:01 +02:00
Martin Weinelt
7f52135a59 nixos/postfix: fold main and master config into settings attribute 2025-07-28 17:03:08 +02:00
Martin Weinelt
029f408b94 treewide: migrate postfix configurations to service.postfix.config
The `services.postfix.config` option is a freeform type that represents
settings in `main.cf`. The top-level options on the postfix module were
replaced by these and that is the reason behind this migration.
2025-07-28 16:42:17 +02:00
Wolfgang Walther
5a0711127c treewide: run nixfmt 1.0.0 2025-07-24 13:55:40 +02:00
Izorkin
5a922bf3e5 libvirt: nixos/mastodon: add fasp Sidekiq jobClasses 2025-07-12 15:40:09 +02:00
Kerstin
5de825150d mastodon: 4.3.8 -> 4.4.0 (#414502)
Co-authored-by: Izorkin <izorkin@elven.pw>
2025-07-09 15:56:45 +02:00
Wolfgang Walther
41c5662cbe nixos/postgresql: move postStart into separate unit
This avoids restarting the postgresql server, when only ensureDatabases
or ensureUsers have been changed. It will also allow to properly wait
for recovery to finish later.

To wait for "postgresql is ready" in other services, we now provide a
postgresql.target.

Resolves #400018

Co-authored-by: Marcel <me@m4rc3l.de>
2025-06-24 15:26:47 +02:00
Kerstin Humm
ed0af3bf25 nixos/mastodon: make robust for cases where postgresql isn't enabled on the host
E.g. when a remote PostgreSQL database is used

Apparently you can't access the services.postgresql.package value
anymore if postgresql isn't enabled?
2025-06-20 14:40:25 +02:00
Izorkin
4ec6492b3b nixos/mastodon: add option elasticsearch.prefix 2025-05-08 14:48:52 +02:00
Silvan Mosberger
374e6bcc40 treewide: Format all Nix files
Format all Nix files using the officially approved formatter,
making the CI check introduced in the previous commit succeed:

  nix-build ci -A fmt.check

This is the next step of the of the [implementation](https://github.com/NixOS/nixfmt/issues/153)
of the accepted [RFC 166](https://github.com/NixOS/rfcs/pull/166).

This commit will lead to merge conflicts for a number of PRs,
up to an estimated ~1100 (~33%) among the PRs with activity in the past 2
months, but that should be lower than what it would be without the previous
[partial treewide format](https://github.com/NixOS/nixpkgs/pull/322537).

Merge conflicts caused by this commit can now automatically be resolved while rebasing using the
[auto-rebase script](8616af08d9/maintainers/scripts/auto-rebase).

If you run into any problems regarding any of this, please reach out to the
[formatting team](https://nixos.org/community/teams/formatting/) by
pinging @NixOS/nix-formatting.
2025-04-01 20:10:43 +02:00
Kerstin Humm
c06efc8927 nixos/mastodon: some formatting 2025-03-13 16:51:55 +01:00
dish
c3abba577a nixos/mastodon: fix documentation link formatting 2025-02-12 21:03:21 +01:00
Izorkin
36a83a3bf1 mastodon: 4.2.13 -> 4.3.0
Changelog:
https://github.com/mastodon/mastodon/releases/tag/v4.3.0
2024-10-10 16:58:54 +02:00
Kerstin Humm
1592790b03 nixos/mastodon: use correct postgresql package 2024-08-19 11:06:57 +02:00
Izorkin
8730a7e8d8 nixos/mastodon: optimize systemd startup order block 2024-05-29 13:45:23 +03:00
Izorkin
a05afb1437 nixos/mastodon: update redis host and port configurations 2024-05-29 13:45:17 +03:00
stuebinm
6afb255d97 nixos: remove all uses of lib.mdDoc
these changes were generated with nixq 0.0.2, by running

  nixq ">> lib.mdDoc[remove] Argument[keep]" --batchmode nixos/**.nix
  nixq ">> mdDoc[remove] Argument[keep]" --batchmode nixos/**.nix
  nixq ">> Inherit >> mdDoc[remove]" --batchmode nixos/**.nix

two mentions of the mdDoc function remain in nixos/, both of which
are inside of comments.

Since lib.mdDoc is already defined as just id, this commit is a no-op as
far as Nix (and the built manual) is concerned.
2024-04-13 10:07:35 -07:00
Maximilian Bosch
e7533df80f nixos/mastodon: stop mastodon-init-db.service if check for seeded DB fails
The postgresql runs on a different node than my mastodon itself. Sometimes when
rebooting the entire host it can happen that mastodon gets started
before the DB[1] is up. In that case `mastodon-init-db.service` ran
through with the following log output:

    2024-03-07 15:30:56.856
    Migrating database (this might be a noop)
    2024-03-07 15:30:56.856
    /nix/store/xzm7www0qb7jg5zrgg7knynckx5yhki9-unit-script-mastodon-init-db-start/bin/mastodon-init-db-start: line 9: [: -eq: unary operator expected

It seems wrong to me to have this unit pass if the DB isn't even up,
especially with such an error.

This patch now checks if the exit code of the psql check was non-zero
and fails the entire unit. A retry can be implemented e.g. with
Restart/RestartSec then (which is more elegant than adding a while/sleep
loop anyways) like this:

    systemd.services.mastodon-init-db = {
      serviceConfig = {
        Restart = "on-failure";
        RestartSec = "5s";
        RestartMode = "direct";
        RemainAfterExit = true;
      };
      unitConfig = {
        StartLimitBurst = 5;
        StartLimitIntervalSec = "60";
      };
    };

Also using `-t --csv` now to not render the column name and to not
render a table so we don't need to rely on the format of psql (and parse
it with `sed(1)`).

[1] I added a script that blocks until postgres is there in the meantime
    though.
2024-03-22 17:51:20 +01:00
Izorkin
c1a97e1f49 nixos/mastodon: add option redis.passwordFile 2024-02-17 15:52:58 +03:00
Izorkin
cf62e3257f nixos/mastodon: redis now uses unix socket by default 2024-02-16 16:39:31 +03:00
Isa
24930dadca mastodon: set LimitNOFILE 2024-01-26 12:30:57 +01:00
Izorkin
8a0a8c7a04 nixos/mastodon: replace ffmpeg to ffmpeg-headless 2023-12-20 18:01:55 +03:00
networkException
4dd61b6e68 nixos/mastodon: properly escape arguments to psql in init-db script 2023-12-19 21:02:13 +01:00
Trolli Schmittlauch
cbf69c83d3 nixos/mastodon: clarify the need to set streamingProcesses
Explicitly declaring that option is now necessary, but wasn't in the module shipped with 23.05.
2023-12-04 02:18:39 +01:00
Ryan Lahfa
ccfe07c316 Merge pull request #266270 from Ma27/postgresql-ownership-15 2023-11-17 18:02:17 +01:00
Izorkin
63ed35dac4 nixos/mastodon: update elasticsearch configuration 2023-11-15 14:01:47 +01:00
Kerstin Humm
c82195d9e8 mastodon: 4.1.6 -> 4.2.1
- run streaming processes in separate systemd services
- remove redundancy in test
- fix update script
- release notes

See https://github.com/mastodon/mastodon/releases/tag/v4.2.1 for details
2023-11-14 21:13:46 +01:00
Maximilian Bosch
48459567ae nixos/postgresql: drop ensurePermissions, fix ensureUsers for postgresql15
Closes #216989

First of all, a bit of context: in PostgreSQL, newly created users don't
have the CREATE privilege on the public schema of a database even with
`ALL PRIVILEGES` granted via `ensurePermissions` which is how most of
the DB users are currently set up "declaratively"[1]. This means e.g. a
freshly deployed Nextcloud service will break early because Nextcloud
itself cannot CREATE any tables in the public schema anymore.

The other issue here is that `ensurePermissions` is a mere hack. It's
effectively a mixture of SQL code (e.g. `DATABASE foo` is relying on how
a value is substituted in a query. You'd have to parse a subset of SQL
to actually know which object are permissions granted to for a user).

After analyzing the existing modules I realized that in every case with
a single exception[2] the UNIX system user is equal to the db user is
equal to the db name and I don't see a compelling reason why people
would change that in 99% of the cases. In fact, some modules would even
break if you'd change that because the declarations of the system user &
the db user are mixed up[3].

So I decided to go with something new which restricts the ways to use
`ensure*` options rather than expanding those[4]. Effectively this means
that

* The DB user _must_ be equal to the DB name.
* Permissions are granted via `ensureDBOwnerhip` for an attribute-set in
  `ensureUsers`. That way, the user is actually the owner and can
  perform `CREATE`.
* For such a postgres user, a database must be declared in
  `ensureDatabases`.

For anything else, a custom state management should be implemented. This
can either be `initialScript`, doing it manual, outside of the module or
by implementing proper state management for postgresql[5], but the
current state of `ensure*` isn't even declarative, but a convergent tool
which is what Nix actually claims to _not_ do.

Regarding existing setups: there are effectively two options:

* Leave everything as-is (assuming that system user == db user == db
  name): then the DB user will automatically become the DB owner and
  everything else stays the same.

* Drop the `createDatabase = true;` declarations: nothing will change
  because a removal of `ensure*` statements is ignored, so it doesn't
  matter at all whether this option is kept after the first deploy (and
  later on you'd usually restore from backups anyways).

  The DB user isn't the owner of the DB then, but for an existing setup
  this is irrelevant because CREATE on the public schema isn't revoked
  from existing users (only not granted for new users).

[1] not really declarative though because removals of these statements
    are simply ignored for instance: https://github.com/NixOS/nixpkgs/issues/206467
[2] `services.invidious`: I removed the `ensure*` part temporarily
    because it IMHO falls into the category "manage the state on your
    own" (see the commit message). See also
    https://github.com/NixOS/nixpkgs/pull/265857
[3] e.g. roundcube had `"DATABASE ${cfg.database.username}" = "ALL PRIVILEGES";`
[4] As opposed to other changes that are considered a potential fix, but
    also add more things like collation for DBs or passwords that are
    _never_ touched again when changing those.
[5] As suggested in e.g. https://github.com/NixOS/nixpkgs/issues/206467
2023-11-13 17:16:25 +01:00
Felix Buehler
933a41a73f treewide: use optional instead of 'then []' 2023-06-25 09:11:40 -03:00
figsoda
701bcdbead nixos: fix typos 2023-05-19 22:31:04 -04:00
Kerstin Humm
aff288424f nixos/mastodon: fixup sidekiq jobClasses assertion
See https://github.com/NixOS/nixpkgs/pull/225005#issuecomment-1516677321
2023-04-20 22:58:34 +02:00
Sandro
6152b09a6a Merge pull request #225005 from erictapen/mastodon-sidekiq 2023-04-12 21:31:50 +02:00
Kerstin Humm
431ccf26e4 nixos/mastodon: add assertion for only allowing one sidekiq scheduler queue 2023-04-09 13:24:43 +02:00
Viv Lim
c778f4d225 nixos/mastodon: Allow configuring sidekiq processes
This change allows the number of sidekiq processes and which job classes
they handle to be configured.

An instance admin may choose to have separate sidekiq processes handling
jobs related to local users (`default` job class) and jobs related to
federation (`push`, `pull`, `ingress`), so that as the instance grows
and takes on more federation traffic, the local users' experience is not
as impacted.

For more details, see https://docs.joinmastodon.org/admin/scaling/#sidekiq

This pr also includes the following changes suggested in review:

- adds syslog identifiers for mastodon services
- moves working directory config to common cfgService
- adds mastodon.target
2023-04-06 16:30:16 +02:00
George Shammas
fef1559b05 nixos/mastodon: Add the ability to pass environment files 2023-01-15 00:18:40 -05:00
Sandro Jäckel
3071db258b nixos/mastodon: remove duplicated shebang 2023-01-07 18:06:57 +01:00
Izorkin
8e14bf10c2 nixos/mastodon: update database configuration 2022-12-16 16:19:39 +03:00
Izorkin
e2cebf2134 nixos/mastodon: fix init db on remote postgresql 2022-12-16 16:14:39 +03:00
Vladimir Pouzanov
65aed3b37f Allow to override the https settings 2022-12-09 19:23:50 +00:00
Lin Yinfeng
56099e008e nixos/mastodon: allow appending other env files to serviceConfig.EnvironmentFile 2022-12-07 15:07:17 +01:00
Sandro
e38618a657 Merge pull request #203825 from SuperSandro2000/mastodon-tootctl
Closes https://github.com/NixOS/nixpkgs/issues/199029
2022-12-04 11:29:45 +01:00
Sandro Jäckel
6e845a8491 nixos/mastodon: replace mastodon-env with a proper wrapper mastodon-tootctl 2022-12-03 02:59:39 +01:00
Daniel Nagy
dbe8182e74 treewide: switch to port type for nixos modules 2022-12-01 22:30:00 +01:00
Izorkin
93de6bf9ed nixos/mastodon: add smtp assertions 2022-11-28 12:07:32 +01:00
Izorkin
17933082cc nixos/mastodon: fix emoji import 2022-11-21 11:43:28 +01:00