Commit Graph

33 Commits

Author SHA1 Message Date
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
K900
c34a1d5135 lemmy: fix nginx config generation 2024-01-28 19:15:02 +03:00
h7x4
79d3d59f58
treewide: replace mkPackageOptionMD with mkPackageOption 2023-11-30 19:03:14 +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
happysalada
676fe5e01b lemmy: fix ui commit_hash path 2023-08-27 20:44:10 +08:00
Freakmiko
66469836be Fix Lemmy Caddy config static path handling
Due to lemmy-ui using a sub-path for the static files, the original static path handling was not sufficient
2023-08-17 04:19:48 +08:00
Eric Wolf
318d8cc4c5 nixos/lemmy: limit impurity by secrets
Split `services.lemmy.secretFile` into
multiple options to allow only secrets.
2023-07-28 07:49:27 +00:00
adisbladis
c88c434c34 nixos/lemmy: Move pictrs url from pictrs_url to pictrs.url
The upstream config schema changed.
2023-07-13 15:46:30 +12:00
adisbladis
2bc5b80182 lemmy-ui: Set NODE_ENV to run server in production mode 2023-07-13 15:46:30 +12:00
adisbladis
8062626e0e lemmy-{server,ui}: 0.18.0 -> 0.18.1 2023-07-08 13:59:30 +12:00
Eric Wolf
ee5cc38432 lemmy: Support secret options
This commit implements #101777 by merging
the config with an external file at startup.
2023-07-03 09:12:40 +08:00
NotAShelf
b5fcbad5fb nixos/lemmy: handle database creation better 2023-06-27 17:46:19 +08:00
Charles Hall
370f3e4883 nixos/lemmy: remove option removed upstream 2023-06-16 05:59:32 -04:00
Charles Hall
af585658b8 nixos/lemmy: reduce moving parts 2023-06-15 06:56:56 -04:00
Charles Hall
fa9306c041 nixos/lemmy: allow overriding packages 2023-06-15 06:56:56 -04:00
Charles Hall
b1853ecfcd nixos/lemmy: only use env var when instructed
Lemmy checks the environment variable before the configuration file;
i.e. if the file is used to configure the database but the environment
variable is set to anything, the connection will fail because it'll
ignore the file. This was the previous behavior.

Now, the environment variable will be unset unless the user explicitly
chooses to set it, which makes the file-based configuration function
correctly. It's also possible to manually set the environment variable,
which has the major advantage of working around [this issue][0], which
prevents certain setups from working.

[0]: https://github.com/LemmyNet/lemmy/issues/2945
2023-06-15 06:56:56 -04:00
Charles Hall
dd0b5a7e08 nixos/lemmy: warn for option removed upstream
Also hide it since it shouldn't be used.
2023-06-15 06:56:56 -04:00
bd77d4ae46 nixos/lemmy: support nginx 2023-06-12 09:59:11 -04:00
855cff92e0 nixos/lemmy: fix documentation links 2023-04-26 18:29:53 -04:00
pennae
0a6e6cf7e6 nixos/manual: render module chapters with nixos-render-docs
this converts meta.doc into an md pointer, not an xml pointer. since we
no longer need xml for manual chapters we can also remove support for
manual chapters from md-to-db.sh

since pandoc converts smart quotes to docbook quote elements and our
nixos-render-docs does not we lose this distinction in the rendered
output. that's probably not that bad, our stylesheet didn't make use of
this anyway (and pre-23.05 versions of the chapters didn't use quote
elements either).

also updates the nixpkgs manual to clarify that option docs support all
extensions (although it doesn't support headings at all, so heading
anchors don't work by extension).
2023-01-27 20:07:34 +01:00
pennae
53fc887582 nixos/manual: move "edit the MD file" comments to generated XML 2023-01-10 12:34:37 +01:00
pennae
bf92eaebe4 nixos/manual: generate module chapters with md-to-db.sh 2023-01-10 10:32:00 +01:00
Brian Leung
e5f798f3b9 nixos/lemmy: use PostgreSQL module to ensure database/user existence
Co-authored-by: Shahar Dawn Or <mightyiampresence@gmail.com>
Co-authored-by: a-kenji <aks.kenji@protonmail.com>
Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io>
Co-authored-by: Ilan Joselevich <personal@ilanjoselevich.com>
2022-09-21 09:00:52 -04:00
Brian Leung
3de898f262 nixos/lemmy: inline localPostgres into database assertion
Co-authored-by: Shahar Dawn Or <mightyiampresence@gmail.com>
Co-authored-by: Ctem <c@ctem.me>
Co-authored-by: a-kenji <aks.kenji@protonmail.com>
Co-authored-by: Brian Leung <leungbk@posteo.net>
Co-authored-by: Ilan Joselevich <personal@ilanjoselevich.com>
2022-09-21 09:00:52 -04:00
Brian Leung
2c8e67bf6b nixos/lemmy: settings.database.createLocally -> database.createLocally
Co-authored-by: Shahar Dawn Or <mightyiampresence@gmail.com>
Co-authored-by: Ctem <c@ctem.me>
Co-authored-by: a-kenji <aks.kenji@protonmail.com>
2022-09-19 11:34:08 -04:00
Brian Leung
c231a20d98 nixos/lemmy: move systemd script to serviceConfig
Co-authored-by: Shahar Dawn Or <mightyiampresence@gmail.com>
Co-authored-by: Ctem <c@ctem.me>
Co-authored-by: Ilan Joselevich <personal@ilanjoselevich.com>
Co-authored-by: a-kenji <aks.kenji@protonmail.com>
2022-09-12 18:39:54 -04:00
a-kenji
5519e1b89b nixos/lemmy: remove services.lemmy.jwtSecretPath
Co-authored-by: Ctem <c@ctem.me>
Co-authored-by: Brian Leung <leungbk@posteo.net>
Co-authored-by: Shahar Dawn Or <mightyiampresence@gmail.com>
Co-authored-by: Ilan Joselevich <personal@ilanjoselevich.com>
2022-09-12 18:39:54 -04:00
Brian Leung
b7f19802af services/lemmy: fix /feeds/* and /nodeinfo/* API endpoints
Co-authored-by: Shahar Dawn Or <mightyiampresence@gmail.com>
Co-authored-by: Matthias Meschede <MMesch@users.noreply.github.com>
Co-authored-by: a-kenji <aks.kenji@protonmail.com>
Co-authored-by: Ctem <c@ctem.me>
Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io>
2022-09-09 05:18:02 -04:00
pennae
ef176dcf7e nixos/*: automatically convert option descriptions
conversions were done using https://github.com/pennae/nix-doc-munge
using (probably) rev f34e145 running

    nix-doc-munge nixos/**/*.nix
    nix-doc-munge --import nixos/**/*.nix

the tool ensures that only changes that could affect the generated
manual *but don't* are committed, other changes require manual review
and are discarded.
2022-08-31 16:32:53 +02:00
pennae
2e751c0772 treewide: automatically md-convert option descriptions
the conversion procedure is simple:

 - find all things that look like options, ie calls to either `mkOption`
   or `lib.mkOption` that take an attrset. remember the attrset as the
   option
 - for all options, find a `description` attribute who's value is not a
   call to `mdDoc` or `lib.mdDoc`
 - textually convert the entire value of the attribute to MD with a few
   simple regexes (the set from mdize-module.sh)
 - if the change produced a change in the manual output, discard
 - if the change kept the manual unchanged, add some text to the
   description to make sure we've actually found an option. if the
   manual changes this time, keep the converted description

this procedure converts 80% of nixos options to markdown. around 2000
options remain to be inspected, but most of those fail the "does not
change the manual output check": currently the MD conversion process
does not faithfully convert docbook tags like <code> and <package>, so
any option using such tags will not be converted at all.
2022-07-30 15:16:34 +02:00
Ilan Joselevich
d0617a58e2
services/web-apps/lemmy.nix: Remove space that causes a type error 2022-07-22 01:19:28 -07:00
happysalada
a8f9539d01 lemmy: systemd postgresql setup service cleanup 2021-10-30 09:16:09 +09:00
Bill Ewanick
cc3b147ed1 nixos/lemmy: init
Co-authored-by: Raphael Megzari <raphael@megzari.com>
2021-10-06 21:02:51 +09:00