Initial commit
This commit is contained in:
commit
77356dd455
156 changed files with 33283 additions and 0 deletions
.editorconfig.envrc
.forgejo/workflows
.gitignoreLICENSE.mdREADME.mddocs
README.mdadministrative-access.mdakaunting-setup.mdakaunting.mdbackups.mddeploying.mddns.mdinvoiceplane.mdmail.mdnextcloud-setup.mdnix-flake-updates.mdnixos-anywhere.mdpaperless-setup.mdpaperless.mdprivacy-hardening.mdrescue.mdreverting-version.mdsecrets.mdunlocking-luks.mdunlocking-zfs-pool.mdwireguard.md
flake.lockflake.nixlib
modules
acme
akaunting
autofetch-hostingde-invoices
backups
core
coturn
default.nixdocker
http-server
invoiceplane
janus-gw
kanidm
mail-server
monitoring-client
monitoring-server
nextcloud-signaling
nextcloud
paperless
postgresql
proxy
solidtime
static-website
unlock-luks-on-boot
unlock-zfs-on-boot
wireguard
overlays
pkgs
staging
43
.editorconfig
Normal file
43
.editorconfig
Normal file
|
@ -0,0 +1,43 @@
|
|||
# Editor configuration, see http://editorconfig.org
|
||||
root = true
|
||||
|
||||
[*]
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
charset = utf-8
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
# Ignore diffs/patches
|
||||
[*.{diff,patch}]
|
||||
end_of_line = unset
|
||||
insert_final_newline = unset
|
||||
trim_trailing_whitespace = unset
|
||||
indent_size = unset
|
||||
charset = unset
|
||||
indent_style = unset
|
||||
indent_size = unset
|
||||
|
||||
[{.*,secrets}/**]
|
||||
end_of_line = false
|
||||
insert_final_newline = false
|
||||
trim_trailing_whitespace = unset
|
||||
charset = unset
|
||||
indent_style = unset
|
||||
indent_size = unset
|
||||
|
||||
[*.rom]
|
||||
end_of_line = unset
|
||||
insert_final_newline = unset
|
||||
trim_trailing_whitespace = unset
|
||||
charset = unset
|
||||
indent_style = unset
|
||||
indent_size = unset
|
||||
|
||||
[*.py]
|
||||
indent_size = 4
|
||||
|
||||
[*.md]
|
||||
max_line_length = off
|
||||
trim_trailing_whitespace = false
|
1
.envrc
Normal file
1
.envrc
Normal file
|
@ -0,0 +1 @@
|
|||
use flake
|
22
.forgejo/workflows/check.yml
Normal file
22
.forgejo/workflows/check.yml
Normal file
|
@ -0,0 +1,22 @@
|
|||
name: Flake checks
|
||||
on: [pull_request]
|
||||
|
||||
jobs:
|
||||
Check:
|
||||
runs-on: self-hosted
|
||||
steps:
|
||||
- name: Check out repository code
|
||||
uses: https://code.forgejo.org/actions/checkout@v4
|
||||
|
||||
- name: Check formatting
|
||||
run: |
|
||||
nix --accept-flake-config --access-tokens '' develop --command treefmt --ci
|
||||
|
||||
- name: Run flake checks
|
||||
run: |
|
||||
set -exuo pipefail
|
||||
# Prevent cache garbage collection by creating GC roots
|
||||
mkdir -p /var/lib/gitea-runner/momo/.local/state/nix/results
|
||||
|
||||
# 1 eval-worker needs about 13GB of memory
|
||||
nix --accept-flake-config --access-tokens '' develop --command nix-fast-build --no-nom --skip-cached --systems "x86_64-linux" --max-jobs 10 --eval-workers 2 --out-link /var/lib/gitea-runner/momo/.local/state/nix/results/nix-fast-build
|
19
.forgejo/workflows/update-flake-lock.yml
Normal file
19
.forgejo/workflows/update-flake-lock.yml
Normal file
|
@ -0,0 +1,19 @@
|
|||
name: Update flake lock
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: '22 2 * * 6' # “At 02:22 on Saturday.”
|
||||
|
||||
jobs:
|
||||
update_lockfile:
|
||||
runs-on: self-hosted
|
||||
steps:
|
||||
- name: nix flake update
|
||||
uses: https://git.pub.solar/momo/forgejo-action-update-flake@825bba1d03c853ea9aeded656d230db82f9f1216
|
||||
with:
|
||||
forgejo_access_token: ${{ secrets.MOMO_BOT_ACCESS_TOKEN }}
|
||||
gpg_private_key: ${{ secrets.GPG_SIGN_SUBKEY }}
|
||||
gpg_fingerprint: 881FA070B6FD7B44E194B4244AB6CFF63D7B2B93
|
||||
gpg_passphrase: ${{ secrets.GPG_PASSPHRASE }}
|
||||
git_author: '"momo-bot" <no-reply@momo.koeln>'
|
||||
closure-diff-nixos-configuration: cassiopeia
|
7
.gitignore
vendored
Normal file
7
.gitignore
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
*.tf.json
|
||||
/tags.*
|
||||
.direnv
|
||||
.terraform
|
||||
*.plan
|
||||
result
|
||||
results
|
660
LICENSE.md
Normal file
660
LICENSE.md
Normal file
|
@ -0,0 +1,660 @@
|
|||
### GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
<https://fsf.org/>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies of this
|
||||
license document, but changing it is not allowed.
|
||||
|
||||
### Preamble
|
||||
|
||||
The GNU Affero General Public License is a free, copyleft license for
|
||||
software and other kinds of works, specifically designed to ensure
|
||||
cooperation with the community in the case of network server software.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
our General Public Licenses are intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains
|
||||
free software for all its users.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing
|
||||
under this license.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
### TERMS AND CONDITIONS
|
||||
|
||||
#### 0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU Affero General Public
|
||||
License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds
|
||||
of works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of
|
||||
an exact copy. The resulting work is called a "modified version" of
|
||||
the earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user
|
||||
through a computer network, with no transfer of a copy, is not
|
||||
conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices" to
|
||||
the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
#### 1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work for
|
||||
making modifications to it. "Object code" means any non-source form of
|
||||
a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users can
|
||||
regenerate automatically from other parts of the Corresponding Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that same
|
||||
work.
|
||||
|
||||
#### 2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not convey,
|
||||
without conditions so long as your license otherwise remains in force.
|
||||
You may convey covered works to others for the sole purpose of having
|
||||
them make modifications exclusively for you, or provide you with
|
||||
facilities for running those works, provided that you comply with the
|
||||
terms of this License in conveying all material for which you do not
|
||||
control copyright. Those thus making or running the covered works for
|
||||
you must do so exclusively on your behalf, under your direction and
|
||||
control, on terms that prohibit them from making any copies of your
|
||||
copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under the
|
||||
conditions stated below. Sublicensing is not allowed; section 10 makes
|
||||
it unnecessary.
|
||||
|
||||
#### 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such
|
||||
circumvention is effected by exercising rights under this License with
|
||||
respect to the covered work, and you disclaim any intention to limit
|
||||
operation or modification of the work as a means of enforcing, against
|
||||
the work's users, your or third parties' legal rights to forbid
|
||||
circumvention of technological measures.
|
||||
|
||||
#### 4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
#### 5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these
|
||||
conditions:
|
||||
|
||||
- a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
- b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under
|
||||
section 7. This requirement modifies the requirement in section 4
|
||||
to "keep intact all notices".
|
||||
- c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
- d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
#### 6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms of
|
||||
sections 4 and 5, provided that you also convey the machine-readable
|
||||
Corresponding Source under the terms of this License, in one of these
|
||||
ways:
|
||||
|
||||
- a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
- b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the Corresponding
|
||||
Source from a network server at no charge.
|
||||
- c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
- d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
- e) Convey the object code using peer-to-peer transmission,
|
||||
provided you inform other peers where the object code and
|
||||
Corresponding Source of the work are being offered to the general
|
||||
public at no charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal,
|
||||
family, or household purposes, or (2) anything designed or sold for
|
||||
incorporation into a dwelling. In determining whether a product is a
|
||||
consumer product, doubtful cases shall be resolved in favor of
|
||||
coverage. For a particular product received by a particular user,
|
||||
"normally used" refers to a typical or common use of that class of
|
||||
product, regardless of the status of the particular user or of the way
|
||||
in which the particular user actually uses, or expects or is expected
|
||||
to use, the product. A product is a consumer product regardless of
|
||||
whether the product has substantial commercial, industrial or
|
||||
non-consumer uses, unless such uses represent the only significant
|
||||
mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to
|
||||
install and execute modified versions of a covered work in that User
|
||||
Product from a modified version of its Corresponding Source. The
|
||||
information must suffice to ensure that the continued functioning of
|
||||
the modified object code is in no case prevented or interfered with
|
||||
solely because modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or
|
||||
updates for a work that has been modified or installed by the
|
||||
recipient, or for the User Product in which it has been modified or
|
||||
installed. Access to a network may be denied when the modification
|
||||
itself materially and adversely affects the operation of the network
|
||||
or violates the rules and protocols for communication across the
|
||||
network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
#### 7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders
|
||||
of that material) supplement the terms of this License with terms:
|
||||
|
||||
- a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
- b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
- c) Prohibiting misrepresentation of the origin of that material,
|
||||
or requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
- d) Limiting the use for publicity purposes of names of licensors
|
||||
or authors of the material; or
|
||||
- e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
- f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions
|
||||
of it) with contractual assumptions of liability to the recipient,
|
||||
for any liability that these contractual assumptions directly
|
||||
impose on those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions; the
|
||||
above requirements apply either way.
|
||||
|
||||
#### 8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your license
|
||||
from a particular copyright holder is reinstated (a) provisionally,
|
||||
unless and until the copyright holder explicitly and finally
|
||||
terminates your license, and (b) permanently, if the copyright holder
|
||||
fails to notify you of the violation by some reasonable means prior to
|
||||
60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
#### 9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or run
|
||||
a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
#### 10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
#### 11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims owned
|
||||
or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within the
|
||||
scope of its coverage, prohibits the exercise of, or is conditioned on
|
||||
the non-exercise of one or more of the rights that are specifically
|
||||
granted under this License. You may not convey a covered work if you
|
||||
are a party to an arrangement with a third party that is in the
|
||||
business of distributing software, under which you make payment to the
|
||||
third party based on the extent of your activity of conveying the
|
||||
work, and under which the third party grants, to any of the parties
|
||||
who would receive the covered work from you, a discriminatory patent
|
||||
license (a) in connection with copies of the covered work conveyed by
|
||||
you (or copies made from those copies), or (b) primarily for and in
|
||||
connection with specific products or compilations that contain the
|
||||
covered work, unless you entered into that arrangement, or that patent
|
||||
license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
#### 12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under
|
||||
this License and any other pertinent obligations, then as a
|
||||
consequence you may not convey it at all. For example, if you agree to
|
||||
terms that obligate you to collect a royalty for further conveying
|
||||
from those to whom you convey the Program, the only way you could
|
||||
satisfy both those terms and this License would be to refrain entirely
|
||||
from conveying the Program.
|
||||
|
||||
#### 13. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your
|
||||
version supports such interaction) an opportunity to receive the
|
||||
Corresponding Source of your version by providing access to the
|
||||
Corresponding Source from a network server at no charge, through some
|
||||
standard or customary means of facilitating copying of software. This
|
||||
Corresponding Source shall include the Corresponding Source for any
|
||||
work covered by version 3 of the GNU General Public License that is
|
||||
incorporated pursuant to the following paragraph.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
#### 14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Affero General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies that a certain numbered version of the GNU Affero General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU Affero General Public License, you may choose any version ever
|
||||
published by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future versions
|
||||
of the GNU Affero General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
#### 15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
|
||||
WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
|
||||
PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE
|
||||
DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
|
||||
CORRECTION.
|
||||
|
||||
#### 16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR
|
||||
CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
|
||||
ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT
|
||||
NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR
|
||||
LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM
|
||||
TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER
|
||||
PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
#### 17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
### How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these
|
||||
terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest to
|
||||
attach them to the start of each source file to most effectively state
|
||||
the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper
|
||||
mail.
|
||||
|
||||
If your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for
|
||||
the specific requirements.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. For more information on this, and how to apply and follow
|
||||
the GNU AGPL, see <https://www.gnu.org/licenses/>.
|
3
README.md
Normal file
3
README.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
# The Momo infrastructure
|
||||
|
||||
This repository aims to contain all of the configuration for the whole Momo infrastructure. Our goal is to have everything, from host configurations to Terraform DNS in this repository.
|
7
docs/README.md
Normal file
7
docs/README.md
Normal file
|
@ -0,0 +1,7 @@
|
|||
# momo documentation
|
||||
|
||||
This directory holds a collection of notes and documentation for momo admins.
|
||||
|
||||
### Systems Overview
|
||||
|
||||
To get a first overview of existing momo systems, please see the [momo systems overview](./systems-overview.md).
|
93
docs/administrative-access.md
Normal file
93
docs/administrative-access.md
Normal file
|
@ -0,0 +1,93 @@
|
|||
# Adminstrative access
|
||||
|
||||
People with admin access to the infrastructure are added to [`logins/admins.nix`](../logins/admins.nix). This is a attrset with the following structure:
|
||||
|
||||
```
|
||||
{
|
||||
<username> = {
|
||||
sshPubKeys = {
|
||||
<name> = <pubkey-string>;
|
||||
};
|
||||
|
||||
wireguardDevices = [
|
||||
{
|
||||
publicKey = <pubkey-string>;
|
||||
allowedIPs = [ "10.30.29.<ip-address>/32" "fd00:3029:3029:3029:3029:<ip-address>::/96" ];
|
||||
}
|
||||
];
|
||||
|
||||
secretEncryptionKeys = {
|
||||
<name> = <encryption-key-string>;
|
||||
};
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
# SSH Access
|
||||
|
||||
SSH is not reachable from the open internet. Instead, SSH Port 22 is protected by a wireguard VPN network. Thus, to get root access on the servers, at least two pieces of information have to be added to the admins config:
|
||||
|
||||
1. **SSH Public key**: self-explanatory. Add your public key to your user attrset under `sshPubKeys`.
|
||||
2. **Wireguard device**: each wireguard device has two parts: the public key and the IP addresses it should have in the wireguard network. To add your device, it's best to choose a free number between 200 and 255 and use that in both the ipv4 and ipv6 ranges, for example: `10.30.29.<ip-address>/32` `fd00:3029:3029:3029:3029:<ip-address>::/96`. For more information on how to generate keypairs, see [the NixOS Wireguard docs](https://wiki.nixos.org/wiki/WireGuard#Generate_keypair).
|
||||
|
||||
One can access our hosts using this domain scheme:
|
||||
|
||||
```
|
||||
ssh <username>@<hostname>.wg.momo.koeln
|
||||
```
|
||||
|
||||
So, for example for `pioneer`:
|
||||
|
||||
```
|
||||
ssh teutat3s@pioneer.wg.momo.koeln
|
||||
```
|
||||
|
||||
Example NixOS snippet for WireGuard client config
|
||||
|
||||
```
|
||||
{
|
||||
networking = {
|
||||
wireguard.enable = true;
|
||||
wg-quick.interfaces = {
|
||||
wg-momo-cloud = {
|
||||
address = [
|
||||
"10.30.29.201/32"
|
||||
"fd00:3029:3029:3029:3029:201::/96"
|
||||
];
|
||||
privateKeyFile = "/etc/wireguard/momo-cloud.privatekey";
|
||||
|
||||
peers = [
|
||||
{
|
||||
# pioneer.momo.koeln
|
||||
publicKey = "W9Vn2yv+AZjOD7sqKp4DyMbIz5N++Vjlr+6J3BnXj3o=";
|
||||
allowedIPs = [
|
||||
"10.30.30.1/32"
|
||||
"fd00:3030:3030:3030:3030:1::/96"
|
||||
];
|
||||
#endpoint = "80.244.242.4:51820";
|
||||
endpoint = "[2001:4d88:1ffa:26::4]:51820";
|
||||
persistentKeepalive = 15;
|
||||
}
|
||||
{
|
||||
# cassiopeia.staging.momo.koeln
|
||||
publicKey = "kFlMTGVLVzBq/KS7YRLmIlJgZ2IVR4mhlkEteJMLaTo=";
|
||||
allowedIPs = [
|
||||
"10.30.31.1/32"
|
||||
"fd00:3031:3031:3031:3031:1::/96"
|
||||
];
|
||||
#endpoint = "80.244.242.6:51820";
|
||||
endpoint = "[2001:4d88:1ffa:26::6]:51820";
|
||||
persistentKeepalive = 15;
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
# Secret encryption
|
||||
|
||||
Deployment secrets are added to the repository in encrypted files. To be able to work with these encrypted files, your public key(s) will have to be added to your user attrset under `secretEncryptionKeys`.
|
||||
|
||||
See also the docs on [working with secrets](./secrets.md).
|
10
docs/akaunting-setup.md
Normal file
10
docs/akaunting-setup.md
Normal file
|
@ -0,0 +1,10 @@
|
|||
# Akaunting setup
|
||||
|
||||
[Upstream docker](https://github.com/akaunting/docker/issues/114#issuecomment-2558426282) uses named volumes. We need bind mount volumes, to allow our nginx to access static files.
|
||||
A few manual commands necessary to install akaunting into the bind mount:
|
||||
|
||||
```
|
||||
curl -Lo /tmp/akaunting.zip 'https://akaunting.com/download.php?version=latest&utm_source=docker&utm_campaign=developers'
|
||||
sudo nix run nixpkgs#unzip -- /tmp/akaunting.zip -d /var/lib/akaunting
|
||||
rm /tmp/akaunting.zip
|
||||
```
|
0
docs/akaunting.md
Normal file
0
docs/akaunting.md
Normal file
19
docs/backups.md
Normal file
19
docs/backups.md
Normal file
|
@ -0,0 +1,19 @@
|
|||
# Backups
|
||||
|
||||
We use [Restic](https://restic.readthedocs.io/en/stable/) to create backups and push them to two repositories.
|
||||
Check `./modules/backups.nix` and `./hosts/nachtigall/backups.nix` for working examples.
|
||||
|
||||
### Hetzner Storagebox
|
||||
|
||||
- Uses SFTP for transfer of backups
|
||||
|
||||
Adding a new host SSH public key to the storagebox:
|
||||
|
||||
First, [SSH to pioneer](./administrative-access.md#ssh-access), then become root and add the new SSH public key
|
||||
|
||||
```
|
||||
sudo -i
|
||||
echo '<ssh-public-key>' | ssh -p23 <user>@<user>.your-storagebox.de install-ssh-key
|
||||
```
|
||||
|
||||
[Link to Hetzner storagebox docs](https://docs.hetzner.com/robot/storage-box/backup-space-ssh-keys).
|
40
docs/deploying.md
Normal file
40
docs/deploying.md
Normal file
|
@ -0,0 +1,40 @@
|
|||
# Deploying new versions
|
||||
|
||||
We use [deploy-rs](https://github.com/serokell/deploy-rs) to deploy changes.
|
||||
Currently this process is not automated, so configuration changes will have to
|
||||
be manually deployed.
|
||||
|
||||
To deploy, make sure you have a [working development shell](./development-shell.md).
|
||||
Then, run `deploy-rs` with the hostname of the server you want to deploy:
|
||||
|
||||
For pioneer.momo.koeln:
|
||||
|
||||
```
|
||||
deploy --targets '.#pioneer' --magic-rollback false --auto-rollback false --keep-result --result-path ./results
|
||||
```
|
||||
|
||||
For cassiopeia.staging.momo.koeln:
|
||||
|
||||
```
|
||||
deploy --targets '.#cassiopeia' --magic-rollback false --auto-rollback false --keep-result --result-path ./results
|
||||
```
|
||||
|
||||
Usually we skip all rollback functionality, but if you want to deploy a change
|
||||
that might lock you out, e.g. to SSH, it might make sense to set these to `true`.
|
||||
|
||||
To skip flake checks, e.g. because you already ran them manually before
|
||||
deployment, add the flag `--skip-checks` at the end of the command.
|
||||
|
||||
`--dry-activate` can be used to only put all files in place without switching,
|
||||
to enable switching to the new config quickly at a later moment.
|
||||
|
||||
We use `--keep-result --result-path ./results` to keep the last `result`
|
||||
symlink of each `deploy` from being garbage collected. That way, we keep builds
|
||||
cached in the Nix store. This is optional and both flags can be removed if disk
|
||||
space is a scarce resource on your machine.
|
||||
|
||||
You'll need to have SSH Access to the boxes to be able to run `deploy`.
|
||||
|
||||
### Getting SSH access
|
||||
|
||||
See [administrative-access.md](./administrative-access.md).
|
45
docs/dns.md
Normal file
45
docs/dns.md
Normal file
|
@ -0,0 +1,45 @@
|
|||
# Changing DNS entries
|
||||
|
||||
Our current DNS provider is [hosting.de](https://hosting.de/).
|
||||
We use [OpenTofu](https://opentofu.org/) to declaratively manage our momo.koeln DNS records.
|
||||
|
||||
### Initial setup
|
||||
|
||||
You will need to setup [hosting.de API credentials](https://www.hosting.de/api/#requests-and-authentication),
|
||||
look for "hosting.de admin API token" in the momo KeePass database.
|
||||
|
||||
```
|
||||
export HOSTINGDE_AUTH_TOKEN=<your-API-token>
|
||||
```
|
||||
|
||||
Now, change into the terraform directory and initialize the opentofu providers.
|
||||
|
||||
```
|
||||
cd terraform/momo
|
||||
|
||||
tofu init
|
||||
```
|
||||
|
||||
Make your changes, e.g. in `dns.tf`.
|
||||
|
||||
```
|
||||
$EDITOR dns.tf
|
||||
```
|
||||
|
||||
Plan your changes using:
|
||||
|
||||
```
|
||||
tofu plan -out momo-infra.plan
|
||||
```
|
||||
|
||||
After verification, apply your changes with:
|
||||
|
||||
```
|
||||
tofu apply "momo-infra.plan"
|
||||
```
|
||||
|
||||
### Useful links
|
||||
|
||||
hosting.de OpenTofu provider docs:
|
||||
|
||||
- https://registry.terraform.io/providers/pub-solar/hostingde/latest
|
40
docs/invoiceplane.md
Normal file
40
docs/invoiceplane.md
Normal file
|
@ -0,0 +1,40 @@
|
|||
# Invoiceplane
|
||||
|
||||
Initial setup with `services.invoiceplane.sites.<name>.database.createLocally`
|
||||
requires manual editing of `ipconfig.php`, to allow creation of the first admin user.
|
||||
Access to the database is provided via socket + matching unix username, which
|
||||
means there is no password. During the invoiceplane setup in the Web UI,
|
||||
filling the invoiceplane database form does not work, because a password will be
|
||||
required.
|
||||
|
||||
First change these environment variables to `false`, then go to https://invoicing.momo.koeln/setup.
|
||||
|
||||
```
|
||||
services.invoiceplane.sites."invoicing.${config.momo-cloud.networking.domain}" = {
|
||||
settings = {
|
||||
DISABLE_SETUP=false;
|
||||
SETUP_COMPLETED=false;
|
||||
};
|
||||
};
|
||||
```
|
||||
|
||||
Before continuing the setup wizard in the Web UI, SSH into the server and edit
|
||||
`/var/lib/invoiceplane/invoicing.momo.koeln/ipconfig.php`
|
||||
|
||||
```
|
||||
momo in 🌐 pioneer in ~
|
||||
sudo vim /var/lib/invoiceplane/invoicing.momo.koeln/ipconfig.php
|
||||
```
|
||||
|
||||
Set the following environment variables:
|
||||
|
||||
```
|
||||
DB_USERNAME='invoiceplane'
|
||||
DB_DATABASE='invoiceplane'
|
||||
```
|
||||
|
||||
This will allow to click through the setup wizard without having to fill in
|
||||
anything. After database migrations have run, you will be prompted to create
|
||||
the first admin user.
|
||||
|
||||
Source: https://wiki.nixos.org/wiki/Invoiceplane
|
3
docs/mail.md
Normal file
3
docs/mail.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
### Mail
|
||||
|
||||
mail.momo.koeln aka pioneer.momo.koeln hosts our mail server.
|
23
docs/nextcloud-setup.md
Normal file
23
docs/nextcloud-setup.md
Normal file
|
@ -0,0 +1,23 @@
|
|||
# Nextcloud setup
|
||||
|
||||
For a basic nextcloud setup, we'll have to generate the following secrets:
|
||||
|
||||
- A database password (alphanumeric any size)
|
||||
- A cookie secret (alphanumeric any size)
|
||||
- A password salt (alphanumeric any size)
|
||||
- An oidc secret (alphanumeric any size)
|
||||
- An admin password (alphanumeric any size)
|
||||
|
||||
## Signaling
|
||||
|
||||
- Nextcloud secret: `openssl -rand -hex 16`
|
||||
- Signaling block key: `openssl rand -hex 16`
|
||||
- Signaling hash key: `openssl rand -hex 16`
|
||||
|
||||
## Coturn
|
||||
|
||||
- static auth secret: `openssl rand -hex 32`
|
||||
|
||||
## Janus
|
||||
|
||||
- Janus api key: `openssl rand -base64 16`
|
43
docs/nix-flake-updates.md
Normal file
43
docs/nix-flake-updates.md
Normal file
|
@ -0,0 +1,43 @@
|
|||
Use these commands to show the diff between versions for planning updates:
|
||||
|
||||
```
|
||||
OLD_CLOSURE=$(nix build --print-out-paths .#nixosConfigurations.nachtigall.config.system.build.toplevel)
|
||||
/nix/store/c6wqp1vzvyr3bq2igd8p460613ddwrmj-nixos-system-nachtigall-23.11.20231201.5de0b32
|
||||
```
|
||||
|
||||
```
|
||||
nix flake update
|
||||
...
|
||||
```
|
||||
|
||||
```
|
||||
NEW_CLOSURE=$(nix build --print-out-paths .#nixosConfigurations.nachtigall.config.system.build.toplevel)
|
||||
/nix/store/xynyf943d2nw1wgawhzxh13xkkf1whb0-nixos-system-nachtigall-23.11.20231210.781e2a9
|
||||
```
|
||||
|
||||
```
|
||||
nix store diff-closures $OLD_CLOSURE $NEW_CLOSURE
|
||||
cpupower: 6.1.64 → 6.1.66
|
||||
element-web: 1.11.47 → 1.11.51, +5325.9 KiB
|
||||
element-web-wrapped: 1.11.47 → 1.11.51
|
||||
initrd-linux: 6.1.64 → 6.1.66
|
||||
keycloak: 22.0.5 → 23.0.0, +15201.4 KiB
|
||||
linux: 6.1.64, 6.1.64-modules → 6.1.66, 6.1.66-modules, +8.3 KiB
|
||||
mastodon: 4.2.1 → 4.2.3, +16.3 KiB
|
||||
mastodon-gems: 4.2.1 → 4.2.3, +14.4 KiB
|
||||
mastodon-modules: 4.2.1 → 4.2.3
|
||||
nix: +18.8 KiB
|
||||
nixos-manual: +73.6 KiB
|
||||
nixos-system-nachtigall: 23.11.20231201.5de0b32 → 23.11.20231210.781e2a9
|
||||
opensearch: 2.11.0 → 2.11.1, +560.5 KiB
|
||||
owncast: 0.1.1 → 0.1.2, +798.9 KiB
|
||||
ruby3.2.2-bcp47_spec: ∅ → 0.2.1, +13.6 KiB
|
||||
ruby3.2.2-json-canonicalization: 0.3.2 → 1.0.0
|
||||
ruby3.2.2-json-ld: 3.2.5 → 3.3.1
|
||||
ruby3.2.2-rdf: 3.2.11 → 3.3.1
|
||||
samba: +12.5 KiB
|
||||
source: +3888.1 KiB
|
||||
wrapped-ruby-mastodon-gems: 4.2.1 → 4.2.3
|
||||
zfs-kernel: 2.2.1-6.1.64 → 2.2.2-6.1.66
|
||||
zfs-user: 2.2.1 → 2.2.2
|
||||
```
|
13
docs/nixos-anywhere.md
Normal file
13
docs/nixos-anywhere.md
Normal file
|
@ -0,0 +1,13 @@
|
|||
```
|
||||
curl -L https://github.com/nix-community/nixos-images/releases/download/nixos-unstable/nixos-kexec-installer-noninteractive-x86_64-linux.tar.gz | tar -xzf- -C /root
|
||||
/root/kexec/run
|
||||
```
|
||||
|
||||
```
|
||||
mkdir -p /etc/secrets/initrd
|
||||
ssh-keygen -t ed25519 -f /etc/secrets/initrd/ssh_host_ed25519_key
|
||||
```
|
||||
|
||||
```
|
||||
nix run github:nix-community/nixos-anywhere -- --flake .#blue-shell root@194.13.83.205
|
||||
```
|
10
docs/paperless-setup.md
Normal file
10
docs/paperless-setup.md
Normal file
|
@ -0,0 +1,10 @@
|
|||
# Paperless setup
|
||||
|
||||
Summary
|
||||
|
||||
1. Create a working paperless instance with regular login enabled
|
||||
1. Create the initial superuser via CLI
|
||||
1. Login as the superuser
|
||||
1. Create groups that map groups in `kanidm`:
|
||||
1. `paperless_users` -> with view permissions for users and groups in paperless
|
||||
1. `paperless_admins` -> all permissions
|
18
docs/paperless.md
Normal file
18
docs/paperless.md
Normal file
|
@ -0,0 +1,18 @@
|
|||
# Paperless initial setup
|
||||
|
||||
Login will not work until the first superuser account has been created. Use the
|
||||
following command **before trying to login with authelia** to create the initial
|
||||
superuser account:
|
||||
|
||||
```
|
||||
sudo /var/lib/paperless/paperless-manage createsuperuser
|
||||
```
|
||||
|
||||
Without this, a 403 error can be observed in the network tab.
|
||||
Other errors in the Web UI that indicate this are:
|
||||
`Something went wrong"
|
||||
|
||||
In `paperless-web.service` logs
|
||||
`Forbidden: /api/ui_settings/`
|
||||
|
||||
Source: https://wiki.nixos.org/wiki/Paperless
|
11
docs/privacy-hardening.md
Normal file
11
docs/privacy-hardening.md
Normal file
|
@ -0,0 +1,11 @@
|
|||
# Privacy hardening
|
||||
|
||||
Some default options in the services we run are not as privacy friendly as they can be. Oftentimes, services assume they are running for an organization in which everyone knows (or wants to know) everyone else. However, when running a public service accounts should be hidden from other users.
|
||||
|
||||
## Nextcloud account leaking
|
||||
|
||||
By default, accounts are visible globally across the instance. To prevent this, go into the administration settings -> Sharing. Check the option saying "Restrict users to only share with users in their group".
|
||||
|
||||
## Forgejo email leaking
|
||||
|
||||
By default, emails are visible on the explore page for other logged in users. We have disabled this in the config by setting `service.DEFAULT_KEEP_EMAIL_PRIVATE` to `true`.
|
5
docs/rescue.md
Normal file
5
docs/rescue.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
# Rescue and remote console
|
||||
|
||||
Rescue is enabled in the Hetzner interface. Check the shared keepass file for credentials.
|
||||
|
||||
The remote console can be requested with Hetzner support. See [the Hetzner docs](https://docs.hetzner.com/robot/dedicated-server/maintainance/kvm-console/) for more information.
|
1
docs/reverting-version.md
Normal file
1
docs/reverting-version.md
Normal file
|
@ -0,0 +1 @@
|
|||
# Reverting to an old version
|
5
docs/secrets.md
Normal file
5
docs/secrets.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
# Working with secrets
|
||||
|
||||
Secrets are handled with [agenix](https://github.com/ryantm/agenix). To be able to view secrets, your public key will have to be added to the admins config. See [Administrative Access](./administrative-access.md) on how to do this.
|
||||
|
||||
For a comprehensive tutorial, see [the agenix repository](https://github.com/ryantm/agenix?tab=readme-ov-file#tutorial).
|
20
docs/unlocking-luks.md
Normal file
20
docs/unlocking-luks.md
Normal file
|
@ -0,0 +1,20 @@
|
|||
# Unlocking disk with LUKS on boot
|
||||
|
||||
After a reboot, the disk encrypted with LUKS will have to be unlocked. This is done by
|
||||
accessing the server via SSH as user `root` on port 2222.
|
||||
|
||||
pioneer:
|
||||
|
||||
```
|
||||
ssh -4 root@pioneer.momo.koeln -p 2222
|
||||
```
|
||||
|
||||
cassiopeia:
|
||||
|
||||
```
|
||||
ssh -4 root@cassiopeia.staging.momo.koeln -p 2222
|
||||
```
|
||||
|
||||
After connecting, paste the encryption passphrase you can find in the shared
|
||||
keepass. This will disconnect the SSH session immediately and the server will
|
||||
continue to boot into stage 2.
|
20
docs/unlocking-zfs-pool.md
Normal file
20
docs/unlocking-zfs-pool.md
Normal file
|
@ -0,0 +1,20 @@
|
|||
# Unlocking the ZFS pool on boot
|
||||
|
||||
After a reboot, the encrypted ZFS pool will have to be unlocked. This is done by
|
||||
accessing the server via SSH as user `root` on port 2222.
|
||||
|
||||
Nachtigall:
|
||||
|
||||
```
|
||||
ssh -4 root@nachtigall.pub.solar -p2222
|
||||
```
|
||||
|
||||
Metronom:
|
||||
|
||||
```
|
||||
ssh -4 root@metronom.pub.solar -p2222
|
||||
```
|
||||
|
||||
After connecting, paste the encryption passphrase you can find in the shared
|
||||
keepass. This will disconnect the SSH session immediately and the server will
|
||||
continue to boot into stage 2.
|
9
docs/wireguard.md
Normal file
9
docs/wireguard.md
Normal file
|
@ -0,0 +1,9 @@
|
|||
# WireGuard network subnets
|
||||
|
||||
The following network subnets are currently in use for WireGuard:
|
||||
|
||||
| Subnet | Usage |
|
||||
| ------------- | ------------------ |
|
||||
| 10.30.29.0/24 | Admin devices |
|
||||
| 10.30.30.0/24 | Production servers |
|
||||
| 10.30.31.0/24 | Staging servers |
|
373
flake.lock
generated
Normal file
373
flake.lock
generated
Normal file
|
@ -0,0 +1,373 @@
|
|||
{
|
||||
"nodes": {
|
||||
"agenix": {
|
||||
"inputs": {
|
||||
"darwin": "darwin",
|
||||
"home-manager": [
|
||||
"home-manager"
|
||||
],
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
],
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1736955230,
|
||||
"narHash": "sha256-uenf8fv2eG5bKM8C/UvFaiJMZ4IpUFaQxk9OH5t/1gA=",
|
||||
"owner": "ryantm",
|
||||
"repo": "agenix",
|
||||
"rev": "e600439ec4c273cf11e06fe4d9d906fb98fa097c",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "ryantm",
|
||||
"repo": "agenix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"blobs": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1604995301,
|
||||
"narHash": "sha256-wcLzgLec6SGJA8fx1OEN1yV/Py5b+U5iyYpksUY/yLw=",
|
||||
"owner": "simple-nixos-mailserver",
|
||||
"repo": "blobs",
|
||||
"rev": "2cccdf1ca48316f2cfd1c9a0017e8de5a7156265",
|
||||
"type": "gitlab"
|
||||
},
|
||||
"original": {
|
||||
"owner": "simple-nixos-mailserver",
|
||||
"repo": "blobs",
|
||||
"type": "gitlab"
|
||||
}
|
||||
},
|
||||
"darwin": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"agenix",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1700795494,
|
||||
"narHash": "sha256-gzGLZSiOhf155FW7262kdHo2YDeugp3VuIFb4/GGng0=",
|
||||
"owner": "lnl7",
|
||||
"repo": "nix-darwin",
|
||||
"rev": "4b9b83d5a92e8c1fbfd8eb27eda375908c11ec4d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "lnl7",
|
||||
"ref": "master",
|
||||
"repo": "nix-darwin",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"deploy-rs": {
|
||||
"inputs": {
|
||||
"flake-compat": "flake-compat",
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
],
|
||||
"utils": "utils"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1727447169,
|
||||
"narHash": "sha256-3KyjMPUKHkiWhwR91J1YchF6zb6gvckCAY1jOE+ne0U=",
|
||||
"owner": "serokell",
|
||||
"repo": "deploy-rs",
|
||||
"rev": "aa07eb05537d4cd025e2310397a6adcedfe72c76",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "serokell",
|
||||
"repo": "deploy-rs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"disko": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1744145203,
|
||||
"narHash": "sha256-I2oILRiJ6G+BOSjY+0dGrTPe080L3pbKpc+gCV3Nmyk=",
|
||||
"owner": "nix-community",
|
||||
"repo": "disko",
|
||||
"rev": "76c0a6dba345490508f36c1aa3c7ba5b6b460989",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "disko",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-compat": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1696426674,
|
||||
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-compat_2": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1696426674,
|
||||
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-parts": {
|
||||
"inputs": {
|
||||
"nixpkgs-lib": "nixpkgs-lib"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1743550720,
|
||||
"narHash": "sha256-hIshGgKZCgWh6AYJpJmRgFdR3WUbkY04o82X05xqQiY=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"rev": "c621e8422220273271f52058f618c94e405bb0f5",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"home-manager": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1744117652,
|
||||
"narHash": "sha256-t7dFCDl4vIOOUMhEZnJF15aAzkpaup9x4ZRGToDFYWI=",
|
||||
"owner": "nix-community",
|
||||
"repo": "home-manager",
|
||||
"rev": "b4e98224ad1336751a2ac7493967a4c9f6d9cb3f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"ref": "release-24.11",
|
||||
"repo": "home-manager",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"invoiceplane-template": {
|
||||
"inputs": {
|
||||
"flake-parts": [
|
||||
"flake-parts"
|
||||
],
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1728398621,
|
||||
"narHash": "sha256-cNCgW0g012t7lZ2gxBpc+Uu6GHV2sTEsOV50nSZ96FM=",
|
||||
"ref": "refs/heads/main",
|
||||
"rev": "a4f2aa76583b5dfa3f2db12ff360ba9f229cfb2f",
|
||||
"revCount": 37,
|
||||
"type": "git",
|
||||
"url": "https://git.pub.solar/momo/invoiceplane-templates.git"
|
||||
},
|
||||
"original": {
|
||||
"type": "git",
|
||||
"url": "https://git.pub.solar/momo/invoiceplane-templates.git"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1744440957,
|
||||
"narHash": "sha256-FHlSkNqFmPxPJvy+6fNLaNeWnF1lZSgqVCl/eWaJRc4=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "26d499fc9f1d567283d5d56fcf367edd815dba1d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "nixos-24.11",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs-lib": {
|
||||
"locked": {
|
||||
"lastModified": 1743296961,
|
||||
"narHash": "sha256-b1EdN3cULCqtorQ4QeWgLMrd5ZGOjLSLemfa00heasc=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nixpkgs.lib",
|
||||
"rev": "e4822aea2a6d1cdd36653c134cacfd64c97ff4fa",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "nixpkgs.lib",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs-master": {
|
||||
"locked": {
|
||||
"lastModified": 1744734272,
|
||||
"narHash": "sha256-P32AWRtc13VZMfSubFKShFHacXRy6od/ILrwmEgkq9c=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "3e5bb71d1ab409b4110a66b8aa340d664892579a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "master",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs-nc-spreed-signaling-pr": {
|
||||
"locked": {
|
||||
"lastModified": 1742859343,
|
||||
"narHash": "sha256-20TWYfC3kaDgDwHrk/v1EXCNJ3AshgCdTAuxnza48WQ=",
|
||||
"owner": "hensoko",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "86025a170c7d3b8ac7b467b9501598885b8c8728",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "hensoko",
|
||||
"ref": "nextcloud-spreed-signaling",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs-unstable": {
|
||||
"locked": {
|
||||
"lastModified": 1744463964,
|
||||
"narHash": "sha256-LWqduOgLHCFxiTNYi3Uj5Lgz0SR+Xhw3kr/3Xd0GPTM=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "2631b0b7abcea6e640ce31cd78ea58910d31e650",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"agenix": "agenix",
|
||||
"deploy-rs": "deploy-rs",
|
||||
"disko": "disko",
|
||||
"flake-parts": "flake-parts",
|
||||
"home-manager": "home-manager",
|
||||
"invoiceplane-template": "invoiceplane-template",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"nixpkgs-master": "nixpkgs-master",
|
||||
"nixpkgs-nc-spreed-signaling-pr": "nixpkgs-nc-spreed-signaling-pr",
|
||||
"nixpkgs-unstable": "nixpkgs-unstable",
|
||||
"simple-nixos-mailserver": "simple-nixos-mailserver"
|
||||
}
|
||||
},
|
||||
"simple-nixos-mailserver": {
|
||||
"inputs": {
|
||||
"blobs": "blobs",
|
||||
"flake-compat": "flake-compat_2",
|
||||
"nixpkgs": [
|
||||
"nixpkgs-unstable"
|
||||
],
|
||||
"nixpkgs-24_11": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1734884447,
|
||||
"narHash": "sha256-HA9fAmGNGf0cOYrhgoa+B6BxNVqGAYXfLyx8zIS0ZBY=",
|
||||
"owner": "simple-nixos-mailserver",
|
||||
"repo": "nixos-mailserver",
|
||||
"rev": "63209b1def2c9fc891ad271f474a3464a5833294",
|
||||
"type": "gitlab"
|
||||
},
|
||||
"original": {
|
||||
"owner": "simple-nixos-mailserver",
|
||||
"ref": "nixos-24.11",
|
||||
"repo": "nixos-mailserver",
|
||||
"type": "gitlab"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems_2": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"utils": {
|
||||
"inputs": {
|
||||
"systems": "systems_2"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1701680307,
|
||||
"narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "4022d587cbbfd70fe950c1e2083a02621806a725",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
102
flake.nix
Normal file
102
flake.nix
Normal file
|
@ -0,0 +1,102 @@
|
|||
{
|
||||
inputs = {
|
||||
# Track channels with commits tested and built by hydra
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11";
|
||||
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
nixpkgs-master.url = "github:nixos/nixpkgs/master";
|
||||
|
||||
nixpkgs-nc-spreed-signaling-pr.url = "github:hensoko/nixpkgs/nextcloud-spreed-signaling";
|
||||
|
||||
home-manager.url = "github:nix-community/home-manager/release-24.11";
|
||||
home-manager.inputs.nixpkgs.follows = "nixpkgs";
|
||||
|
||||
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||
|
||||
simple-nixos-mailserver.url = "gitlab:simple-nixos-mailserver/nixos-mailserver/nixos-24.11";
|
||||
simple-nixos-mailserver.inputs.nixpkgs-24_11.follows = "nixpkgs";
|
||||
simple-nixos-mailserver.inputs.nixpkgs.follows = "nixpkgs-unstable";
|
||||
|
||||
invoiceplane-template.url = "git+https://git.pub.solar/momo/invoiceplane-templates.git";
|
||||
invoiceplane-template.inputs.nixpkgs.follows = "nixpkgs";
|
||||
invoiceplane-template.inputs.flake-parts.follows = "flake-parts";
|
||||
};
|
||||
|
||||
outputs =
|
||||
inputs@{ self, ... }:
|
||||
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
|
||||
systems = [
|
||||
"x86_64-linux"
|
||||
"aarch64-linux"
|
||||
];
|
||||
|
||||
imports = [
|
||||
inputs.flake-parts.flakeModules.easyOverlay
|
||||
./lib
|
||||
./overlays
|
||||
./modules
|
||||
];
|
||||
|
||||
perSystem =
|
||||
args@{
|
||||
system,
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{
|
||||
packages = import ./pkgs args;
|
||||
overlayAttrs = config.packages;
|
||||
|
||||
_module.args = {
|
||||
inherit inputs;
|
||||
pkgs = import inputs.nixpkgs {
|
||||
inherit system;
|
||||
};
|
||||
unstable = import inputs.nixpkgs-unstable { inherit system; };
|
||||
};
|
||||
|
||||
checks =
|
||||
let
|
||||
nixos-lib = import (inputs.nixpkgs + "/nixos/lib") { };
|
||||
testDir = builtins.attrNames (builtins.readDir ./tests);
|
||||
testFiles = builtins.filter (n: builtins.match "^.*.nix$" n != null) testDir;
|
||||
in
|
||||
builtins.listToAttrs (
|
||||
map (x: {
|
||||
name = "test-${lib.strings.removeSuffix ".nix" x}";
|
||||
value = nixos-lib.runTest (
|
||||
import (./tests + "/${x}") {
|
||||
inherit self;
|
||||
inherit pkgs;
|
||||
inherit lib;
|
||||
inherit config;
|
||||
}
|
||||
);
|
||||
}) testFiles
|
||||
);
|
||||
|
||||
devShells.default = pkgs.mkShell {
|
||||
buildInputs = with pkgs; [
|
||||
nix-fast-build
|
||||
cachix
|
||||
editorconfig-checker
|
||||
nodePackages.prettier
|
||||
nvfetcher
|
||||
shellcheck
|
||||
shfmt
|
||||
treefmt2
|
||||
nixos-generators
|
||||
jq
|
||||
mob
|
||||
];
|
||||
};
|
||||
|
||||
devShells.ci = pkgs.mkShell { buildInputs = with pkgs; [ nodejs_22 ]; };
|
||||
};
|
||||
|
||||
flake = {
|
||||
formatter."x86_64-linux" = inputs.nixpkgs.legacyPackages."x86_64-linux".nixfmt-rfc-style;
|
||||
};
|
||||
};
|
||||
}
|
21
lib/compat/default.nix
Normal file
21
lib/compat/default.nix
Normal file
|
@ -0,0 +1,21 @@
|
|||
let
|
||||
lock = builtins.fromJSON (
|
||||
builtins.readFile builtins.path {
|
||||
path = ../../flake.lock;
|
||||
name = "lockPath";
|
||||
}
|
||||
);
|
||||
flake =
|
||||
import
|
||||
(fetchTarball {
|
||||
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
|
||||
sha256 = lock.nodes.flake-compat.locked.narHash;
|
||||
})
|
||||
{
|
||||
src = builtins.path {
|
||||
path = ../../.;
|
||||
name = "projectRoot";
|
||||
};
|
||||
};
|
||||
in
|
||||
flake
|
10
lib/compat/nixos/default.nix
Normal file
10
lib/compat/nixos/default.nix
Normal file
|
@ -0,0 +1,10 @@
|
|||
{ ... }:
|
||||
let
|
||||
inherit (default.inputs.nixos) lib;
|
||||
|
||||
host = configs.${hostname} or configs.PubSolarOS;
|
||||
configs = default.nixosConfigurations;
|
||||
default = (import ../.).defaultNix;
|
||||
hostname = lib.fileContents /etc/hostname;
|
||||
in
|
||||
host
|
24
lib/default.nix
Normal file
24
lib/default.nix
Normal file
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
self,
|
||||
lib,
|
||||
inputs,
|
||||
...
|
||||
}:
|
||||
{
|
||||
# Configuration common to all Linux systems
|
||||
flake = {
|
||||
lib =
|
||||
let
|
||||
callLibs = file: import file { inherit lib; };
|
||||
in
|
||||
rec {
|
||||
## Define your own library functions here!
|
||||
#id = x: x;
|
||||
## Or in files, containing functions that take {lib}
|
||||
#foo = callLibs ./foo.nix;
|
||||
## In configs, they can be used under "lib.our"
|
||||
|
||||
wireguardDevicesForUsers = callLibs ./wireguardDevicesForUsers.nix;
|
||||
};
|
||||
};
|
||||
}
|
6
lib/wireguardDevicesForUsers.nix
Normal file
6
lib/wireguardDevicesForUsers.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
{ lib }:
|
||||
users:
|
||||
lib.lists.foldl (
|
||||
wireguardDevices: userConfig:
|
||||
wireguardDevices ++ (if userConfig ? "wireguardDevices" then userConfig.wireguardDevices else [ ])
|
||||
) [ ] (lib.attrsets.attrValues users)
|
50
modules/acme/default.nix
Normal file
50
modules/acme/default.nix
Normal file
|
@ -0,0 +1,50 @@
|
|||
{
|
||||
flake,
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{
|
||||
options.momo-cloud.acme =
|
||||
let
|
||||
inherit (lib) mkOption mkEnableOption types;
|
||||
in
|
||||
{
|
||||
enable = mkEnableOption ''
|
||||
Whether to configure ACME default settings for momo-cloud (currently DNS challenge)
|
||||
'';
|
||||
|
||||
staging = mkEnableOption ''
|
||||
Run against letsencrypt staging URL
|
||||
'';
|
||||
|
||||
email = mkOption {
|
||||
description = "Email used for ACME authentication";
|
||||
type = types.str;
|
||||
default = "admins@momo.koeln";
|
||||
};
|
||||
|
||||
credentialsFile = mkOption {
|
||||
description = "File that holds the acme DNS secrets";
|
||||
type = types.nullOr types.path;
|
||||
default = null;
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf config.momo-cloud.acme.enable {
|
||||
security.acme = {
|
||||
acceptTerms = true;
|
||||
|
||||
defaults = {
|
||||
email = config.momo-cloud.acme.email;
|
||||
server = lib.mkIf config.momo-cloud.acme.staging "https://acme-staging-v02.api.letsencrypt.org/directory";
|
||||
dnsProvider = "hostingde";
|
||||
dnsPropagationCheck = true;
|
||||
credentialsFile = config.momo-cloud.acme.credentialsFile;
|
||||
group = "nginx";
|
||||
webroot = null;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
198
modules/akaunting/default.nix
Normal file
198
modules/akaunting/default.nix
Normal file
|
@ -0,0 +1,198 @@
|
|||
{
|
||||
config,
|
||||
flake,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
let
|
||||
backupDir = "/var/backups/akaunting";
|
||||
in
|
||||
{
|
||||
options.momo-cloud.akaunting = with lib; {
|
||||
enable = mkEnableOption "Enable akaunting instance";
|
||||
|
||||
envFile = mkOption { type = types.str; };
|
||||
};
|
||||
|
||||
config = lib.mkIf config.momo-cloud.akaunting.enable {
|
||||
momo-cloud.docker.enable = true;
|
||||
momo-cloud.postgresql.enable = true;
|
||||
momo-cloud.http-server.enable = true;
|
||||
momo-cloud.acme.enable = true;
|
||||
|
||||
systemd.services."docker-network-akaunting" =
|
||||
let
|
||||
docker = config.virtualisation.oci-containers.backend;
|
||||
dockerBin = "${pkgs.${docker}}/bin/${docker}";
|
||||
in
|
||||
{
|
||||
serviceConfig.Type = "oneshot";
|
||||
before = [ "docker-akaunting.service" ];
|
||||
requiredBy = [ "docker-akaunting.service" ];
|
||||
script = ''
|
||||
${dockerBin} network inspect akaunting >/dev/null 2>&1 || ${dockerBin} network create akaunting --subnet 172.21.0.0/24
|
||||
'';
|
||||
};
|
||||
|
||||
services.nginx.virtualHosts."akaunting.${config.momo-cloud.networking.domain}" = {
|
||||
enableACME = true;
|
||||
forceSSL = true;
|
||||
root = "/var/lib/akaunting";
|
||||
extraConfig = ''
|
||||
index index.html index.htm index.php;
|
||||
error_page 404 /index.php;
|
||||
'';
|
||||
|
||||
locations."/" = {
|
||||
priority = 100;
|
||||
extraConfig = ''
|
||||
try_files $uri $uri/ /index.php?$query_string;
|
||||
'';
|
||||
};
|
||||
|
||||
# Prevent Direct Access To Protected Files
|
||||
locations."~ \\.(env|log)" = {
|
||||
priority = 200;
|
||||
extraConfig = ''
|
||||
deny all;
|
||||
'';
|
||||
};
|
||||
|
||||
# # Prevent Direct Access To Protected Folders
|
||||
locations."~ ^/(^app$|bootstrap|config|database|overrides|resources|routes|storage|tests|artisan)" =
|
||||
{
|
||||
priority = 300;
|
||||
extraConfig = ''
|
||||
deny all;
|
||||
'';
|
||||
};
|
||||
|
||||
# Prevent Direct Access To modules/vendor Folders Except Assets
|
||||
locations."~ ^/(modules|vendor)\\/(.*)\\.((?!ico|gif|jpg|jpeg|png|js\\b|css|less|sass|font|woff|woff2|eot|ttf|svg).)*$" =
|
||||
{
|
||||
priority = 400;
|
||||
extraConfig = ''
|
||||
deny all;
|
||||
'';
|
||||
};
|
||||
|
||||
# Pass PHP Scripts To FastCGI Server
|
||||
locations."~ \\.php$" = {
|
||||
root = "/var/www/html";
|
||||
priority = 500;
|
||||
extraConfig = ''
|
||||
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
||||
fastcgi_pass 127.0.0.1:8123;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
include ${pkgs.nginx}/conf/fastcgi.conf;
|
||||
'';
|
||||
};
|
||||
|
||||
locations."~ /\\.(?!well-known).*" = {
|
||||
priority = 600;
|
||||
extraConfig = ''
|
||||
deny all;
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
virtualisation = {
|
||||
oci-containers = {
|
||||
backend = "docker";
|
||||
|
||||
containers."mysql" = {
|
||||
image = "mariadb:11.7.2";
|
||||
autoStart = true;
|
||||
|
||||
extraOptions = [
|
||||
"--network=akaunting"
|
||||
];
|
||||
|
||||
environment = {
|
||||
MYSQL_DATABASE = "akaunting";
|
||||
};
|
||||
|
||||
volumes = [
|
||||
"/var/lib/mysql:/var/lib/mysql"
|
||||
];
|
||||
environmentFiles = [
|
||||
config.momo-cloud.akaunting.envFile
|
||||
];
|
||||
};
|
||||
containers."akaunting" = {
|
||||
image = "docker.io/akaunting/akaunting:3.1.15-fpm-alpine";
|
||||
autoStart = true;
|
||||
|
||||
ports = [ "127.0.0.1:8123:9000" ];
|
||||
|
||||
extraOptions = [
|
||||
"--pull=always"
|
||||
"--network=akaunting"
|
||||
];
|
||||
|
||||
environment = {
|
||||
APP_DEBUG = "false";
|
||||
|
||||
APP_URL = "https://akaunting.miom.space";
|
||||
LOCALE = "en-US";
|
||||
|
||||
# Set to true in initial deployment
|
||||
AKAUNTING_SETUP = "false";
|
||||
# Set to false in initial deployment
|
||||
APP_INSTALLED = "true";
|
||||
|
||||
# Don't change this unless you rename your database container or use rootless podman, in case of using rootless podman you should set it to 127.0.0.1 (NOT localhost)
|
||||
DB_HOST = "mysql";
|
||||
DB_PORT = "3306";
|
||||
|
||||
# Change these to match env/db.env
|
||||
DB_NAME = "akaunting";
|
||||
|
||||
# You should change this to a random string of three numbers or letters followed by an underscore
|
||||
DB_PREFIX = "aka_";
|
||||
|
||||
# These define the first company to exist on this instance. They are only used during setup.
|
||||
COMPANY_NAME = "MiOM Kreativraum e.V.";
|
||||
COMPANY_EMAIL = "contact@miom.space";
|
||||
};
|
||||
|
||||
environmentFiles = [
|
||||
config.momo-cloud.akaunting.envFile
|
||||
];
|
||||
|
||||
volumes = [
|
||||
"/var/lib/akaunting:/var/www/html"
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
systemd.tmpfiles.rules = [
|
||||
"d '${backupDir}' 0700 root root - -"
|
||||
];
|
||||
|
||||
momo-cloud.backups.restic.akaunting = {
|
||||
paths = [
|
||||
"/var/lib/akaunting"
|
||||
backupDir
|
||||
];
|
||||
timerConfig = {
|
||||
OnCalendar = "*-*-* 00:30:00 Etc/UTC";
|
||||
};
|
||||
initialize = true;
|
||||
backupPrepareCommand = ''
|
||||
${pkgs.docker-client}/bin/docker exec -t mysql sh -c 'mariadb-dump --databases akaunting --password=$MYSQL_PASSWORD --user akaunting' > "${backupDir}/akaunting.sql"
|
||||
'';
|
||||
backupCleanupCommand = ''
|
||||
rm -rf ${backupDir}/*
|
||||
'';
|
||||
pruneOpts = [
|
||||
"--keep-daily 7"
|
||||
"--keep-weekly 4"
|
||||
"--keep-monthly 3"
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
54
modules/autofetch-hostingde-invoices/default.nix
Normal file
54
modules/autofetch-hostingde-invoices/default.nix
Normal file
|
@ -0,0 +1,54 @@
|
|||
{
|
||||
flake,
|
||||
lib,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
{
|
||||
options.momo-cloud.autofetch-hostingde-invoices = with lib; {
|
||||
enable = mkEnableOption "Enable paperless hostingde invoice autofetching";
|
||||
hostingdeApiKeyFile = mkOption {
|
||||
type = types.str;
|
||||
default = "";
|
||||
};
|
||||
stateDir = mkOption {
|
||||
type = types.str;
|
||||
default = "/var/lib/autofetch-hostingde-invoices/state";
|
||||
};
|
||||
outputDir = mkOption {
|
||||
type = types.str;
|
||||
default = "/var/lib/autofetch-hostingde-invoices/out";
|
||||
};
|
||||
user = mkOption {
|
||||
type = types.str;
|
||||
default = "paperless";
|
||||
};
|
||||
group = mkOption {
|
||||
type = types.str;
|
||||
default = "users";
|
||||
};
|
||||
};
|
||||
|
||||
config =
|
||||
let
|
||||
cfg = config.momo-cloud.autofetch-hostingde-invoices;
|
||||
in
|
||||
lib.mkIf cfg.enable {
|
||||
services.cron = {
|
||||
enable = true;
|
||||
systemCronJobs = [
|
||||
"30 1 * * * ${cfg.user} ${pkgs.autofetch-hostingde-invoices}/bin/autofetch-hostingde-invoices '${cfg.hostingdeApiKeyFile}' '${cfg.outputDir}' ${cfg.stateDir}/ids"
|
||||
];
|
||||
};
|
||||
systemd.tmpfiles.rules = [
|
||||
"d ${cfg.stateDir} 0700 ${cfg.user} ${cfg.group} - -"
|
||||
"d ${cfg.outputDir} 0700 ${cfg.user}${cfg.group} - -"
|
||||
];
|
||||
|
||||
momo-cloud.backups.restic.autofetch-hostingde-invoices = {
|
||||
paths = [ cfg.stateDir ];
|
||||
initialize = true;
|
||||
};
|
||||
};
|
||||
}
|
292
modules/backups/default.nix
Normal file
292
modules/backups/default.nix
Normal file
|
@ -0,0 +1,292 @@
|
|||
{
|
||||
flake,
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
utils = import "${flake.inputs.nixpkgs}/nixos/lib/utils.nix" {
|
||||
inherit lib;
|
||||
inherit config;
|
||||
inherit pkgs;
|
||||
};
|
||||
# Type for a valid systemd unit option. Needed for correctly passing "timerConfig" to "systemd.timers"
|
||||
inherit (utils.systemdUtils.unitOptions) unitOption;
|
||||
inherit (lib)
|
||||
literalExpression
|
||||
mkOption
|
||||
mkPackageOption
|
||||
types
|
||||
;
|
||||
in
|
||||
{
|
||||
options.momo-cloud.backups = {
|
||||
repos = mkOption {
|
||||
description = ''
|
||||
Configuration of Restic repositories.
|
||||
'';
|
||||
type = types.attrsOf (
|
||||
types.submodule (
|
||||
{ name, ... }:
|
||||
{
|
||||
options = {
|
||||
passwordFile = mkOption {
|
||||
type = types.str;
|
||||
description = ''
|
||||
Read the repository password from a file.
|
||||
'';
|
||||
example = "/etc/nixos/restic-password";
|
||||
};
|
||||
|
||||
environmentFile = mkOption {
|
||||
type = with types; nullOr str;
|
||||
default = null;
|
||||
description = ''
|
||||
Read repository secrets as environment variables from a file.
|
||||
'';
|
||||
example = "/etc/nixos/restic-env";
|
||||
};
|
||||
|
||||
repository = mkOption {
|
||||
type = with types; nullOr str;
|
||||
default = null;
|
||||
description = ''
|
||||
repository to backup to.
|
||||
'';
|
||||
example = "sftp:backup@192.168.1.100:/backups/${name}";
|
||||
};
|
||||
};
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
default = { };
|
||||
example = {
|
||||
remotebackup = {
|
||||
repository = "sftp:backup@host:/backups/home";
|
||||
passwordFile = "/etc/nixos/secrets/restic-password";
|
||||
environmentFile = "/etc/nixos/secrets/restic-env";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
restic = mkOption {
|
||||
description = ''
|
||||
Periodic backups to create with Restic.
|
||||
'';
|
||||
type = types.attrsOf (
|
||||
types.submodule (
|
||||
{ name, ... }:
|
||||
{
|
||||
options = {
|
||||
paths = mkOption {
|
||||
# This is nullable for legacy reasons only. We should consider making it a pure listOf
|
||||
# after some time has passed since this comment was added.
|
||||
type = types.nullOr (types.listOf types.str);
|
||||
default = [ ];
|
||||
description = ''
|
||||
Which paths to backup, in addition to ones specified via
|
||||
`dynamicFilesFrom`. If null or an empty array and
|
||||
`dynamicFilesFrom` is also null, no backup command will be run.
|
||||
This can be used to create a prune-only job.
|
||||
'';
|
||||
example = [
|
||||
"/var/lib/postgresql"
|
||||
"/home/user/backup"
|
||||
];
|
||||
};
|
||||
|
||||
exclude = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [ ];
|
||||
description = ''
|
||||
Patterns to exclude when backing up. See
|
||||
https://restic.readthedocs.io/en/latest/040_backup.html#excluding-files for
|
||||
details on syntax.
|
||||
'';
|
||||
example = [
|
||||
"/var/cache"
|
||||
"/home/*/.cache"
|
||||
".git"
|
||||
];
|
||||
};
|
||||
|
||||
timerConfig = mkOption {
|
||||
type = types.nullOr (types.attrsOf unitOption);
|
||||
default = {
|
||||
OnCalendar = "daily";
|
||||
Persistent = true;
|
||||
};
|
||||
description = ''
|
||||
When to run the backup. See {manpage}`systemd.timer(5)` for
|
||||
details. If null no timer is created and the backup will only
|
||||
run when explicitly started.
|
||||
'';
|
||||
example = {
|
||||
OnCalendar = "00:05";
|
||||
RandomizedDelaySec = "5h";
|
||||
Persistent = true;
|
||||
};
|
||||
};
|
||||
|
||||
user = mkOption {
|
||||
type = types.str;
|
||||
default = "root";
|
||||
description = ''
|
||||
As which user the backup should run.
|
||||
'';
|
||||
example = "postgresql";
|
||||
};
|
||||
|
||||
extraBackupArgs = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [ ];
|
||||
description = ''
|
||||
Extra arguments passed to restic backup.
|
||||
'';
|
||||
example = [ "--exclude-file=/etc/nixos/restic-ignore" ];
|
||||
};
|
||||
|
||||
extraOptions = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [ ];
|
||||
description = ''
|
||||
Extra extended options to be passed to the restic --option flag.
|
||||
'';
|
||||
example = [ "sftp.command='ssh backup@192.168.1.100 -i /home/user/.ssh/id_rsa -s sftp'" ];
|
||||
};
|
||||
|
||||
initialize = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
Create the repository if it doesn't exist.
|
||||
'';
|
||||
};
|
||||
|
||||
pruneOpts = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [ ];
|
||||
description = ''
|
||||
A list of options (--keep-\* et al.) for 'restic forget
|
||||
--prune', to automatically prune old snapshots. The
|
||||
'forget' command is run *after* the 'backup' command, so
|
||||
keep that in mind when constructing the --keep-\* options.
|
||||
'';
|
||||
example = [
|
||||
"--keep-daily 7"
|
||||
"--keep-weekly 5"
|
||||
"--keep-monthly 12"
|
||||
"--keep-yearly 75"
|
||||
];
|
||||
};
|
||||
|
||||
runCheck = mkOption {
|
||||
type = types.bool;
|
||||
default = (builtins.length config.momo-cloud.backups.restic.${name}.checkOpts > 0);
|
||||
defaultText = literalExpression ''builtins.length config.services.backups.${name}.checkOpts > 0'';
|
||||
description = "Whether to run the `check` command with the provided `checkOpts` options.";
|
||||
example = true;
|
||||
};
|
||||
|
||||
checkOpts = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [ ];
|
||||
description = ''
|
||||
A list of options for 'restic check'.
|
||||
'';
|
||||
example = [ "--with-cache" ];
|
||||
};
|
||||
|
||||
dynamicFilesFrom = mkOption {
|
||||
type = with types; nullOr str;
|
||||
default = null;
|
||||
description = ''
|
||||
A script that produces a list of files to back up. The
|
||||
results of this command are given to the '--files-from'
|
||||
option. The result is merged with paths specified via `paths`.
|
||||
'';
|
||||
example = "find /home/matt/git -type d -name .git";
|
||||
};
|
||||
|
||||
backupPrepareCommand = mkOption {
|
||||
type = with types; nullOr str;
|
||||
default = null;
|
||||
description = ''
|
||||
A script that must run before starting the backup process.
|
||||
'';
|
||||
};
|
||||
|
||||
backupCleanupCommand = mkOption {
|
||||
type = with types; nullOr str;
|
||||
default = null;
|
||||
description = ''
|
||||
A script that must run after finishing the backup process.
|
||||
'';
|
||||
};
|
||||
|
||||
package = mkPackageOption pkgs "restic" { };
|
||||
|
||||
createWrapper = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = true;
|
||||
description = ''
|
||||
Whether to generate and add a script to the system path, that has the same environment variables set
|
||||
as the systemd service. This can be used to e.g. mount snapshots or perform other opterations, without
|
||||
having to manually specify most options.
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
)
|
||||
);
|
||||
default = { };
|
||||
example = {
|
||||
localbackup = {
|
||||
paths = [ "/home" ];
|
||||
exclude = [ "/home/*/.cache" ];
|
||||
initialize = true;
|
||||
};
|
||||
remotebackup = {
|
||||
paths = [ "/home" ];
|
||||
extraOptions = [
|
||||
"sftp.command='ssh backup@host -i /etc/nixos/secrets/backup-private-key -s sftp'"
|
||||
];
|
||||
timerConfig = {
|
||||
OnCalendar = "00:05";
|
||||
RandomizedDelaySec = "5h";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
services.restic.backups =
|
||||
let
|
||||
repos = config.momo-cloud.backups.repos;
|
||||
restic = config.momo-cloud.backups.restic;
|
||||
|
||||
repoNames = builtins.attrNames repos;
|
||||
backupNames = builtins.attrNames restic;
|
||||
|
||||
createBackups =
|
||||
backupName:
|
||||
map (repoName: {
|
||||
name = "${backupName}-${repoName}";
|
||||
value = repos."${repoName}" // restic."${backupName}";
|
||||
}) repoNames;
|
||||
|
||||
in
|
||||
builtins.listToAttrs (lib.lists.flatten (map createBackups backupNames));
|
||||
|
||||
# Used for momo-cloud.backups.repos.storagebox
|
||||
programs.ssh.knownHosts = {
|
||||
"u377325.your-storagebox.de".publicKey =
|
||||
"ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA5EB5p/5Hp3hGW1oHok+PIOH9Pbn7cnUiGmUEBrCVjnAw+HrKyN8bYVV0dIGllswYXwkG/+bgiBlE6IVIBAq+JwVWu1Sss3KarHY3OvFJUXZoZyRRg/Gc/+LRCE7lyKpwWQ70dbelGRyyJFH36eNv6ySXoUYtGkwlU5IVaHPApOxe4LHPZa/qhSRbPo2hwoh0orCtgejRebNtW5nlx00DNFgsvn8Svz2cIYLxsPVzKgUxs8Zxsxgn+Q/UvR7uq4AbAhyBMLxv7DjJ1pc7PJocuTno2Rw9uMZi1gkjbnmiOh6TTXIEWbnroyIhwc8555uto9melEUmWNQ+C+PwAK+MPw==";
|
||||
"[u377325.your-storagebox.de]:23".publicKey =
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIICf9svRenC/PLKIL9nk6K/pxQgoiFC41wTNvoIncOxs";
|
||||
};
|
||||
};
|
||||
}
|
60
modules/core/default.nix
Normal file
60
modules/core/default.nix
Normal file
|
@ -0,0 +1,60 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
flake,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{
|
||||
imports = [
|
||||
./nix.nix
|
||||
./networking.nix
|
||||
./terminal-tooling.nix
|
||||
./users.nix
|
||||
./email-smtp.nix
|
||||
./systemd.nix
|
||||
];
|
||||
|
||||
options.momo-cloud =
|
||||
let
|
||||
inherit (lib) mkOption types;
|
||||
in
|
||||
{
|
||||
adminEmail = mkOption {
|
||||
description = "Email address to use for administrative stuff like ACME";
|
||||
type = types.str;
|
||||
default = "admins@momo.koeln";
|
||||
};
|
||||
|
||||
privacyPolicyUrl = mkOption {
|
||||
description = "URL of the privacy policy. Used to link there from applications";
|
||||
type = types.str;
|
||||
default = "https://momo.koeln/privacy";
|
||||
};
|
||||
|
||||
imprintUrl = mkOption {
|
||||
description = "URL of the imprint. Used to link there from applications";
|
||||
type = types.str;
|
||||
default = "https://momo.koeln/about";
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
environment = {
|
||||
# Just a couple of global packages to make our lives easier
|
||||
systemPackages = with pkgs; [
|
||||
git
|
||||
vim
|
||||
wget
|
||||
];
|
||||
};
|
||||
|
||||
# Select internationalization properties
|
||||
console = {
|
||||
font = "Lat2-Terminus16";
|
||||
keyMap = "us";
|
||||
};
|
||||
|
||||
time.timeZone = "Etc/UTC";
|
||||
};
|
||||
}
|
47
modules/core/email-smtp.nix
Normal file
47
modules/core/email-smtp.nix
Normal file
|
@ -0,0 +1,47 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
flake,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{
|
||||
options.momo-cloud.email-smtp =
|
||||
let
|
||||
inherit (lib) mkOption types;
|
||||
in
|
||||
{
|
||||
username = mkOption {
|
||||
description = "SMTP auth username";
|
||||
type = types.str;
|
||||
default = "admins@momo.koeln";
|
||||
};
|
||||
|
||||
passwordFile = mkOption {
|
||||
description = "SMTP auth password file";
|
||||
type = types.path;
|
||||
};
|
||||
|
||||
host = mkOption {
|
||||
description = "SMTP host";
|
||||
type = types.str;
|
||||
default = "mail.momo.koeln";
|
||||
};
|
||||
|
||||
port = mkOption {
|
||||
description = "SMTP port";
|
||||
type = types.str;
|
||||
default = "465";
|
||||
};
|
||||
|
||||
encryption = mkOption {
|
||||
description = "SMTP encryption type";
|
||||
type = types.enum [
|
||||
"ssl"
|
||||
"starttls"
|
||||
"none"
|
||||
];
|
||||
default = "ssl";
|
||||
};
|
||||
};
|
||||
}
|
68
modules/core/networking.nix
Normal file
68
modules/core/networking.nix
Normal file
|
@ -0,0 +1,68 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
{
|
||||
options.momo-cloud.networking =
|
||||
let
|
||||
inherit (lib) mkOption types;
|
||||
in
|
||||
{
|
||||
domain = mkOption {
|
||||
description = "domain on which all services should run.";
|
||||
type = types.str;
|
||||
default = "momo.koeln";
|
||||
};
|
||||
|
||||
defaultInterface = mkOption {
|
||||
description = "Network interface which should be used as the default internet-connected one";
|
||||
type = types.nullOr types.str;
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
|
||||
# Don't expose SSH via public interfaces
|
||||
networking.firewall.interfaces.wg-ssh.allowedTCPPorts = [ 22 ];
|
||||
|
||||
networking.domain = config.momo-cloud.networking.domain;
|
||||
|
||||
services.openssh = {
|
||||
enable = true;
|
||||
openFirewall = lib.mkDefault false;
|
||||
settings = {
|
||||
PermitRootLogin = "prohibit-password";
|
||||
PasswordAuthentication = false;
|
||||
# Add back openssh MACs that got removed from defaults
|
||||
# for backwards compatibility
|
||||
#
|
||||
# NixOS default openssh MACs have changed to use "encrypt-then-mac" only.
|
||||
# This breaks compatibilty with clients that do not offer these MACs. For
|
||||
# compatibility reasons, we add back the old defaults.
|
||||
# See: https://github.com/NixOS/nixpkgs/pull/231165
|
||||
#
|
||||
# https://blog.stribik.technology/2015/01/04/secure-secure-shell.html
|
||||
# https://infosec.mozilla.org/guidelines/openssh#modern-openssh-67
|
||||
Macs = [
|
||||
"hmac-sha2-512-etm@openssh.com"
|
||||
"hmac-sha2-256-etm@openssh.com"
|
||||
"umac-128-etm@openssh.com"
|
||||
"hmac-sha2-512"
|
||||
"hmac-sha2-256"
|
||||
"umac-128@openssh.com"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
services.resolved = {
|
||||
enable = true;
|
||||
extraConfig = ''
|
||||
DNS=193.110.81.0#dns0.eu 185.253.5.0#dns0.eu 2a0f:fc80::#dns0.eu 2a0f:fc81::#dns0.eu 9.9.9.9#dns.quad9.net 149.112.112.112#dns.quad9.net 2620:fe::fe#dns.quad9.net 2620:fe::9#dns.quad9.net
|
||||
FallbackDNS=5.1.66.255#dot.ffmuc.net 185.150.99.255#dot.ffmuc.net 2001:678:e68:f000::#dot.ffmuc.net 2001:678:ed0:f000::#dot.ffmuc.net
|
||||
Domains=~.
|
||||
DNSOverTLS=yes
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
64
modules/core/nix.nix
Normal file
64
modules/core/nix.nix
Normal file
|
@ -0,0 +1,64 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
flake,
|
||||
...
|
||||
}:
|
||||
{
|
||||
nixpkgs.config = lib.mkDefault { allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ ]; };
|
||||
|
||||
system.activationScripts.diff-closures = {
|
||||
text = ''
|
||||
if [[ -e /run/current-system ]]; then
|
||||
${config.nix.package}/bin/nix store diff-closures \
|
||||
/run/current-system "$systemConfig" \
|
||||
--extra-experimental-features nix-command
|
||||
fi
|
||||
'';
|
||||
supportsDryActivation = true;
|
||||
};
|
||||
|
||||
nix = {
|
||||
# Use default version alias for nix package
|
||||
package = pkgs.nix;
|
||||
gc.automatic = true;
|
||||
optimise.automatic = true;
|
||||
|
||||
registry = {
|
||||
nixpkgs.flake = config.momo-cloud.flake-dependency-inject.nixpkgs;
|
||||
unstable.flake = config.momo-cloud.flake-dependency-inject.nixpkgs-unstable;
|
||||
master.flake = config.momo-cloud.flake-dependency-inject.nixpkgs-master;
|
||||
system.flake = flake.self;
|
||||
};
|
||||
|
||||
settings = {
|
||||
# Improve nix store disk usage
|
||||
auto-optimise-store = true;
|
||||
# Prevents impurities in builds
|
||||
sandbox = true;
|
||||
# Give root and @wheel special privileges with nix
|
||||
trusted-users = [
|
||||
"root"
|
||||
"@wheel"
|
||||
];
|
||||
# Allow only group wheel to connect to the nix daemon
|
||||
allowed-users = [ "@wheel" ];
|
||||
};
|
||||
|
||||
# Generally useful nix option defaults
|
||||
extraOptions = lib.mkForce ''
|
||||
experimental-features = flakes nix-command
|
||||
min-free = 536870912
|
||||
keep-outputs = true
|
||||
keep-derivations = true
|
||||
fallback = true
|
||||
'';
|
||||
|
||||
nixPath = [
|
||||
"nixpkgs=${config.momo-cloud.flake-dependency-inject.nixpkgs}"
|
||||
"nixos-config=${../../lib/compat/nixos}"
|
||||
"home-manager=${config.momo-cloud.flake-dependency-inject.home-manager}"
|
||||
];
|
||||
};
|
||||
}
|
8
modules/core/systemd.nix
Normal file
8
modules/core/systemd.nix
Normal file
|
@ -0,0 +1,8 @@
|
|||
{ ... }:
|
||||
|
||||
{
|
||||
# drop logs older than given time
|
||||
services.journald.extraConfig = ''
|
||||
MaxRetentionSec=14day
|
||||
'';
|
||||
}
|
38
modules/core/terminal-tooling.nix
Normal file
38
modules/core/terminal-tooling.nix
Normal file
|
@ -0,0 +1,38 @@
|
|||
{
|
||||
flake,
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
{
|
||||
home-manager.users = (
|
||||
lib.attrsets.foldlAttrs (
|
||||
acc: name: value:
|
||||
acc
|
||||
// {
|
||||
${name} = {
|
||||
programs.git.enable = true;
|
||||
programs.starship.enable = true;
|
||||
programs.bash = {
|
||||
enable = true;
|
||||
historyControl = [
|
||||
"ignoredups"
|
||||
"ignorespace"
|
||||
];
|
||||
};
|
||||
programs.neovim = {
|
||||
enable = true;
|
||||
vimAlias = true;
|
||||
viAlias = true;
|
||||
defaultEditor = true;
|
||||
# configure = {
|
||||
# packages.myVimPackages = with pkgs.vimPlugins; {
|
||||
# start = [vim-nix vim-surrund rainbow];
|
||||
# };
|
||||
# };
|
||||
};
|
||||
};
|
||||
}
|
||||
) { } config.momo-cloud.authentication.users
|
||||
);
|
||||
}
|
116
modules/core/users.nix
Normal file
116
modules/core/users.nix
Normal file
|
@ -0,0 +1,116 @@
|
|||
{
|
||||
flake,
|
||||
pkgs,
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
{
|
||||
options.momo-cloud.authentication =
|
||||
let
|
||||
inherit (lib) mkOption types;
|
||||
in
|
||||
{
|
||||
users = mkOption {
|
||||
description = "Administrative users to add";
|
||||
|
||||
type = types.attrsOf (
|
||||
types.submodule {
|
||||
options = {
|
||||
sshPubKeys = mkOption {
|
||||
type = types.attrsOf types.str;
|
||||
default = { };
|
||||
};
|
||||
secretEncryptionKeys = mkOption {
|
||||
type = types.attrsOf types.str;
|
||||
default = { };
|
||||
};
|
||||
wireguardDevices = mkOption {
|
||||
type = types.listOf (
|
||||
types.submodule {
|
||||
options = {
|
||||
publicKey = mkOption { type = types.str; };
|
||||
allowedIPs = mkOption { type = types.listOf types.str; };
|
||||
};
|
||||
}
|
||||
);
|
||||
default = { };
|
||||
};
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
default = flake.self.logins.admins;
|
||||
};
|
||||
|
||||
root.initialHashedPassword = mkOption {
|
||||
description = "Hashed password of the root account";
|
||||
type = types.str;
|
||||
default = "$y$j9T$bIN6GjQkmPMllOcQsq52K0$q0Z5B5.KW/uxXK9fItB8H6HO79RYAcI/ZZdB0Djke32";
|
||||
};
|
||||
|
||||
robot.username = mkOption {
|
||||
description = "username for the robot user";
|
||||
type = types.str;
|
||||
default = "hakkonaut";
|
||||
};
|
||||
|
||||
robot.sshPubKeys = mkOption {
|
||||
description = "SSH Keys to use for the robot user";
|
||||
type = types.listOf types.str;
|
||||
default = flake.self.logins.robots.sshPubKeys;
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
users.users =
|
||||
(lib.attrsets.foldlAttrs (
|
||||
acc: name: value:
|
||||
acc
|
||||
// {
|
||||
${name} = {
|
||||
name = name;
|
||||
group = name;
|
||||
extraGroups = [
|
||||
"wheel"
|
||||
"docker"
|
||||
];
|
||||
isNormalUser = true;
|
||||
openssh.authorizedKeys.keys = lib.attrsets.attrValues value.sshPubKeys;
|
||||
};
|
||||
}
|
||||
) { } config.momo-cloud.authentication.users)
|
||||
// {
|
||||
root.initialHashedPassword = config.momo-cloud.authentication.root.initialHashedPassword;
|
||||
|
||||
${config.momo-cloud.authentication.robot.username} = {
|
||||
description = "CI and automation user";
|
||||
home = "/home/${config.momo-cloud.authentication.robot.username}";
|
||||
createHome = true;
|
||||
useDefaultShell = true;
|
||||
uid = 998;
|
||||
group = "${config.momo-cloud.authentication.robot.username}";
|
||||
isSystemUser = true;
|
||||
openssh.authorizedKeys.keys = config.momo-cloud.authentication.robot.sshPubKeys;
|
||||
};
|
||||
};
|
||||
|
||||
home-manager.users = (
|
||||
lib.attrsets.foldlAttrs (
|
||||
acc: name: value:
|
||||
acc // { ${name}.home.stateVersion = "24.11"; }
|
||||
) { } config.momo-cloud.authentication.users
|
||||
);
|
||||
|
||||
users.groups =
|
||||
(lib.attrsets.foldlAttrs (
|
||||
acc: name: value:
|
||||
acc // { "${name}" = { }; }
|
||||
) { } config.momo-cloud.authentication.users)
|
||||
// {
|
||||
${config.momo-cloud.authentication.robot.username} = { };
|
||||
};
|
||||
|
||||
security.sudo.wheelNeedsPassword = false;
|
||||
};
|
||||
}
|
139
modules/coturn/default.nix
Normal file
139
modules/coturn/default.nix
Normal file
|
@ -0,0 +1,139 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
cfg = config.momo-cloud.coturn;
|
||||
domain = "turn.${config.momo-cloud.networking.domain}";
|
||||
listeningPort = 3478;
|
||||
tlsListeningPort = 5349;
|
||||
altListeningPort = 3479;
|
||||
altTlsListeningPort = 5350;
|
||||
in
|
||||
{
|
||||
options.momo-cloud.coturn = with lib; {
|
||||
enable = mkEnableOption "enable coturn";
|
||||
staticAuthSecretFile = mkOption {
|
||||
description = "File that holds the static auth secret";
|
||||
type = types.str;
|
||||
};
|
||||
interface = mkOption {
|
||||
description = "Interface coturn should listen on";
|
||||
type = types.str;
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
services.coturn = {
|
||||
enable = true;
|
||||
no-cli = true;
|
||||
min-port = 49000;
|
||||
max-port = 50000;
|
||||
listening-port = listeningPort;
|
||||
tls-listening-port = tlsListeningPort;
|
||||
alt-listening-port = altListeningPort;
|
||||
alt-tls-listening-port = altTlsListeningPort;
|
||||
use-auth-secret = true;
|
||||
static-auth-secret-file = config.momo-cloud.coturn.staticAuthSecretFile;
|
||||
realm = domain;
|
||||
cert = "${config.security.acme.certs.${domain}.directory}/full.pem";
|
||||
pkey = "${config.security.acme.certs.${domain}.directory}/key.pem";
|
||||
relay-ips =
|
||||
let
|
||||
toIPs = setList: map (set: set.address) setList;
|
||||
in
|
||||
(toIPs config.networking.interfaces.${config.momo-cloud.coturn.interface}.ipv4.addresses)
|
||||
++ toIPs (config.networking.interfaces.${config.momo-cloud.coturn.interface}.ipv6.addresses);
|
||||
no-tcp-relay = true;
|
||||
extraConfig =
|
||||
let
|
||||
externalIPv4s = lib.strings.concatMapStringsSep "\n" (
|
||||
{ address, ... }: "external-ip=${address}"
|
||||
) config.networking.interfaces.${config.momo-cloud.coturn.interface}.ipv4.addresses;
|
||||
externalIPv6s = lib.strings.concatMapStringsSep "\n" (
|
||||
{ address, ... }: "external-ip=${address}"
|
||||
) config.networking.interfaces.${config.momo-cloud.coturn.interface}.ipv6.addresses;
|
||||
in
|
||||
''
|
||||
${externalIPv4s}
|
||||
${externalIPv6s}
|
||||
|
||||
cipher-list=\"HIGH\"
|
||||
|
||||
no-tlsv1
|
||||
no-tlsv1_1
|
||||
|
||||
no-rfc5780
|
||||
response-origin-only-with-rfc5780
|
||||
|
||||
prod
|
||||
|
||||
no-stun-backward-compatibility
|
||||
|
||||
# ban private IP ranges
|
||||
no-multicast-peers
|
||||
denied-peer-ip=0.0.0.0-0.255.255.255
|
||||
denied-peer-ip=10.0.0.0-10.255.255.255
|
||||
denied-peer-ip=100.64.0.0-100.127.255.255
|
||||
denied-peer-ip=127.0.0.0-127.255.255.255
|
||||
denied-peer-ip=169.254.0.0-169.254.255.255
|
||||
denied-peer-ip=172.16.0.0-172.31.255.255
|
||||
denied-peer-ip=192.0.0.0-192.0.0.255
|
||||
denied-peer-ip=192.0.2.0-192.0.2.255
|
||||
denied-peer-ip=192.88.99.0-192.88.99.255
|
||||
denied-peer-ip=192.168.0.0-192.168.255.255
|
||||
denied-peer-ip=198.18.0.0-198.19.255.255
|
||||
denied-peer-ip=198.51.100.0-198.51.100.255
|
||||
denied-peer-ip=203.0.113.0-203.0.113.255
|
||||
denied-peer-ip=240.0.0.0-255.255.255.255
|
||||
denied-peer-ip=::1
|
||||
denied-peer-ip=64:ff9b::-64:ff9b::ffff:ffff
|
||||
denied-peer-ip=::ffff:0.0.0.0-::ffff:255.255.255.255
|
||||
denied-peer-ip=100::-100::ffff:ffff:ffff:ffff
|
||||
denied-peer-ip=2001::-2001:1ff:ffff:ffff:ffff:ffff:ffff:ffff
|
||||
denied-peer-ip=2002::-2002:ffff:ffff:ffff:ffff:ffff:ffff:ffff
|
||||
denied-peer-ip=fc00::-fdff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
|
||||
denied-peer-ip=fe80::-febf:ffff:ffff:ffff:ffff:ffff:ffff:ffff
|
||||
'';
|
||||
};
|
||||
|
||||
networking.firewall = {
|
||||
allowedUDPPortRanges = with config.services.coturn; [
|
||||
{
|
||||
from = min-port;
|
||||
to = max-port;
|
||||
}
|
||||
];
|
||||
allowedUDPPorts = [
|
||||
listeningPort
|
||||
altListeningPort
|
||||
];
|
||||
allowedTCPPortRanges = [ ];
|
||||
allowedTCPPorts = [
|
||||
listeningPort
|
||||
tlsListeningPort
|
||||
altListeningPort
|
||||
altTlsListeningPort
|
||||
];
|
||||
};
|
||||
|
||||
# get a certificate
|
||||
services.nginx = {
|
||||
enable = true;
|
||||
virtualHosts = {
|
||||
"${domain}" = {
|
||||
forceSSL = true;
|
||||
enableACME = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
security.acme.certs.${config.services.coturn.realm} = {
|
||||
postRun = "systemctl restart coturn.service";
|
||||
group = "turnserver";
|
||||
};
|
||||
|
||||
users.users.nginx.extraGroups = [ "turnserver" ];
|
||||
};
|
||||
}
|
55
modules/default.nix
Normal file
55
modules/default.nix
Normal file
|
@ -0,0 +1,55 @@
|
|||
{
|
||||
self,
|
||||
inputs,
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
{
|
||||
flake.nixosModules =
|
||||
let
|
||||
names = builtins.filter (name: name != "default.nix") (builtins.attrNames (builtins.readDir ./.));
|
||||
allModulesList = builtins.map (name: ./. + "/${name}/default.nix") names;
|
||||
allModulesAttrSet = builtins.listToAttrs (
|
||||
map (name: {
|
||||
name = name;
|
||||
value = import "./${name}";
|
||||
}) names
|
||||
);
|
||||
in
|
||||
{
|
||||
momo-cloud.imports = [
|
||||
({
|
||||
# This makes the inputs from the momo-cloud flake available inside other nixosModules.
|
||||
# If we use `flake.inputs` directly in the reusable nixosModules, that attrset would be overwritten
|
||||
# by the inputs of the flake momo-cloud is being used in, instead of pointing at the inputs
|
||||
# of the momo-cloud flake itself.
|
||||
#
|
||||
# See also: https://jade.fyi/blog/flakes-arent-real#injecting-dependencies
|
||||
options.momo-cloud.flake-dependency-inject = lib.mkOption {
|
||||
default = {
|
||||
nixpkgs = inputs.nixpkgs;
|
||||
nixpkgs-unstable = inputs.nixpkgs-unstable;
|
||||
nixpkgs-master = inputs.nixpkgs-master;
|
||||
home-manager = inputs.home-manager;
|
||||
};
|
||||
};
|
||||
})
|
||||
|
||||
inputs.home-manager.nixosModules.home-manager
|
||||
({
|
||||
home-manager.useGlobalPkgs = true;
|
||||
home-manager.useUserPackages = true;
|
||||
home-manager.extraSpecialArgs = {
|
||||
flake = {
|
||||
inherit self inputs config;
|
||||
};
|
||||
};
|
||||
})
|
||||
|
||||
self.nixosModules.overlays
|
||||
inputs.simple-nixos-mailserver.nixosModule
|
||||
] ++ allModulesList;
|
||||
}
|
||||
// allModulesAttrSet;
|
||||
}
|
24
modules/docker/default.nix
Normal file
24
modules/docker/default.nix
Normal file
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
pkgs,
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
{
|
||||
options.momo-cloud.docker = with lib; {
|
||||
enable = mkEnableOption "Enable docker daemon with default settings";
|
||||
};
|
||||
|
||||
config = lib.mkIf config.momo-cloud.docker.enable {
|
||||
virtualisation.docker.enable = true;
|
||||
|
||||
networking.firewall.trustedInterfaces = [ "docker0" ];
|
||||
|
||||
users.users = (
|
||||
lib.attrsets.foldlAttrs (
|
||||
acc: name: value:
|
||||
acc // { ${name}.extraGroups = [ "wheel" ]; }
|
||||
) { } config.momo-cloud.authentication.users
|
||||
);
|
||||
};
|
||||
}
|
68
modules/http-server/default.nix
Normal file
68
modules/http-server/default.nix
Normal file
|
@ -0,0 +1,68 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
self,
|
||||
...
|
||||
}:
|
||||
{
|
||||
options.momo-cloud.http-server =
|
||||
let
|
||||
inherit (lib) mkOption mkEnableOption types;
|
||||
in
|
||||
{
|
||||
enable = mkEnableOption ''
|
||||
Enable the momo cloud http server, currently nginx, with default config
|
||||
'';
|
||||
workerProcesses = mkOption {
|
||||
description = "Amount of worker processes";
|
||||
type = types.number;
|
||||
default = 4;
|
||||
};
|
||||
workerConnections = mkOption {
|
||||
description = "Amount of worker connections";
|
||||
type = types.number;
|
||||
default = 1024;
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf config.momo-cloud.http-server.enable {
|
||||
networking.firewall.allowedTCPPorts = [
|
||||
80
|
||||
443
|
||||
];
|
||||
|
||||
services.nginx = {
|
||||
enable = true;
|
||||
enableReload = true;
|
||||
proxyCachePath.cache = {
|
||||
enable = true;
|
||||
};
|
||||
resolver.addresses = [
|
||||
"193.110.81.0" # dns0.eu
|
||||
"185.253.5.0" # dns0.eu
|
||||
"[2a0f:fc80::]" # dns0.eu
|
||||
"[2a0f:fc81::]" # dns0.eu
|
||||
"9.9.9.9" # dns.quad9.net
|
||||
"149.112.112.112" # dns.quad9.net
|
||||
"[2620:fe::fe]" # dns.quad9.net
|
||||
"[2620:fe::9]" # dns.quad9.net
|
||||
];
|
||||
recommendedGzipSettings = true;
|
||||
recommendedOptimisation = true;
|
||||
recommendedProxySettings = true;
|
||||
recommendedTlsSettings = true;
|
||||
appendHttpConfig = ''
|
||||
# https://my.f5.com/manage/s/article/K51798430
|
||||
proxy_headers_hash_bucket_size 128;
|
||||
'';
|
||||
appendConfig = ''
|
||||
# Number of CPU cores
|
||||
worker_processes ${toString config.momo-cloud.http-server.workerProcesses};
|
||||
'';
|
||||
eventsConfig = ''
|
||||
worker_connections ${toString config.momo-cloud.http-server.workerConnections};
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
97
modules/invoiceplane/default.nix
Normal file
97
modules/invoiceplane/default.nix
Normal file
|
@ -0,0 +1,97 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
let
|
||||
backupDir = "/var/backups/invoiceplane";
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
./override.nix
|
||||
];
|
||||
|
||||
options.momo-cloud.invoiceplane = with lib; {
|
||||
enable = mkEnableOption "Enable invoiceplane instance";
|
||||
passwordFile = mkOption {
|
||||
type = types.nullOr types.path;
|
||||
default = null;
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf config.momo-cloud.invoiceplane.enable {
|
||||
momo-cloud.http-server.enable = true;
|
||||
momo-cloud.acme.enable = true;
|
||||
momo-cloud.postgresql.enable = true;
|
||||
|
||||
security.acme.certs = {
|
||||
"invoicing.${config.momo-cloud.networking.domain}" = { };
|
||||
};
|
||||
|
||||
services.nginx.virtualHosts = {
|
||||
"invoicing.${config.momo-cloud.networking.domain}" = {
|
||||
forceSSL = true;
|
||||
useACMEHost = "invoicing.${config.momo-cloud.networking.domain}";
|
||||
listenAddresses = [
|
||||
config.momo-cloud.wireguard.ipv4.address
|
||||
"[${config.momo-cloud.wireguard.ipv6.address}]"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
services.invoiceplane.webserver = "nginx";
|
||||
services.invoiceplane.sites."invoicing.${config.momo-cloud.networking.domain}" = {
|
||||
enable = true;
|
||||
|
||||
database = {
|
||||
user = "invoiceplane";
|
||||
name = "invoiceplane";
|
||||
host = "127.0.0.1";
|
||||
port = 3306;
|
||||
createLocally = true;
|
||||
passwordFile = config.momo-cloud.invoiceplane.passwordFile;
|
||||
};
|
||||
|
||||
invoiceTemplates = [ pkgs.invoiceplane-template ];
|
||||
|
||||
settings = {
|
||||
SETUP_COMPLETED = true;
|
||||
DISABLE_SETUP = true;
|
||||
IP_URL = "https://invoicing.${config.momo-cloud.networking.domain}";
|
||||
};
|
||||
|
||||
poolConfig = {
|
||||
"pm" = "dynamic";
|
||||
"pm.max_children" = 32;
|
||||
"pm.max_requests" = 500;
|
||||
"pm.max_spare_servers" = 4;
|
||||
"pm.min_spare_servers" = 2;
|
||||
"pm.start_servers" = 2;
|
||||
"php_admin_value[error_log]" =
|
||||
"/var/lib/invoiceplane/invoicing.${config.momo-cloud.networking.domain}/logs/php-error.log";
|
||||
"php_admin_flag[display_errors]" = "off";
|
||||
"php_admin_flag[log_errors]" = "on";
|
||||
"catch_workers_output" = "yes";
|
||||
};
|
||||
};
|
||||
|
||||
systemd.tmpfiles.rules = [
|
||||
"d '${backupDir}' 0700 root root - -"
|
||||
];
|
||||
|
||||
momo-cloud.backups.restic.invoiceplane = {
|
||||
paths = [
|
||||
backupDir
|
||||
"/var/lib/invoiceplane/invoicing.${config.momo-cloud.networking.domain}"
|
||||
];
|
||||
initialize = true;
|
||||
backupPrepareCommand = ''
|
||||
${pkgs.sudo}/bin/sudo -u invoiceplane ${config.services.mysql.package}/bin/mariadb-dump --databases invoiceplane > "${backupDir}/invoiceplane.sql"
|
||||
'';
|
||||
backupCleanupCommand = ''
|
||||
rm -rf ${backupDir}/*
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
481
modules/invoiceplane/override.nix
Normal file
481
modules/invoiceplane/override.nix
Normal file
|
@ -0,0 +1,481 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
inherit (lib)
|
||||
any
|
||||
attrValues
|
||||
boolToString
|
||||
concatMapStringsSep
|
||||
concatStrings
|
||||
concatStringsSep
|
||||
escapeShellArg
|
||||
flatten
|
||||
isBool
|
||||
isInt
|
||||
isList
|
||||
isString
|
||||
literalExpression
|
||||
mapAttrs'
|
||||
mapAttrsToList
|
||||
mkDefault
|
||||
mkEnableOption
|
||||
mkIf
|
||||
mkMerge
|
||||
mkOption
|
||||
nameValuePair
|
||||
optionalString
|
||||
types
|
||||
;
|
||||
|
||||
cfg = config.services.invoiceplane;
|
||||
eachSite = cfg.sites;
|
||||
user = "invoiceplane";
|
||||
webserver = config.services.${cfg.webserver};
|
||||
#backupDir = "/var/lib/invoiceplane/backup";
|
||||
|
||||
invoiceplane-config =
|
||||
hostName: cfg:
|
||||
pkgs.writeText "ipconfig.php" ''
|
||||
IP_URL=http://${hostName}
|
||||
ENABLE_DEBUG=false
|
||||
DISABLE_SETUP=false
|
||||
REMOVE_INDEXPHP=false
|
||||
DB_HOSTNAME=${cfg.database.host}
|
||||
DB_USERNAME=${cfg.database.user}
|
||||
# NOTE: file_get_contents adds newline at the end of returned string
|
||||
DB_PASSWORD=${
|
||||
optionalString (
|
||||
cfg.database.passwordFile != null
|
||||
) "trim(file_get_contents('${cfg.database.passwordFile}'), \"\\r\\n\")"
|
||||
}
|
||||
DB_DATABASE=${cfg.database.name}
|
||||
DB_PORT=${toString cfg.database.port}
|
||||
SESS_EXPIRATION=864000
|
||||
ENABLE_INVOICE_DELETION=false
|
||||
DISABLE_READ_ONLY=false
|
||||
ENCRYPTION_KEY=
|
||||
ENCRYPTION_CIPHER=AES-256
|
||||
SETUP_COMPLETED=false
|
||||
REMOVE_INDEXPHP=true
|
||||
'';
|
||||
|
||||
mkPhpValue =
|
||||
v:
|
||||
if isString v then
|
||||
escapeShellArg v
|
||||
# NOTE: If any value contains a , (comma) this will not get escaped
|
||||
else if isList v && any lib.strings.isCoercibleToString v then
|
||||
escapeShellArg (concatMapStringsSep "," toString v)
|
||||
else if isInt v then
|
||||
toString v
|
||||
else if isBool v then
|
||||
boolToString v
|
||||
else
|
||||
abort "The Invoiceplane config value ${lib.generators.toPretty { } v} can not be encoded.";
|
||||
|
||||
extraConfig =
|
||||
hostName: cfg:
|
||||
let
|
||||
settings = mapAttrsToList (k: v: "${k}=${mkPhpValue v}") cfg.settings;
|
||||
in
|
||||
pkgs.writeText "extraConfig.php" (concatStringsSep "\n" settings);
|
||||
|
||||
pkg =
|
||||
hostName: cfg:
|
||||
pkgs.stdenv.mkDerivation rec {
|
||||
pname = "invoiceplane-${hostName}";
|
||||
version = src.version;
|
||||
src = pkgs.invoiceplane;
|
||||
|
||||
postPatch = ''
|
||||
# Patch index.php file to load additional config file
|
||||
substituteInPlace index.php \
|
||||
--replace-fail "require('vendor/autoload.php');" "require('vendor/autoload.php'); \$dotenv = Dotenv\Dotenv::createImmutable(__DIR__, 'extraConfig.php'); \$dotenv->load();";
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
cp -r * $out/
|
||||
|
||||
# symlink uploads and log directories
|
||||
rm -r $out/uploads $out/application/logs $out/vendor/mpdf/mpdf/tmp
|
||||
ln -sf ${cfg.stateDir}/uploads $out/
|
||||
ln -sf ${cfg.stateDir}/logs $out/application/
|
||||
ln -sf ${cfg.stateDir}/tmp $out/vendor/mpdf/mpdf/
|
||||
|
||||
# symlink the InvoicePlane config
|
||||
ln -s ${cfg.stateDir}/ipconfig.php $out/ipconfig.php
|
||||
|
||||
# symlink the extraConfig file
|
||||
ln -s ${extraConfig hostName cfg} $out/extraConfig.php
|
||||
|
||||
# symlink additional templates
|
||||
${concatMapStringsSep "\n" (
|
||||
template: "cp -r ${template}/. $out/application/views/invoice_templates/pdf/"
|
||||
) cfg.invoiceTemplates}
|
||||
'';
|
||||
};
|
||||
|
||||
siteOpts =
|
||||
{ name, ... }:
|
||||
{
|
||||
options = {
|
||||
|
||||
enable = mkEnableOption "InvoicePlane web application";
|
||||
|
||||
stateDir = mkOption {
|
||||
type = types.path;
|
||||
default = "/var/lib/invoiceplane/${name}";
|
||||
description = ''
|
||||
This directory is used for uploads of attachments and cache.
|
||||
The directory passed here is automatically created and permissions
|
||||
adjusted as required.
|
||||
'';
|
||||
};
|
||||
|
||||
database = {
|
||||
host = mkOption {
|
||||
type = types.str;
|
||||
default = "localhost";
|
||||
description = "Database host address.";
|
||||
};
|
||||
|
||||
port = mkOption {
|
||||
type = types.port;
|
||||
default = 3306;
|
||||
description = "Database host port.";
|
||||
};
|
||||
|
||||
name = mkOption {
|
||||
type = types.str;
|
||||
default = "invoiceplane";
|
||||
description = "Database name.";
|
||||
};
|
||||
|
||||
user = mkOption {
|
||||
type = types.str;
|
||||
default = "invoiceplane";
|
||||
description = "Database user.";
|
||||
};
|
||||
|
||||
passwordFile = mkOption {
|
||||
type = types.nullOr types.path;
|
||||
default = null;
|
||||
example = "/run/keys/invoiceplane-dbpassword";
|
||||
description = ''
|
||||
A file containing the password corresponding to
|
||||
{option}`database.user`.
|
||||
'';
|
||||
};
|
||||
|
||||
createLocally = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = "Create the database and database user locally.";
|
||||
};
|
||||
};
|
||||
|
||||
invoiceTemplates = mkOption {
|
||||
type = types.listOf types.path;
|
||||
default = [ ];
|
||||
description = ''
|
||||
List of path(s) to respective template(s) which are copied from the 'invoice_templates/pdf' directory.
|
||||
|
||||
::: {.note}
|
||||
These templates need to be packaged before use, see example.
|
||||
:::
|
||||
'';
|
||||
example = literalExpression ''
|
||||
let
|
||||
# Let's package an example template
|
||||
template-vtdirektmarketing = pkgs.stdenv.mkDerivation {
|
||||
name = "vtdirektmarketing";
|
||||
# Download the template from a public repository
|
||||
src = pkgs.fetchgit {
|
||||
url = "https://git.project-insanity.org/onny/invoiceplane-vtdirektmarketing.git";
|
||||
sha256 = "1hh0q7wzsh8v8x03i82p6qrgbxr4v5fb05xylyrpp975l8axyg2z";
|
||||
};
|
||||
sourceRoot = ".";
|
||||
# Installing simply means copying template php file to the output directory
|
||||
installPhase = ""
|
||||
mkdir -p $out
|
||||
cp invoiceplane-vtdirektmarketing/vtdirektmarketing.php $out/
|
||||
"";
|
||||
};
|
||||
# And then pass this package to the template list like this:
|
||||
in [ template-vtdirektmarketing ]
|
||||
'';
|
||||
};
|
||||
|
||||
poolConfig = mkOption {
|
||||
type =
|
||||
with types;
|
||||
attrsOf (oneOf [
|
||||
str
|
||||
int
|
||||
bool
|
||||
]);
|
||||
default = {
|
||||
"pm" = "dynamic";
|
||||
"pm.max_children" = 32;
|
||||
"pm.start_servers" = 2;
|
||||
"pm.min_spare_servers" = 2;
|
||||
"pm.max_spare_servers" = 4;
|
||||
"pm.max_requests" = 500;
|
||||
};
|
||||
description = ''
|
||||
Options for the InvoicePlane PHP pool. See the documentation on `php-fpm.conf`
|
||||
for details on configuration directives.
|
||||
'';
|
||||
};
|
||||
|
||||
settings = mkOption {
|
||||
type = types.attrsOf types.anything;
|
||||
default = { };
|
||||
description = ''
|
||||
Structural InvoicePlane configuration. Refer to
|
||||
<https://github.com/InvoicePlane/InvoicePlane/blob/master/ipconfig.php.example>
|
||||
for details and supported values.
|
||||
'';
|
||||
example = literalExpression ''
|
||||
{
|
||||
SETUP_COMPLETED = true;
|
||||
DISABLE_SETUP = true;
|
||||
IP_URL = "https://invoice.example.com";
|
||||
}
|
||||
'';
|
||||
};
|
||||
|
||||
cron = {
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
Enable cron service which periodically runs Invoiceplane tasks.
|
||||
Requires key taken from the administration page. Refer to
|
||||
<https://wiki.invoiceplane.com/en/1.0/modules/recurring-invoices>
|
||||
on how to configure it.
|
||||
'';
|
||||
};
|
||||
key = mkOption {
|
||||
type = types.str;
|
||||
description = "Cron key taken from the administration page.";
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
in
|
||||
{
|
||||
disabledModules = [ "services/web-apps/invoiceplane.nix" ];
|
||||
|
||||
# interface
|
||||
options = {
|
||||
services.invoiceplane = mkOption {
|
||||
type = types.submodule {
|
||||
|
||||
options.sites = mkOption {
|
||||
type = types.attrsOf (types.submodule siteOpts);
|
||||
default = { };
|
||||
description = "Specification of one or more WordPress sites to serve";
|
||||
};
|
||||
|
||||
options.webserver = mkOption {
|
||||
type = types.enum [
|
||||
"caddy"
|
||||
"nginx"
|
||||
];
|
||||
default = "caddy";
|
||||
example = "nginx";
|
||||
description = ''
|
||||
Which webserver to use for virtual host management.
|
||||
'';
|
||||
};
|
||||
};
|
||||
default = { };
|
||||
description = "InvoicePlane configuration.";
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
# implementation
|
||||
config = mkIf (eachSite != { }) (mkMerge [
|
||||
{
|
||||
|
||||
assertions = flatten (
|
||||
mapAttrsToList (hostName: cfg: [
|
||||
{
|
||||
assertion = cfg.database.createLocally -> cfg.database.user == user;
|
||||
message = ''services.invoiceplane.sites."${hostName}".database.user must be ${user} if the database is to be automatically provisioned'';
|
||||
}
|
||||
{
|
||||
assertion = cfg.database.createLocally -> cfg.database.passwordFile == null;
|
||||
message = ''services.invoiceplane.sites."${hostName}".database.passwordFile cannot be specified if services.invoiceplane.sites."${hostName}".database.createLocally is set to true.'';
|
||||
}
|
||||
{
|
||||
assertion = cfg.cron.enable -> cfg.cron.key != null;
|
||||
message = ''services.invoiceplane.sites."${hostName}".cron.key must be set in order to use cron service.'';
|
||||
}
|
||||
]) eachSite
|
||||
);
|
||||
|
||||
services.mysql = mkIf (any (v: v.database.createLocally) (attrValues eachSite)) {
|
||||
enable = true;
|
||||
package = mkDefault pkgs.mariadb;
|
||||
ensureDatabases = mapAttrsToList (hostName: cfg: cfg.database.name) eachSite;
|
||||
ensureUsers = mapAttrsToList (hostName: cfg: {
|
||||
name = cfg.database.user;
|
||||
ensurePermissions = {
|
||||
"${cfg.database.name}.*" = "ALL PRIVILEGES";
|
||||
};
|
||||
}) eachSite;
|
||||
};
|
||||
|
||||
services.phpfpm = {
|
||||
phpPackage = pkgs.php81;
|
||||
pools = mapAttrs' (
|
||||
hostName: cfg:
|
||||
(nameValuePair "invoiceplane-${hostName}" {
|
||||
inherit user;
|
||||
group = webserver.group;
|
||||
settings = {
|
||||
"listen.owner" = webserver.user;
|
||||
"listen.group" = webserver.group;
|
||||
} // cfg.poolConfig;
|
||||
})
|
||||
) eachSite;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
systemd.tmpfiles.rules = flatten (
|
||||
mapAttrsToList (hostName: cfg: [
|
||||
"d ${cfg.stateDir} 0750 ${user} ${webserver.group} - -"
|
||||
"f ${cfg.stateDir}/ipconfig.php 0750 ${user} ${webserver.group} - -"
|
||||
"d ${cfg.stateDir}/logs 0750 ${user} ${webserver.group} - -"
|
||||
"d ${cfg.stateDir}/uploads 0750 ${user} ${webserver.group} - -"
|
||||
"d ${cfg.stateDir}/uploads/archive 0750 ${user} ${webserver.group} - -"
|
||||
"d ${cfg.stateDir}/uploads/customer_files 0750 ${user} ${webserver.group} - -"
|
||||
"d ${cfg.stateDir}/uploads/temp 0750 ${user} ${webserver.group} - -"
|
||||
"d ${cfg.stateDir}/uploads/temp/mpdf 0750 ${user} ${webserver.group} - -"
|
||||
"d ${cfg.stateDir}/tmp 0750 ${user} ${webserver.group} - -"
|
||||
]) eachSite
|
||||
);
|
||||
|
||||
systemd.services.invoiceplane-config = {
|
||||
serviceConfig.Type = "oneshot";
|
||||
script = concatStrings (
|
||||
mapAttrsToList (hostName: cfg: ''
|
||||
mkdir -p ${cfg.stateDir}/logs \
|
||||
${cfg.stateDir}/uploads
|
||||
if ! grep -q IP_URL "${cfg.stateDir}/ipconfig.php"; then
|
||||
cp "${invoiceplane-config hostName cfg}" "${cfg.stateDir}/ipconfig.php"
|
||||
fi
|
||||
'') eachSite
|
||||
);
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
};
|
||||
|
||||
users.users.${user} = {
|
||||
group = webserver.group;
|
||||
isSystemUser = true;
|
||||
};
|
||||
|
||||
}
|
||||
{
|
||||
|
||||
# Cron service implementation
|
||||
|
||||
systemd.timers = mapAttrs' (
|
||||
hostName: cfg:
|
||||
(nameValuePair "invoiceplane-cron-${hostName}" (
|
||||
mkIf cfg.cron.enable {
|
||||
wantedBy = [ "timers.target" ];
|
||||
timerConfig = {
|
||||
OnBootSec = "5m";
|
||||
OnUnitActiveSec = "5m";
|
||||
Unit = "invoiceplane-cron-${hostName}.service";
|
||||
};
|
||||
}
|
||||
))
|
||||
) eachSite;
|
||||
|
||||
systemd.services = mapAttrs' (
|
||||
hostName: cfg:
|
||||
(nameValuePair "invoiceplane-cron-${hostName}" (
|
||||
mkIf cfg.cron.enable {
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
User = user;
|
||||
ExecStart = "${pkgs.curl}/bin/curl --header 'Host: ${hostName}' http://localhost/invoices/cron/recur/${cfg.cron.key}";
|
||||
};
|
||||
}
|
||||
))
|
||||
) eachSite;
|
||||
|
||||
}
|
||||
|
||||
(mkIf (cfg.webserver == "caddy") {
|
||||
services.caddy = {
|
||||
enable = true;
|
||||
virtualHosts = mapAttrs' (
|
||||
hostName: cfg:
|
||||
(nameValuePair "http://${hostName}" {
|
||||
extraConfig = ''
|
||||
root * ${pkg hostName cfg}
|
||||
file_server
|
||||
php_fastcgi unix/${config.services.phpfpm.pools."invoiceplane-${hostName}".socket}
|
||||
'';
|
||||
})
|
||||
) eachSite;
|
||||
};
|
||||
})
|
||||
|
||||
(mkIf (cfg.webserver == "nginx") {
|
||||
services.nginx = {
|
||||
enable = true;
|
||||
virtualHosts = mapAttrs' (
|
||||
hostName: cfg:
|
||||
(nameValuePair hostName {
|
||||
root = pkg hostName cfg;
|
||||
extraConfig = ''
|
||||
index index.php index.html index.htm;
|
||||
|
||||
if (!-e $request_filename){
|
||||
rewrite ^(.*)$ /index.php break;
|
||||
}
|
||||
'';
|
||||
|
||||
locations = {
|
||||
"/setup".extraConfig =
|
||||
let
|
||||
scheme = if config.services.nginx.virtualHosts.${hostName}.forceSSL then "https" else "http";
|
||||
in
|
||||
''
|
||||
rewrite ^(.*)$ ${scheme}://${hostName}/ redirect;
|
||||
'';
|
||||
|
||||
"~ .php$" = {
|
||||
extraConfig = ''
|
||||
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
fastcgi_pass unix:${config.services.phpfpm.pools."invoiceplane-${hostName}".socket};
|
||||
include ${config.services.nginx.package}/conf/fastcgi_params;
|
||||
include ${config.services.nginx.package}/conf/fastcgi.conf;
|
||||
'';
|
||||
};
|
||||
};
|
||||
})
|
||||
) eachSite;
|
||||
};
|
||||
})
|
||||
]);
|
||||
}
|
130
modules/janus-gw/default.nix
Normal file
130
modules/janus-gw/default.nix
Normal file
|
@ -0,0 +1,130 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
cfg = config.momo-cloud.janus-gw;
|
||||
domain = "janus.${config.momo-cloud.networking.domain}";
|
||||
httpPort = "8088";
|
||||
wsPort = "8188";
|
||||
|
||||
janusCfg = pkgs.writeText "janus.jcfg" ''
|
||||
plugins: {
|
||||
disable = "libjanus_audiobridge.so,libjanus_echotest.so,libjanus_nosip.so,libjanus_recordplay.so,libjanus_sip.so,libjanus_textroom.so,libjanus_videocall.so"
|
||||
}
|
||||
loggers: {
|
||||
disable = "libjanus_jsonlog.so"
|
||||
}
|
||||
nat: {
|
||||
stun_server = "turn.${config.momo-cloud.networking.domain}"
|
||||
stun_port = "${toString config.services.coturn.listening-port}"
|
||||
full_trickle = true
|
||||
turn_rest_api_key = "##JANUSAPIKEY##"
|
||||
}
|
||||
'';
|
||||
|
||||
bootstrapConfig = pkgs.writeShellScript "bootstrap-janus" ''
|
||||
CFG=/etc/janus/janus.jcfg
|
||||
|
||||
cp -f ${janusCfg} ''${CFG}
|
||||
sed -ri "s/##JANUSAPIKEY##/$(cat ${cfg.apiKeyFile})/g" ''${CFG}
|
||||
|
||||
chown janus:janus ''${CFG}
|
||||
'';
|
||||
in
|
||||
{
|
||||
options.momo-cloud.janus-gw =
|
||||
let
|
||||
inherit (lib) mkOption mkEnableOption types;
|
||||
in
|
||||
{
|
||||
enable = mkEnableOption "enable janus-gw";
|
||||
apiKeyFile = mkOption {
|
||||
description = "File that holds the janus server api key";
|
||||
type = types.str;
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
services.nginx.virtualHosts."${domain}" = {
|
||||
forceSSL = true;
|
||||
enableACME = true;
|
||||
|
||||
locations = {
|
||||
"/" = {
|
||||
proxyPass = "http://127.0.0.1:${wsPort}/";
|
||||
proxyWebsockets = true;
|
||||
};
|
||||
"/janus" = {
|
||||
proxyPass = "http://127.0.0.1:${httpPort}/janus";
|
||||
proxyWebsockets = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
environment.etc = {
|
||||
"janus/janus.plugin.streaming.jcfg".text = ''
|
||||
general: {
|
||||
}
|
||||
|
||||
'';
|
||||
"janus/janus.plugin.videoroom.jcfg".text = ''
|
||||
general: {
|
||||
}
|
||||
'';
|
||||
"janus/janus.transport.http.jcfg".text = ''
|
||||
general: {
|
||||
base_path = "/janus"
|
||||
http = true
|
||||
port = ${httpPort}
|
||||
ip = "127.0.0.1"
|
||||
https = false
|
||||
acl = "127.,"
|
||||
acl_forwarded = true
|
||||
}
|
||||
|
||||
admin: {
|
||||
admin_base_path= "/admin"
|
||||
admin_http = true
|
||||
admin_port = 7088
|
||||
admin_https = false
|
||||
ip = "127.0.0.1"
|
||||
}
|
||||
'';
|
||||
|
||||
"janus/janus.transport.websockets.jcfg".text = ''
|
||||
general: {
|
||||
json = "indented" # Whether the JSON messages should be indented (default),
|
||||
# plain (no indentation) or compact (no indentation and no spaces)
|
||||
ws = true # Whether to enable the WebSockets API
|
||||
ws_port = ${wsPort} # WebSockets server port
|
||||
ws_ip = "127.0.0.1" # Whether we should bind this server to a specific IP address only
|
||||
wss = false # Whether to enable secure WebSockets
|
||||
}
|
||||
'';
|
||||
};
|
||||
|
||||
users.groups."janus" = { };
|
||||
users.users."janus" = {
|
||||
isSystemUser = true;
|
||||
group = "janus";
|
||||
};
|
||||
|
||||
systemd.services.janus = {
|
||||
after = [ "coturn.service" ];
|
||||
serviceConfig = {
|
||||
StateDirectory = "janus";
|
||||
LimitNOFILE = 65536;
|
||||
ExecStartPre = "!${bootstrapConfig}";
|
||||
ExecStart = "${pkgs.janus-gateway}/bin/janus -F /etc/janus";
|
||||
User = "janus";
|
||||
Group = "janus";
|
||||
Restart = "on-failure";
|
||||
};
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
};
|
||||
};
|
||||
}
|
91
modules/kanidm/default.nix
Normal file
91
modules/kanidm/default.nix
Normal file
|
@ -0,0 +1,91 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
pkgs,
|
||||
flake,
|
||||
...
|
||||
}:
|
||||
let
|
||||
domain = "account.${config.momo-cloud.networking.domain}";
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
./override.nix
|
||||
];
|
||||
|
||||
disabledModules = [
|
||||
"services/security/kanidm.nix"
|
||||
];
|
||||
|
||||
options.momo-cloud.authentication =
|
||||
let
|
||||
inherit (lib) mkOption mkEnableOption types;
|
||||
in
|
||||
{
|
||||
enable = mkEnableOption ''
|
||||
Whether to enable the kanidm identity management service
|
||||
'';
|
||||
adminPasswordFile = mkOption {
|
||||
description = "File that holds the initial admin user password";
|
||||
type = types.str;
|
||||
};
|
||||
idmAdminPasswordFile = mkOption {
|
||||
description = "File that holds the initial idm_admin user password";
|
||||
type = types.str;
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf config.momo-cloud.authentication.enable {
|
||||
momo-cloud.acme.enable = true;
|
||||
momo-cloud.http-server.enable = true;
|
||||
|
||||
security.acme.certs.${domain} = {
|
||||
reloadServices = [
|
||||
"nginx.service"
|
||||
"kanidm.service"
|
||||
];
|
||||
};
|
||||
|
||||
users.users.kanidm.extraGroups = [ "nginx" ];
|
||||
|
||||
services.nginx.virtualHosts = {
|
||||
${domain} = {
|
||||
forceSSL = true;
|
||||
useACMEHost = domain;
|
||||
locations."/".proxyPass = "https://${config.services.kanidm.serverSettings.bindaddress}";
|
||||
locations."/".extraConfig = ''
|
||||
proxy_ssl_name ${domain};
|
||||
proxy_ssl_server_name on;
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
services.kanidm = {
|
||||
enableServer = true;
|
||||
package = pkgs.kanidmWithSecretProvisioning_1_5;
|
||||
serverSettings = {
|
||||
origin = "https://${domain}";
|
||||
domain = domain;
|
||||
bindaddress = "127.0.0.1:8443";
|
||||
ldapbindaddress = "127.0.0.1:636";
|
||||
tls_chain = "${config.security.acme.certs.${domain}.directory}/fullchain.pem";
|
||||
tls_key = "${config.security.acme.certs.${domain}.directory}/key.pem";
|
||||
trust_x_forward_for = true;
|
||||
};
|
||||
provision = {
|
||||
enable = true;
|
||||
adminPasswordFile = config.momo-cloud.authentication.adminPasswordFile;
|
||||
idmAdminPasswordFile = config.momo-cloud.authentication.idmAdminPasswordFile;
|
||||
};
|
||||
};
|
||||
|
||||
# kanidm only allows running with HTTPS, and thus depends
|
||||
# on the certificates generated by ACME to be there before start
|
||||
systemd.services.kanidm.after = [ "acme-${domain}.service" ];
|
||||
|
||||
momo-cloud.backups.restic.kanidm = {
|
||||
paths = [ "/var/lib/kanidm" ];
|
||||
initialize = true;
|
||||
};
|
||||
};
|
||||
}
|
1014
modules/kanidm/override.nix
Normal file
1014
modules/kanidm/override.nix
Normal file
File diff suppressed because it is too large
Load diff
45
modules/mail-server/default.nix
Normal file
45
modules/mail-server/default.nix
Normal file
|
@ -0,0 +1,45 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{
|
||||
options.momo-cloud.mail-server =
|
||||
let
|
||||
inherit (lib) mkOption mkEnableOption types;
|
||||
in
|
||||
{
|
||||
enable = mkEnableOption ''
|
||||
Whether to enable the mail server
|
||||
'';
|
||||
};
|
||||
|
||||
config = lib.mkIf config.momo-cloud.mail-server.enable {
|
||||
momo-cloud.acme.enable = true;
|
||||
|
||||
mailserver = {
|
||||
enable = true;
|
||||
fqdn = "mail.${config.momo-cloud.networking.domain}";
|
||||
domains = [ config.momo-cloud.networking.domain ];
|
||||
# Use Let's Encrypt certificates. Note that this needs to set up a stripped
|
||||
# down nginx and opens port 80.
|
||||
certificateScheme = "acme-nginx";
|
||||
};
|
||||
|
||||
momo-cloud.backups.restic.mail-server = {
|
||||
paths = [
|
||||
"/var/vmail"
|
||||
"/var/dkim"
|
||||
];
|
||||
timerConfig = {
|
||||
OnCalendar = "*-*-* 02:00:00 Etc/UTC";
|
||||
};
|
||||
initialize = true;
|
||||
pruneOpts = [
|
||||
"--keep-daily 7"
|
||||
"--keep-weekly 4"
|
||||
"--keep-monthly 3"
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
32
modules/monitoring-client/alloy-config.nix
Normal file
32
modules/monitoring-client/alloy-config.nix
Normal file
|
@ -0,0 +1,32 @@
|
|||
{ config }:
|
||||
''
|
||||
discovery.relabel "journal" {
|
||||
targets = []
|
||||
|
||||
rule {
|
||||
source_labels = ["__journal__systemd_unit"]
|
||||
target_label = "unit"
|
||||
}
|
||||
}
|
||||
|
||||
loki.source.journal "journal" {
|
||||
max_age = "24h0m0s"
|
||||
relabel_rules = discovery.relabel.journal.rules
|
||||
forward_to = [loki.write.default.receiver]
|
||||
labels = {
|
||||
host = "${config.networking.hostName}.${config.momo-cloud.networking.domain}",
|
||||
job = "systemd-journal",
|
||||
}
|
||||
}
|
||||
|
||||
loki.write "default" {
|
||||
endpoint {
|
||||
url = "https://loki.${config.momo-cloud.networking.domain}/loki/api/v1/push"
|
||||
}
|
||||
basic_auth = {
|
||||
username = "loki"
|
||||
password_file = "${config.momo-cloud.monitoring-client.basicAuthPasswordFile}"
|
||||
}
|
||||
external_labels = {}
|
||||
}
|
||||
''
|
25
modules/monitoring-client/default.nix
Normal file
25
modules/monitoring-client/default.nix
Normal file
|
@ -0,0 +1,25 @@
|
|||
{ config, lib, ... }:
|
||||
|
||||
let
|
||||
cfg = config.momo-cloud.monitoring-client;
|
||||
in
|
||||
{
|
||||
options.momo-cloud.monitoring-client = {
|
||||
enable = lib.mkEnableOption "enable monitoring client";
|
||||
basicAuthPasswordFile = lib.mkOption {
|
||||
description = "Basic auth password file to connect to loki";
|
||||
type = lib.types.path;
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
environment.etc."alloy/config.alloy".text = (import ./alloy-config.nix) { inherit config; };
|
||||
services.alloy = {
|
||||
enable = true;
|
||||
};
|
||||
|
||||
systemd.services.alloy.reloadTriggers = [
|
||||
cfg.basicAuthPasswordFile
|
||||
];
|
||||
};
|
||||
}
|
14
modules/monitoring-server/default.nix
Normal file
14
modules/monitoring-server/default.nix
Normal file
|
@ -0,0 +1,14 @@
|
|||
{ lib, ... }:
|
||||
|
||||
{
|
||||
imports = [
|
||||
./grafana.nix
|
||||
./grafana-dashboards.nix
|
||||
./loki.nix
|
||||
./prometheus.nix
|
||||
];
|
||||
|
||||
options.momo-cloud.monitoring-server = {
|
||||
enable = lib.mkEnableOption "Enable monitoring server";
|
||||
};
|
||||
}
|
16
modules/monitoring-server/grafana-dashboards.nix
Normal file
16
modules/monitoring-server/grafana-dashboards.nix
Normal file
|
@ -0,0 +1,16 @@
|
|||
{ config, lib, ... }:
|
||||
|
||||
let
|
||||
cfg = config.momo-cloud.monitoring-server;
|
||||
in
|
||||
{
|
||||
config = lib.mkIf cfg.enable {
|
||||
environment.etc = {
|
||||
"grafana-dashboards/node-exporter-full_rev33.json" = {
|
||||
source = ./grafana-dashboards/node-exporter-full_rev33.json;
|
||||
group = "grafana";
|
||||
user = "grafana";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
File diff suppressed because it is too large
Load diff
148
modules/monitoring-server/grafana.nix
Normal file
148
modules/monitoring-server/grafana.nix
Normal file
|
@ -0,0 +1,148 @@
|
|||
{ config, lib, ... }:
|
||||
|
||||
let
|
||||
cfg = config.momo-cloud.monitoring-server;
|
||||
in
|
||||
{
|
||||
options.momo-cloud.monitoring-server.grafana =
|
||||
let
|
||||
inherit (lib) mkOption types;
|
||||
in
|
||||
{
|
||||
adminPasswordFile = mkOption { type = types.str; };
|
||||
oidcSecretFile = mkOption { type = types.str; };
|
||||
smtpHost = mkOption {
|
||||
type = types.str;
|
||||
default = "${config.momo-cloud.email-smtp.host}:${config.momo-cloud.email-smtp.port}";
|
||||
};
|
||||
smtpUser = mkOption {
|
||||
type = types.str;
|
||||
default = config.momo-cloud.email-smtp.username;
|
||||
};
|
||||
smtpPasswordFile = mkOption {
|
||||
type = types.str;
|
||||
default = config.momo-cloud.email-smtp.passwordFile;
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
momo-cloud.acme.enable = true;
|
||||
momo-cloud.proxy.enable = true;
|
||||
|
||||
services.nginx.virtualHosts."grafana.${config.momo-cloud.networking.domain}" = {
|
||||
enableACME = true;
|
||||
forceSSL = true;
|
||||
locations."/".proxyPass =
|
||||
"http://127.0.0.1:${toString config.services.grafana.settings.server.http_port}";
|
||||
};
|
||||
|
||||
services.grafana = {
|
||||
enable = true;
|
||||
settings = {
|
||||
server = {
|
||||
http_addr = "127.0.0.1";
|
||||
http_port = 3000;
|
||||
# Grafana needs to know on which domain and URL it's running
|
||||
domain = "grafana.${config.momo-cloud.networking.domain}";
|
||||
root_url = "https://grafana.${config.momo-cloud.networking.domain}";
|
||||
enable_gzip = true;
|
||||
};
|
||||
smtp = {
|
||||
enabled = true;
|
||||
host = cfg.grafana.smtpHost;
|
||||
user = cfg.grafana.smtpUser;
|
||||
password = "\$__file{${cfg.grafana.smtpPasswordFile}}";
|
||||
from_address = "grafana@${config.momo-cloud.networking.domain}";
|
||||
from_name = "grafana.${config.momo-cloud.networking.domain}";
|
||||
ehlo_identity = "grafana.${config.momo-cloud.networking.domain}";
|
||||
};
|
||||
security = {
|
||||
admin_email = config.momo-cloud.adminEmail;
|
||||
admin_password = "\$__file{${cfg.grafana.adminPasswordFile}}";
|
||||
};
|
||||
"auth.generic_oauth" = {
|
||||
enabled = true;
|
||||
name = "momo-cloud ID";
|
||||
allow_sign_up = true;
|
||||
client_id = "grafana";
|
||||
client_secret = "\$__file{${cfg.grafana.oidcSecretFile}}";
|
||||
scopes = "openid email profile offline_access roles groups";
|
||||
email_attribute_path = "email";
|
||||
login_attribute_path = "preferred_username";
|
||||
name_attribute_path = "full_name";
|
||||
auth_url = "https://account.${config.momo-cloud.networking.domain}/ui/oauth2";
|
||||
token_url = "https://account.${config.momo-cloud.networking.domain}/oauth2/token";
|
||||
api_url = "https://account.${config.momo-cloud.networking.domain}/oauth2/openid/grafana/userinfo";
|
||||
groups_attribute_path = "groups";
|
||||
role_attribute_path = "contains(grafana_role[*], 'GrafanaAdmin') && 'GrafanaAdmin' || contains(grafana_role[*], 'Viewer') && 'Viewer'";
|
||||
use_refresh_token = true;
|
||||
use_pkce = true;
|
||||
allow_assign_grafana_admin = true;
|
||||
};
|
||||
};
|
||||
provision = {
|
||||
enable = true;
|
||||
datasources = {
|
||||
settings = {
|
||||
datasources = [
|
||||
{
|
||||
name = "Prometheus";
|
||||
type = "prometheus";
|
||||
access = "proxy";
|
||||
url = "http://127.0.0.1:${toString config.services.prometheus.port}";
|
||||
isDefault = true;
|
||||
}
|
||||
{
|
||||
name = "Loki";
|
||||
type = "loki";
|
||||
access = "proxy";
|
||||
url = "http://127.0.0.1:${toString config.services.loki.configuration.server.http_listen_port}";
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
dashboards = {
|
||||
settings = {
|
||||
providers = [
|
||||
{
|
||||
name = "momo Dashboards";
|
||||
options.path = "/etc/grafana-dashboards";
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
services.kanidm.provision = {
|
||||
groups.grafana_users = {
|
||||
memberless = true;
|
||||
};
|
||||
groups.grafana_admins = {
|
||||
memberless = true;
|
||||
};
|
||||
|
||||
systems.oauth2."grafana" = {
|
||||
displayName = "grafana";
|
||||
originUrl = "https://grafana.${config.momo-cloud.networking.domain}/login/generic_oauth";
|
||||
basicSecretFile = cfg.grafana.oidcSecretFile;
|
||||
preferShortUsername = true;
|
||||
claimMaps.grafana_role = {
|
||||
valuesByGroup = {
|
||||
grafana_admins = [ "GrafanaAdmin" ];
|
||||
grafana_users = [ "Viewer" ];
|
||||
};
|
||||
};
|
||||
scopeMaps.grafana_users = [
|
||||
"email"
|
||||
"profile"
|
||||
"openid"
|
||||
"groups"
|
||||
"roles"
|
||||
"offline_access"
|
||||
];
|
||||
originLanding = "https://grafana.${config.momo-cloud.networking.domain}/login/generic_oauth";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
108
modules/monitoring-server/loki.nix
Normal file
108
modules/monitoring-server/loki.nix
Normal file
|
@ -0,0 +1,108 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.momo-cloud.monitoring-server;
|
||||
in
|
||||
{
|
||||
options.momo-cloud.monitoring-server.loki = {
|
||||
basicAuth = lib.mkOption {
|
||||
description = "Loki basic auth file contents for nginx";
|
||||
type = lib.types.str;
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
services.nginx.virtualHosts."loki.${config.momo-cloud.networking.domain}" = {
|
||||
enableACME = true;
|
||||
forceSSL = true;
|
||||
locations."/" = {
|
||||
proxyPass = "http://127.0.0.1:${toString config.services.loki.configuration.server.http_listen_port}";
|
||||
proxyWebsockets = true;
|
||||
basicAuthFile = pkgs.writeText "loki-basic-auth-file" cfg.loki.basicAuth;
|
||||
};
|
||||
};
|
||||
|
||||
# source: https://gist.github.com/rickhull/895b0cb38fdd537c1078a858cf15d63e
|
||||
# https://grafana.com/docs/loki/latest/configure/examples/#1-local-configuration-exampleyaml
|
||||
services.loki = {
|
||||
enable = true;
|
||||
configuration = {
|
||||
server = {
|
||||
http_listen_address = "127.0.0.1";
|
||||
http_listen_port = 3100;
|
||||
};
|
||||
auth_enabled = true;
|
||||
common = {
|
||||
ring = {
|
||||
instance_enable_ipv6 = true;
|
||||
kvstore = {
|
||||
store = "inmemory";
|
||||
};
|
||||
};
|
||||
replication_factor = 1;
|
||||
path_prefix = "/var/lib/loki";
|
||||
storage = {
|
||||
filesystem = {
|
||||
chunks_directory = "chunks/";
|
||||
rules_directory = "rules/";
|
||||
};
|
||||
};
|
||||
};
|
||||
ingester = {
|
||||
chunk_encoding = "snappy";
|
||||
chunk_idle_period = "1h";
|
||||
};
|
||||
query_range = {
|
||||
results_cache = {
|
||||
cache = {
|
||||
embedded_cache = {
|
||||
enabled = true;
|
||||
max_size_mb = 500;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
chunk_store_config = {
|
||||
chunk_cache_config = {
|
||||
embedded_cache = {
|
||||
enabled = true;
|
||||
max_size_mb = 500;
|
||||
ttl = "24h";
|
||||
};
|
||||
};
|
||||
};
|
||||
# Keep logs for 4 weeks
|
||||
# https://grafana.com/docs/loki/latest/operations/storage/retention/
|
||||
limits_config = {
|
||||
retention_period = "4w";
|
||||
split_queries_by_interval = "0";
|
||||
};
|
||||
compactor = {
|
||||
compaction_interval = "10m";
|
||||
delete_request_store = "filesystem";
|
||||
retention_enabled = true;
|
||||
retention_delete_delay = "2h";
|
||||
retention_delete_worker_count = 150;
|
||||
};
|
||||
schema_config = {
|
||||
configs = [
|
||||
{
|
||||
from = "2025-03-01";
|
||||
store = "tsdb";
|
||||
object_store = "filesystem";
|
||||
schema = "v13";
|
||||
index = {
|
||||
prefix = "index_";
|
||||
period = "24h";
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
25
modules/monitoring-server/prometheus.nix
Normal file
25
modules/monitoring-server/prometheus.nix
Normal file
|
@ -0,0 +1,25 @@
|
|||
{ config, lib, ... }:
|
||||
|
||||
let
|
||||
cfg = config.momo-cloud.monitoring-server;
|
||||
prometheusPort = 9001;
|
||||
in
|
||||
{
|
||||
config = lib.mkIf cfg.enable {
|
||||
services.prometheus = {
|
||||
enable = true;
|
||||
listenAddress = "127.0.0.1";
|
||||
port = prometheusPort;
|
||||
scrapeConfigs = [
|
||||
{
|
||||
job_name = "node_exporters";
|
||||
static_configs = [
|
||||
{
|
||||
targets = [ "127.0.0.1:9002" ];
|
||||
}
|
||||
];
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
37
modules/nextcloud-signaling/default.nix
Normal file
37
modules/nextcloud-signaling/default.nix
Normal file
|
@ -0,0 +1,37 @@
|
|||
{ config, lib, ... }:
|
||||
|
||||
{
|
||||
imports = [
|
||||
./signaling-server.nix
|
||||
];
|
||||
|
||||
options.momo-cloud.nextcloud-signaling = {
|
||||
enable = lib.mkEnableOption "enable nextcloud-signaling-server and required components";
|
||||
internalSecretFile = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
};
|
||||
hashKeyFile = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
};
|
||||
blockKeyFile = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
};
|
||||
janusApiKeyFile = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
};
|
||||
turnSecretFile = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
};
|
||||
nextcloudSecretFile = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf config.momo-cloud.nextcloud-signaling.enable {
|
||||
momo-cloud.coturn.enable = true;
|
||||
momo-cloud.janus-gw = {
|
||||
enable = true;
|
||||
apiKeyFile = config.momo-cloud.nextcloud-signaling.janusApiKeyFile;
|
||||
};
|
||||
};
|
||||
}
|
87
modules/nextcloud-signaling/signaling-server.nix
Normal file
87
modules/nextcloud-signaling/signaling-server.nix
Normal file
|
@ -0,0 +1,87 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
cfg = config.momo-cloud.nextcloud-signaling;
|
||||
|
||||
port = 8916;
|
||||
|
||||
serverConfig = lib.generators.toINI { } {
|
||||
app.trustedproxies = "127.0.0.1";
|
||||
|
||||
backend = {
|
||||
backendtype = "static";
|
||||
backends = "backend-nextcloud";
|
||||
};
|
||||
|
||||
backend-nextcloud = {
|
||||
secret = "##NEXTCLOUDSECRET##";
|
||||
url = "https://cloud.${config.momo-cloud.networking.domain}";
|
||||
};
|
||||
|
||||
clients.internalsecret = "##INTERNALSECRET##";
|
||||
|
||||
http.listen = "127.0.0.1:${toString port}";
|
||||
|
||||
mcu = {
|
||||
type = "janus";
|
||||
url = "wss://janus.${config.momo-cloud.networking.domain}";
|
||||
};
|
||||
nats.url = "nats://loopback";
|
||||
|
||||
sessions = {
|
||||
hashKey = "##HASHKEY##";
|
||||
blockKey = "##BLOCKKEY##";
|
||||
};
|
||||
|
||||
turn = {
|
||||
apikey = "##JANUSAPIKEY##";
|
||||
secret = "##TURNSECRET##";
|
||||
servers = "turn:turn.${config.momo-cloud.networking.domain}:${toString config.services.coturn.listening-port}?transport=udp,turn:turn.${config.momo-cloud.networking.domain}:${toString config.services.coturn.listening-port}?transport=tcp";
|
||||
};
|
||||
};
|
||||
|
||||
serverConfigFile = pkgs.writeText "nextcloud-signaling-server.cfg" serverConfig;
|
||||
|
||||
bootstrapConfig = pkgs.writeShellScript "bootstrap-signaling" ''
|
||||
CFG=/etc/nextcloud-signaling-server.cfg
|
||||
|
||||
cp -f ${serverConfigFile} ''${CFG}
|
||||
|
||||
sed -ri "s/##NEXTCLOUDSECRET##/$(cat ${cfg.nextcloudSecretFile})/g" /etc/nextcloud-signaling-server.cfg
|
||||
sed -ri "s/##INTERNALSECRET##/$(cat ${cfg.internalSecretFile})/g" /etc/nextcloud-signaling-server.cfg
|
||||
sed -ri "s/##HASHKEY##/$(cat ${cfg.hashKeyFile})/g" /etc/nextcloud-signaling-server.cfg
|
||||
sed -ri "s/##BLOCKKEY##/$(cat ${cfg.blockKeyFile})/g" /etc/nextcloud-signaling-server.cfg
|
||||
sed -ri "s/##JANUSAPIKEY##/$(cat ${cfg.janusApiKeyFile})/g" /etc/nextcloud-signaling-server.cfg
|
||||
sed -ri "s/##TURNSECRET##/$(cat ${cfg.turnSecretFile})/g" /etc/nextcloud-signaling-server.cfg
|
||||
'';
|
||||
in
|
||||
{
|
||||
config = lib.mkIf cfg.enable {
|
||||
services.nginx.virtualHosts."signaling.${config.momo-cloud.networking.domain}" = {
|
||||
forceSSL = true;
|
||||
enableACME = true;
|
||||
|
||||
locations = {
|
||||
"/" = {
|
||||
proxyPass = "http://127.0.0.1:${toString port}/";
|
||||
proxyWebsockets = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
systemd.services.nextcloud-spreed-signaling = {
|
||||
serviceConfig = {
|
||||
StateDirectory = "nextcloud-spreed-signaling";
|
||||
LimitNOFILE = 65536;
|
||||
ExecStartPre = "!${bootstrapConfig}";
|
||||
ExecStart = "${pkgs.nextcloud-spreed-signaling}/bin/server -config /etc/nextcloud-signaling-server.cfg";
|
||||
};
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
};
|
||||
};
|
||||
}
|
23
modules/nextcloud/backup.nix
Normal file
23
modules/nextcloud/backup.nix
Normal file
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{
|
||||
config = lib.mkIf config.momo-cloud.nextcloud.enable {
|
||||
momo-cloud.backups.restic.nextcloud = {
|
||||
paths = [
|
||||
"/var/lib/nextcloud/data"
|
||||
"/tmp/nextcloud-backup.sql"
|
||||
];
|
||||
backupPrepareCommand = ''
|
||||
${pkgs.sudo}/bin/sudo -u postgres ${pkgs.postgresql}/bin/pg_dump -d nextcloud > /tmp/nextcloud-backup.sql
|
||||
'';
|
||||
backupCleanupCommand = ''
|
||||
rm /tmp/nextcloud-backup.sql
|
||||
'';
|
||||
initialize = true;
|
||||
};
|
||||
};
|
||||
}
|
235
modules/nextcloud/default.nix
Normal file
235
modules/nextcloud/default.nix
Normal file
|
@ -0,0 +1,235 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
flake,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{
|
||||
imports = [
|
||||
./backup.nix
|
||||
./preview-generation.nix
|
||||
./talk.nix
|
||||
./federation.nix
|
||||
];
|
||||
|
||||
options.momo-cloud.nextcloud =
|
||||
let
|
||||
inherit (lib) mkOption mkEnableOption types;
|
||||
in
|
||||
{
|
||||
enable = mkEnableOption ''
|
||||
Whether to enable the kanidm identity management service
|
||||
'';
|
||||
adminPasswordFile = mkOption {
|
||||
description = "File that holds the initial admin user password";
|
||||
type = types.str;
|
||||
};
|
||||
secretsFile = mkOption {
|
||||
description = "File that holds the nextcloud secrets";
|
||||
type = types.str;
|
||||
};
|
||||
oidcSecretFile = mkOption {
|
||||
description = "File that holds the OIDC secret";
|
||||
type = types.str;
|
||||
};
|
||||
extraApps = mkOption {
|
||||
description = "Extra apps to be installed";
|
||||
type = types.attrsOf types.package;
|
||||
default = { };
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf config.momo-cloud.nextcloud.enable {
|
||||
momo-cloud.acme.enable = true;
|
||||
momo-cloud.http-server.enable = true;
|
||||
|
||||
services.nginx.virtualHosts."cloud.${config.momo-cloud.networking.domain}" = {
|
||||
enableACME = true;
|
||||
forceSSL = true;
|
||||
};
|
||||
|
||||
services.nextcloud = {
|
||||
hostName = "cloud.${config.momo-cloud.networking.domain}";
|
||||
home = "/var/lib/nextcloud";
|
||||
|
||||
enable = true;
|
||||
# When updating package, remember to update nextcloud30Packages in
|
||||
# services.nextcloud.extraApps
|
||||
package = pkgs.nextcloud30;
|
||||
https = true;
|
||||
secretFile = config.momo-cloud.nextcloud.secretsFile;
|
||||
maxUploadSize = "1G";
|
||||
|
||||
configureRedis = true;
|
||||
|
||||
config = {
|
||||
adminuser = "admin";
|
||||
adminpassFile = config.momo-cloud.nextcloud.adminPasswordFile;
|
||||
dbuser = "nextcloud";
|
||||
dbtype = "pgsql";
|
||||
dbname = "nextcloud";
|
||||
};
|
||||
|
||||
settings = {
|
||||
overwrite.cli.url = "https://cloud.${config.momo-cloud.networking.domain}";
|
||||
overwriteprotocol = "https";
|
||||
|
||||
# installed = true;
|
||||
default_phone_region = "+49";
|
||||
mail_sendmailmode = "smtp";
|
||||
mail_from_address = "nextcloud@${config.momo-cloud.networking.domain}";
|
||||
mail_smtpmode = "smtp";
|
||||
mail_smtpauthtype = "PLAIN";
|
||||
mail_domain = config.momo-cloud.networking.domain;
|
||||
mail_smtpname = config.momo-cloud.email-smtp.username;
|
||||
mail_smtpsecure = config.momo-cloud.email-smtp.encryption;
|
||||
mail_smtpauth = true;
|
||||
mail_smtphost = config.momo-cloud.email-smtp.host;
|
||||
mail_smtpport = config.momo-cloud.email-smtp.port;
|
||||
|
||||
# This is to allow connections to collabora and kanidm, among other services
|
||||
# running on the same host
|
||||
#
|
||||
# https://docs.nextcloud.com/server/stable/admin_manual/configuration_server/config_sample_php_parameters.html?highlight=allow_local_remote_servers%20true
|
||||
# https://github.com/ONLYOFFICE/onlyoffice-nextcloud/issues/293
|
||||
allow_local_remote_servers = true;
|
||||
|
||||
auth.bruteforce.protection.enabled = true;
|
||||
trashbin_retention_obligation = "auto,7";
|
||||
defaultapp = "file";
|
||||
activity_expire_days = "14";
|
||||
integrity.check.disabled = false;
|
||||
updater.release.channel = "stable";
|
||||
loglevel = 2;
|
||||
debug = false;
|
||||
maintenance_window_start = "1";
|
||||
# maintenance = false;
|
||||
# app_install_overwrite = [
|
||||
# "pdfdraw"
|
||||
# "integration_whiteboard"
|
||||
# ];
|
||||
htaccess.RewriteBase = "/";
|
||||
theme = "";
|
||||
simpleSignUpLink.shown = false;
|
||||
|
||||
user_oidc.use_pkce = true;
|
||||
allow_user_to_change_display_name = false;
|
||||
lost_password_link = "disabled";
|
||||
|
||||
notify_push = {
|
||||
enable = true;
|
||||
bendDomainToLocalhost = true;
|
||||
};
|
||||
};
|
||||
|
||||
phpOptions = {
|
||||
"opcache.interned_strings_buffer" = "32";
|
||||
"opcache.max_accelerated_files" = "16229";
|
||||
"opcache.memory_consumption" = "256";
|
||||
# https://docs.nextcloud.com/server/latest/admin_manual/installation/server_tuning.html#enable-php-opcache
|
||||
"opcache.revalidate_freq" = "60";
|
||||
# https://docs.nextcloud.com/server/latest/admin_manual/installation/server_tuning.html#:~:text=opcache.jit%20%3D%201255%20opcache.jit_buffer_size%20%3D%20128m
|
||||
"opcache.jit" = "1255";
|
||||
"opcache.jit_buffer_size" = "128M";
|
||||
};
|
||||
|
||||
# Calculated with 4GiB RAM, 80MiB process size available on
|
||||
# https://spot13.com/pmcalculator/
|
||||
poolSettings = {
|
||||
pm = "dynamic";
|
||||
"pm.max_children" = "52";
|
||||
"pm.max_requests" = "500";
|
||||
"pm.max_spare_servers" = "39";
|
||||
"pm.min_spare_servers" = "13";
|
||||
"pm.start_servers" = "13";
|
||||
};
|
||||
|
||||
caching.redis = true;
|
||||
# Don't allow the installation and updating of apps from the Nextcloud appstore,
|
||||
# because we declaratively install them
|
||||
appstoreEnable = false;
|
||||
autoUpdateApps.enable = false;
|
||||
extraApps = {
|
||||
inherit (pkgs.nextcloud30Packages.apps)
|
||||
calendar
|
||||
contacts
|
||||
groupfolders
|
||||
user_oidc
|
||||
quota_warning
|
||||
notify_push
|
||||
;
|
||||
} // config.momo-cloud.nextcloud.extraApps;
|
||||
|
||||
database.createLocally = true;
|
||||
};
|
||||
|
||||
systemd.services."nextcloud-oidc-provisioning" =
|
||||
let
|
||||
occ = "/run/current-system/sw/bin/nextcloud-occ";
|
||||
in
|
||||
{
|
||||
serviceConfig.Type = "oneshot";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
|
||||
after = [ "nextcloud-setup.service" ];
|
||||
script =
|
||||
let
|
||||
adminGroupName = "nextcloud_admins@account.${config.momo-cloud.networking.domain}";
|
||||
in
|
||||
''
|
||||
CLIENT_SECRET=$(cat "${config.momo-cloud.nextcloud.oidcSecretFile}")
|
||||
|
||||
${occ} user_oidc:provider "kanidm" || \
|
||||
${occ} user_oidc:provider --clientid nextcloud \
|
||||
--clientsecret "''${CLIENT_SECRET}" \
|
||||
--discoveryuri=https://account.${config.momo-cloud.networking.domain}/oauth2/openid/nextcloud/.well-known/openid-configuration \
|
||||
--scope="openid email profile groups" \
|
||||
--mapping-uid="preferred_username" \
|
||||
--mapping-groups="groups" \
|
||||
--group-provisioning=1 \
|
||||
--unique-uid=0 \
|
||||
kanidm
|
||||
|
||||
[ "''$(${occ} config:app:get user_oidc allow_multiple_user_backends)" == "0" ] || \
|
||||
${occ} config:app:set --value=0 user_oidc allow_multiple_user_backends
|
||||
|
||||
${occ} group:info ${adminGroupName} || \
|
||||
${occ} group:add ${adminGroupName}
|
||||
|
||||
[ "''$(${occ} admin-delegation:show | grep -F 'OCA\GroupFolders\Settings\Admin' | grep -c '${adminGroupName}')" != "0" ] || \
|
||||
${occ} admin-delegation:add 'OCA\GroupFolders\Settings\Admin' ${adminGroupName}
|
||||
|
||||
[ "''$(${occ} admin-delegation:show | grep -F 'OCA\Settings\Settings\Admin\Users' | grep -c '${adminGroupName}')" != "0" ] || \
|
||||
${occ} admin-delegation:add 'OCA\Settings\Settings\Admin\Users' ${adminGroupName}
|
||||
|
||||
[ "''$(${occ} admin-delegation:show | grep -F 'OCA\Settings\Settings\Admin\Sharing' | grep -c '${adminGroupName}')" != "0" ] || \
|
||||
${occ} admin-delegation:add 'OCA\Settings\Settings\Admin\Sharing' ${adminGroupName}
|
||||
'';
|
||||
};
|
||||
|
||||
services.kanidm.provision = {
|
||||
groups.nextcloud_users = {
|
||||
memberless = true;
|
||||
};
|
||||
|
||||
groups.nextcloud_admins = {
|
||||
memberless = true;
|
||||
};
|
||||
|
||||
systems.oauth2."nextcloud" = {
|
||||
displayName = "nextcloud";
|
||||
originUrl = "https://cloud.${config.momo-cloud.networking.domain}/apps/user_oidc/code";
|
||||
basicSecretFile = config.momo-cloud.nextcloud.oidcSecretFile;
|
||||
preferShortUsername = true;
|
||||
scopeMaps.nextcloud_users = [
|
||||
"email"
|
||||
"profile"
|
||||
"openid"
|
||||
"groups"
|
||||
];
|
||||
originLanding = "https://cloud.${config.momo-cloud.networking.domain}/";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
37
modules/nextcloud/federation.nix
Normal file
37
modules/nextcloud/federation.nix
Normal file
|
@ -0,0 +1,37 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{
|
||||
options.momo-cloud.nextcloud.federation =
|
||||
let
|
||||
inherit (lib) mkOption types;
|
||||
in
|
||||
{
|
||||
enable = mkOption {
|
||||
description = ''
|
||||
Whether to enable the nextcloud federation module
|
||||
'';
|
||||
type = types.bool;
|
||||
default = config.momo-cloud.nextcloud.enable;
|
||||
};
|
||||
};
|
||||
config = lib.mkIf config.momo-cloud.nextcloud.federation.enable {
|
||||
systemd.services."nextcloud-federation-provisioning" =
|
||||
let
|
||||
occ = "/run/current-system/sw/bin/nextcloud-occ";
|
||||
in
|
||||
{
|
||||
serviceConfig.Type = "oneshot";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
|
||||
after = [ "nextcloud-setup.service" ];
|
||||
script = ''
|
||||
${occ} app:enable federation
|
||||
${occ} app:enable federatedfilesharing
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
116
modules/nextcloud/preview-generation.nix
Normal file
116
modules/nextcloud/preview-generation.nix
Normal file
|
@ -0,0 +1,116 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
flake,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{
|
||||
config = lib.mkIf config.momo-cloud.nextcloud.enable {
|
||||
services.nextcloud = {
|
||||
extraApps = {
|
||||
inherit (pkgs.nextcloud30Packages.apps)
|
||||
previewgenerator
|
||||
;
|
||||
};
|
||||
settings = {
|
||||
enable_previews = true;
|
||||
jpeg_quality = 60;
|
||||
enabledPreviewProviders = [
|
||||
"OC\\Preview\\PNG"
|
||||
"OC\\Preview\\JPEG"
|
||||
"OC\\Preview\\GIF"
|
||||
"OC\\Preview\\BMP"
|
||||
"OC\\Preview\\HEIC"
|
||||
"OC\\Preview\\TIFF"
|
||||
"OC\\Preview\\XBitmap"
|
||||
"OC\\Preview\\SVG"
|
||||
"OC\\Preview\\WebP"
|
||||
"OC\\Preview\\Font"
|
||||
"OC\\Preview\\Movie"
|
||||
"OC\\Preview\\ImaginaryPDF"
|
||||
"OC\\Preview\\MP3"
|
||||
"OC\\Preview\\OpenDocument"
|
||||
"OC\\Preview\\Krita"
|
||||
"OC\\Preview\\TXT"
|
||||
"OC\\Preview\\MarkDown"
|
||||
"OC\\Preview\\Imaginary"
|
||||
];
|
||||
preview_imaginary_url = "http://127.0.0.1:${toString config.services.imaginary.port}/";
|
||||
preview_max_filesize_image = 128; # MB
|
||||
preview_max_memory = 512; # MB
|
||||
preview_max_x = 2048; # px
|
||||
preview_max_y = 2048; # px
|
||||
preview_max_scale_factor = 1;
|
||||
"preview_ffmpeg_path" = lib.getExe pkgs.ffmpeg-headless;
|
||||
};
|
||||
};
|
||||
|
||||
# https://docs.nextcloud.com/server/30/admin_manual/installation/server_tuning.html#previews
|
||||
services.imaginary = {
|
||||
enable = true;
|
||||
address = "127.0.0.1";
|
||||
settings.return-size = true;
|
||||
};
|
||||
|
||||
systemd = {
|
||||
services =
|
||||
let
|
||||
occ = "/run/current-system/sw/bin/nextcloud-occ";
|
||||
in
|
||||
{
|
||||
nextcloud-cron-preview-generator = {
|
||||
environment.NEXTCLOUD_CONFIG_DIR = "${config.services.nextcloud.home}/config";
|
||||
serviceConfig = {
|
||||
ExecStart = "${occ} preview:pre-generate";
|
||||
Type = "oneshot";
|
||||
User = "nextcloud";
|
||||
};
|
||||
};
|
||||
|
||||
nextcloud-preview-generator-setup = {
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
requires = [ "phpfpm-nextcloud.service" ];
|
||||
after = [ "phpfpm-nextcloud.service" ];
|
||||
environment.NEXTCLOUD_CONFIG_DIR = "${config.services.nextcloud.home}/config";
|
||||
script = # bash
|
||||
''
|
||||
# check with:
|
||||
# for size in squareSizes widthSizes heightSizes; do echo -n "$size: "; nextcloud-occ config:app:get previewgenerator $size; done
|
||||
|
||||
# extra commands run for preview generator:
|
||||
# 32 icon file list
|
||||
# 64 icon file list android app, photos app
|
||||
# 96 nextcloud client VFS windows file preview
|
||||
# 256 file app grid view, many requests
|
||||
# 512 photos app tags
|
||||
${occ} config:app:set --value="32 64 96 256 512" previewgenerator squareSizes
|
||||
|
||||
# 341 hover in maps app
|
||||
# 1920 files/photos app when viewing picture
|
||||
${occ} config:app:set --value="341 1920" previewgenerator widthSizes
|
||||
|
||||
# 256 hover in maps app
|
||||
# 1080 files/photos app when viewing picture
|
||||
${occ} config:app:set --value="256 1080" previewgenerator heightSizes
|
||||
'';
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
User = "nextcloud";
|
||||
};
|
||||
};
|
||||
};
|
||||
timers.nextcloud-cron-preview-generator = {
|
||||
after = [ "nextcloud-setup.service" ];
|
||||
timerConfig = {
|
||||
OnCalendar = "*:0/10";
|
||||
OnUnitActiveSec = "9m";
|
||||
Persistent = true;
|
||||
RandomizedDelaySec = 60;
|
||||
Unit = "nextcloud-cron-preview-generator.service";
|
||||
};
|
||||
wantedBy = [ "timers.target" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
54
modules/nextcloud/talk.nix
Normal file
54
modules/nextcloud/talk.nix
Normal file
|
@ -0,0 +1,54 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{
|
||||
options.momo-cloud.nextcloud.talk =
|
||||
let
|
||||
inherit (lib) mkOption mkEnableOption types;
|
||||
in
|
||||
{
|
||||
enable = mkEnableOption ''
|
||||
Whether to enable the nextcloud talk module
|
||||
'';
|
||||
coturnStaticAuthSecretFile = mkOption {
|
||||
description = "File that holds the coturn static auth secret";
|
||||
type = types.str;
|
||||
};
|
||||
signalingSecretFile = mkOption {
|
||||
description = "File that holds the signaling server secret";
|
||||
type = types.str;
|
||||
};
|
||||
};
|
||||
config = lib.mkIf config.momo-cloud.nextcloud.enable {
|
||||
momo-cloud.nextcloud.extraApps = {
|
||||
inherit (pkgs.nextcloud30Packages.apps)
|
||||
spreed
|
||||
;
|
||||
};
|
||||
|
||||
systemd.services."nextcloud-talk-provisioning" =
|
||||
let
|
||||
occ = "/run/current-system/sw/bin/nextcloud-occ";
|
||||
in
|
||||
{
|
||||
serviceConfig.Type = "oneshot";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
|
||||
after = [ "nextcloud-setup.service" ];
|
||||
script = ''
|
||||
TURN_SECRET=$(cat ${config.momo-cloud.nextcloud.talk.coturnStaticAuthSecretFile})
|
||||
|
||||
[ "''$(${occ} talk:turn:list | grep 'server:' | grep -c 'turn.${config.momo-cloud.networking.domain}')" != "0" ] || \
|
||||
${occ} talk:turn:add turns turn.${config.momo-cloud.networking.domain} udp,tcp --secret $TURN_SECRET
|
||||
|
||||
SIGNALING_SECRET=$(cat ${config.momo-cloud.nextcloud.talk.signalingSecretFile})
|
||||
|
||||
[ "''$(${occ} talk:signaling:list | grep 'server:' | grep -c 'signaling.${config.momo-cloud.networking.domain}')" != "0" ] || \
|
||||
${occ} talk:signaling:add https://signaling.${config.momo-cloud.networking.domain} $SIGNALING_SECRET --verify
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
127
modules/paperless/default.nix
Normal file
127
modules/paperless/default.nix
Normal file
|
@ -0,0 +1,127 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
let
|
||||
backupDir = "/var/backups/paperless";
|
||||
nixpkgs-master = builtins.fetchTarball {
|
||||
url = "https://github.com/NixOS/nixpkgs/archive/8852da7e72ef9f41684d83925c2f428b06587a29.tar.gz";
|
||||
sha256 = "sha256:0q2ww87kqn9bard90x8w5r30gbcyjk07zngfwr2ap3pbs4rzpjxi";
|
||||
};
|
||||
in
|
||||
{
|
||||
# Pull in early https://github.com/paperless-ngx/paperless-ngx/pull/9039
|
||||
imports = [
|
||||
(nixpkgs-master + "/nixos/modules/services/misc/paperless.nix")
|
||||
];
|
||||
|
||||
disabledModules = [
|
||||
"services/misc/paperless.nix"
|
||||
];
|
||||
|
||||
options.momo-cloud.paperless = with lib; {
|
||||
enable = mkEnableOption "Enable paperless instance";
|
||||
setup = mkEnableOption "Setup config, e.g. enablign regular login";
|
||||
|
||||
dataDir = mkOption {
|
||||
description = "Paperless data directory";
|
||||
type = types.str;
|
||||
default = "/var/lib/paperless";
|
||||
};
|
||||
|
||||
consumptionDir = mkOption {
|
||||
description = "Paperless consumption directory";
|
||||
type = types.str;
|
||||
default = "/var/lib/paperless/consume";
|
||||
};
|
||||
|
||||
envFile = mkOption { type = types.str; };
|
||||
oidcSecretFile = mkOption { type = types.str; };
|
||||
superuserPasswordFile = mkOption { type = types.str; };
|
||||
};
|
||||
|
||||
config = lib.mkIf config.momo-cloud.paperless.enable {
|
||||
security.acme.certs."paperless.${config.momo-cloud.networking.domain}" = { };
|
||||
|
||||
services.nginx.virtualHosts = {
|
||||
"paperless.${config.momo-cloud.networking.domain}" = {
|
||||
forceSSL = true;
|
||||
useACMEHost = "paperless.${config.momo-cloud.networking.domain}";
|
||||
listenAddresses = [
|
||||
config.momo-cloud.wireguard.ipv4.address
|
||||
"[${config.momo-cloud.wireguard.ipv6.address}]"
|
||||
];
|
||||
locations."/".proxyPass = "http://127.0.0.1:${builtins.toString config.services.paperless.port}";
|
||||
};
|
||||
};
|
||||
|
||||
services.paperless = {
|
||||
enable = true;
|
||||
consumptionDir = config.momo-cloud.paperless.consumptionDir;
|
||||
dataDir = config.momo-cloud.paperless.dataDir;
|
||||
address = "127.0.0.1";
|
||||
passwordFile = config.momo-cloud.paperless.superuserPasswordFile;
|
||||
settings = {
|
||||
PAPERLESS_ADMIN_USER = "admin@account.${config.momo-cloud.networking.domain}";
|
||||
PAPERLESS_OCR_LANGUAGE = "deu+eng";
|
||||
PAPERLESS_OCR_USER_ARGS = ''{"invalidate_digital_signatures": true}'';
|
||||
PAPERLESS_URL = "https://paperless.${config.momo-cloud.networking.domain}";
|
||||
PAPERLESS_DISABLE_REGULAR_LOGIN = if config.momo-cloud.paperless.setup then "false" else "true";
|
||||
PAPERLESS_APPS = "allauth.socialaccount.providers.openid_connect";
|
||||
PAPERLESS_SOCIAL_ACCOUNT_SYNC_GROUPS = "true";
|
||||
PAPERLESS_SOCIAL_ACCOUNT_DEFAULT_GROUPS = "paperless_users";
|
||||
PAPERLESS_SOCIALACCOUNT_AUTO_SIGNUP = "true";
|
||||
PAPERLESS_SOCIALACCOUNT_EMAIL_AUTHENTICATION_AUTO_CONNECT = "true";
|
||||
PAPERLESS_ACCOUNT_SESSION_REMEMBER = "true";
|
||||
PAPERLESS_EMAIL_TASK_CRON = "*/2 * * * *";
|
||||
};
|
||||
};
|
||||
|
||||
services.kanidm.provision = {
|
||||
groups.paperless_users = {
|
||||
memberless = true;
|
||||
};
|
||||
groups.paperless_admins = {
|
||||
memberless = true;
|
||||
};
|
||||
|
||||
systems.oauth2."paperless" = {
|
||||
displayName = "paperless";
|
||||
originUrl = "https://paperless.${config.momo-cloud.networking.domain}/accounts/oidc/kanidm/login/callback/";
|
||||
basicSecretFile = config.momo-cloud.paperless.oidcSecretFile;
|
||||
preferShortUsername = true;
|
||||
scopeMaps.paperless_users = [
|
||||
"email"
|
||||
"profile"
|
||||
"openid"
|
||||
"groups"
|
||||
];
|
||||
originLanding = "https://paperless.${config.momo-cloud.networking.domain}/accounts/login/";
|
||||
};
|
||||
};
|
||||
|
||||
systemd.services.paperless-web.serviceConfig.EnvironmentFile = [
|
||||
config.momo-cloud.paperless.envFile
|
||||
];
|
||||
|
||||
#################################
|
||||
# Backups
|
||||
#################################
|
||||
|
||||
systemd.tmpfiles.rules = [
|
||||
"d '${config.momo-cloud.paperless.dataDir}' 0700 paperless paperless - -"
|
||||
"d '${backupDir}' 0700 paperless paperless - -"
|
||||
"d '${config.momo-cloud.paperless.consumptionDir}' 0700 paperless paperless - -"
|
||||
];
|
||||
|
||||
momo-cloud.backups.restic.paperless = {
|
||||
paths = [ backupDir ];
|
||||
initialize = true;
|
||||
backupPrepareCommand = "${config.momo-cloud.paperless.dataDir}/paperless-manage document_exporter ${backupDir} -c -p";
|
||||
backupCleanupCommand = ''
|
||||
rm -rf ${backupDir}/*
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
37
modules/postgresql/default.nix
Normal file
37
modules/postgresql/default.nix
Normal file
|
@ -0,0 +1,37 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
{
|
||||
options.momo-cloud.postgresql = with lib; {
|
||||
enable = mkEnableOption "Enable postgres with sane default settings";
|
||||
};
|
||||
|
||||
config = lib.mkIf config.momo-cloud.postgresql.enable {
|
||||
services.postgresql = {
|
||||
enable = true;
|
||||
# Required for MediaWiki, connects via docker network
|
||||
enableTCPIP = true;
|
||||
# https://pgtune.leopard.in.ua/ DB Version: 14 OS Type: linux DB Type: web
|
||||
# Total Memory (RAM): 8 GB Data Storage: ssd
|
||||
settings = {
|
||||
max_connections = 200;
|
||||
shared_buffers = "2GB";
|
||||
effective_cache_size = "6GB";
|
||||
maintenance_work_mem = "512MB";
|
||||
checkpoint_completion_target = 0.9;
|
||||
wal_buffers = "16MB";
|
||||
default_statistics_target = 100;
|
||||
random_page_cost = 1.1;
|
||||
effective_io_concurrency = 200;
|
||||
work_mem = "5242kB";
|
||||
huge_pages = "off";
|
||||
min_wal_size = "1GB";
|
||||
max_wal_size = "4GB";
|
||||
# ZFS is always consistent (Copy-On-Write)
|
||||
full_page_writes = false;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
32
modules/proxy/authelia-authrequest.conf
Normal file
32
modules/proxy/authelia-authrequest.conf
Normal file
|
@ -0,0 +1,32 @@
|
|||
## Send a subrequest to Authelia to verify if the user is authenticated and has permission to access the resource.
|
||||
auth_request /internal/authelia/authz;
|
||||
|
||||
## Save the upstream metadata response headers from Authelia to variables.
|
||||
auth_request_set $user $upstream_http_remote_user;
|
||||
auth_request_set $groups $upstream_http_remote_groups;
|
||||
auth_request_set $name $upstream_http_remote_name;
|
||||
auth_request_set $email $upstream_http_remote_email;
|
||||
|
||||
## Inject the metadata response headers from the variables into the request made to the backend.
|
||||
proxy_set_header Remote-User $user;
|
||||
proxy_set_header Remote-Groups $groups;
|
||||
proxy_set_header Remote-Email $email;
|
||||
proxy_set_header Remote-Name $name;
|
||||
|
||||
## Configure the redirection when the authz failure occurs. Lines starting with 'Modern Method' and 'Legacy Method'
|
||||
## should be commented / uncommented as pairs. The modern method uses the session cookies configuration's authelia_url
|
||||
## value to determine the redirection URL here. It's much simpler and compatible with the mutli-cookie domain easily.
|
||||
|
||||
## Modern Method: Set the $redirection_url to the Location header of the response to the Authz endpoint.
|
||||
auth_request_set $redirection_url $upstream_http_location;
|
||||
|
||||
## Modern Method: When there is a 401 response code from the authz endpoint redirect to the $redirection_url.
|
||||
error_page 401 =302 $redirection_url;
|
||||
|
||||
## Legacy Method: Set $target_url to the original requested URL.
|
||||
## This requires http_set_misc module, replace 'set_escape_uri' with 'set' if you don't have this module.
|
||||
# set_escape_uri $target_url $scheme://$http_host$request_uri;
|
||||
|
||||
## Legacy Method: When there is a 401 response code from the authz endpoint redirect to the portal with the 'rd'
|
||||
## URL parameter set to $target_url. This requires users update 'auth.example.com/' with their external authelia URL.
|
||||
# error_page 401 =302 https://auth.example.com/?rd=$target_url;
|
30
modules/proxy/authelia-location.conf
Normal file
30
modules/proxy/authelia-location.conf
Normal file
|
@ -0,0 +1,30 @@
|
|||
## Virtual endpoint created by nginx to forward auth requests.
|
||||
location /internal/authelia/authz {
|
||||
## Essential Proxy Configuration
|
||||
internal;
|
||||
proxy_pass $upstream_authelia;
|
||||
|
||||
## Headers
|
||||
## The headers starting with X-* are required.
|
||||
proxy_set_header X-Original-Method $request_method;
|
||||
proxy_set_header X-Original-URL $scheme://$http_host$request_uri;
|
||||
proxy_set_header X-Forwarded-For $remote_addr;
|
||||
proxy_set_header Content-Length "";
|
||||
proxy_set_header Connection "";
|
||||
|
||||
## Basic Proxy Configuration
|
||||
proxy_pass_request_body off;
|
||||
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503; # Timeout if the real server is dead
|
||||
proxy_redirect http:// $scheme://;
|
||||
proxy_http_version 1.1;
|
||||
proxy_cache_bypass $cookie_session;
|
||||
proxy_no_cache $cookie_session;
|
||||
proxy_buffers 4 32k;
|
||||
client_body_buffer_size 128k;
|
||||
|
||||
## Advanced Proxy Configuration
|
||||
send_timeout 5m;
|
||||
proxy_read_timeout 240;
|
||||
proxy_send_timeout 240;
|
||||
proxy_connect_timeout 240;
|
||||
}
|
26
modules/proxy/default.nix
Normal file
26
modules/proxy/default.nix
Normal file
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
flake,
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{
|
||||
options.momo-cloud.proxy = with lib; {
|
||||
enable = mkEnableOption "Enable nginx proxy settings";
|
||||
};
|
||||
|
||||
config = lib.mkIf config.momo-cloud.proxy.enable {
|
||||
momo-cloud.http-server.enable = true;
|
||||
|
||||
environment.etc = {
|
||||
"nginx/conf-available/proxy.conf".source = ./proxy.conf;
|
||||
"nginx/conf-available/authelia-location.conf".text =
|
||||
''
|
||||
set $upstream_authelia https://auth.${config.momo-cloud.networking.domain}/api/authz/auth-request;
|
||||
''
|
||||
+ (builtins.readFile ./authelia-location.conf);
|
||||
"nginx/conf-available/authelia-authrequest.conf".source = ./authelia-authrequest.conf;
|
||||
};
|
||||
};
|
||||
}
|
28
modules/proxy/proxy.conf
Normal file
28
modules/proxy/proxy.conf
Normal file
|
@ -0,0 +1,28 @@
|
|||
## Headers
|
||||
proxy_set_header X-Original-URL $scheme://$http_host$request_uri;
|
||||
proxy_set_header X-Forwarded-URI $request_uri;
|
||||
proxy_set_header X-Forwarded-Ssl on;
|
||||
|
||||
## Basic Proxy Configuration
|
||||
client_body_buffer_size 128k;
|
||||
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503; ## Timeout if the real server is dead.
|
||||
proxy_redirect http:// $scheme://;
|
||||
proxy_http_version 1.1;
|
||||
proxy_cache_bypass $cookie_session;
|
||||
proxy_no_cache $cookie_session;
|
||||
proxy_buffers 64 256k;
|
||||
|
||||
## Trusted Proxies Configuration
|
||||
## Please read the following documentation before configuring this:
|
||||
## https://www.authelia.com/integration/proxies/nginx/#trusted-proxies
|
||||
set_real_ip_from 10.30.30.0/24;
|
||||
set_real_ip_from fd00:30:30:30:30::/80;
|
||||
|
||||
real_ip_header X-Forwarded-For;
|
||||
real_ip_recursive on;
|
||||
|
||||
## Advanced Proxy Configuration
|
||||
send_timeout 5m;
|
||||
proxy_read_timeout 360;
|
||||
proxy_send_timeout 360;
|
||||
proxy_connect_timeout 360;
|
162
modules/solidtime/default.nix
Normal file
162
modules/solidtime/default.nix
Normal file
|
@ -0,0 +1,162 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
let
|
||||
backupDir = "/var/backups/solidtime";
|
||||
domain = "timetracking.${config.momo-cloud.networking.domain}";
|
||||
in
|
||||
{
|
||||
options.momo-cloud.solidtime = with lib; {
|
||||
enable = mkEnableOption "Enable solidtime instance";
|
||||
|
||||
superAdmins = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [ ];
|
||||
};
|
||||
envFile = mkOption { type = types.str; };
|
||||
dbEnvFile = mkOption { type = types.str; };
|
||||
};
|
||||
|
||||
config =
|
||||
let
|
||||
superAdmins = lib.strings.concatStringsSep "," config.momo-cloud.solidtime.superAdmins;
|
||||
defaultEnvironment = {
|
||||
SUPER_ADMINS = superAdmins;
|
||||
APP_URL = "https://timetracking.${config.momo-cloud.networking.domain}";
|
||||
};
|
||||
in
|
||||
lib.mkIf config.momo-cloud.solidtime.enable {
|
||||
momo-cloud.http-server.enable = true;
|
||||
momo-cloud.acme.enable = true;
|
||||
momo-cloud.docker.enable = true;
|
||||
|
||||
security.acme.certs = {
|
||||
"${domain}" = { };
|
||||
};
|
||||
|
||||
services.nginx.virtualHosts = {
|
||||
"${domain}" = {
|
||||
forceSSL = true;
|
||||
useACMEHost = domain;
|
||||
listenAddresses = [
|
||||
config.momo-cloud.wireguard.ipv4.address
|
||||
"[${config.momo-cloud.wireguard.ipv6.address}]"
|
||||
];
|
||||
locations."/".proxyPass = "http://127.0.0.1:8000";
|
||||
};
|
||||
};
|
||||
|
||||
systemd.services."docker-network-solidtime" =
|
||||
let
|
||||
docker = config.virtualisation.oci-containers.backend;
|
||||
dockerBin = "${pkgs.${docker}}/bin/${docker}";
|
||||
in
|
||||
{
|
||||
serviceConfig.Type = "oneshot";
|
||||
before = [ "docker-solidtime.service" ];
|
||||
requiredBy = [ "docker-solidtime.service" ];
|
||||
script = ''
|
||||
${dockerBin} network inspect solidtime >/dev/null 2>&1 || ${dockerBin} network create solidtime --subnet 172.20.0.0/24
|
||||
'';
|
||||
};
|
||||
|
||||
virtualisation = {
|
||||
oci-containers = {
|
||||
backend = "docker";
|
||||
|
||||
containers."solidtime" = {
|
||||
image = "solidtime/solidtime:latest";
|
||||
autoStart = true;
|
||||
volumes = [
|
||||
"/var/lib/solidtime/storage:/var/www/html/storage"
|
||||
"${config.momo-cloud.solidtime.envFile}:/var/www/html/.env"
|
||||
];
|
||||
extraOptions = [
|
||||
"--network=solidtime"
|
||||
"--add-host=mail.momo.koeln:host-gateway"
|
||||
"--health-cmd"
|
||||
"curl --fail http://localhost:8000/health-check/up || exit 1"
|
||||
];
|
||||
environment = defaultEnvironment // {
|
||||
CONTAINER_MODE = "http";
|
||||
AUTO_DB_MIGRATE = "true";
|
||||
};
|
||||
ports = [ "127.0.0.1:8000:8000" ];
|
||||
dependsOn = [ "solidtime-db" ];
|
||||
};
|
||||
|
||||
containers."solidtime-scheduler" = {
|
||||
image = "solidtime/solidtime:latest";
|
||||
autoStart = true;
|
||||
volumes = [
|
||||
"/var/lib/solidtime/storage:/var/www/html/storage"
|
||||
"${config.momo-cloud.solidtime.envFile}:/var/www/html/.env"
|
||||
];
|
||||
extraOptions = [
|
||||
"--network=solidtime"
|
||||
"--add-host=mail.momo.koeln:host-gateway"
|
||||
"--health-cmd"
|
||||
"supervisorctl status scheduler:scheduler_00"
|
||||
];
|
||||
environment = defaultEnvironment // {
|
||||
CONTAINER_MODE = "scheduler";
|
||||
};
|
||||
dependsOn = [ "solidtime-db" ];
|
||||
};
|
||||
|
||||
containers."solidtime-queue" = {
|
||||
image = "solidtime/solidtime:latest";
|
||||
autoStart = true;
|
||||
volumes = [
|
||||
"/var/lib/solidtime/storage:/var/www/html/storage"
|
||||
"${config.momo-cloud.solidtime.envFile}:/var/www/html/.env"
|
||||
];
|
||||
extraOptions = [
|
||||
"--network=solidtime"
|
||||
"--add-host=mail.momo.koeln:host-gateway"
|
||||
"--health-cmd"
|
||||
"supervisorctl status worker:worker_00"
|
||||
];
|
||||
environment = defaultEnvironment // {
|
||||
CONTAINER_MODE = "worker";
|
||||
WORKER_COMMAND = "php /var/www/html/artisan queue:work";
|
||||
};
|
||||
dependsOn = [ "solidtime-db" ];
|
||||
};
|
||||
|
||||
containers."solidtime-db" = {
|
||||
image = "postgres:16";
|
||||
autoStart = true;
|
||||
volumes = [
|
||||
"/var/lib/solidtime/db:/var/lib/postgresql/data"
|
||||
];
|
||||
extraOptions = [ "--network=solidtime" ];
|
||||
environmentFiles = [
|
||||
config.momo-cloud.solidtime.dbEnvFile
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
systemd.tmpfiles.rules = [
|
||||
"d '${backupDir}' 0700 root root - -"
|
||||
];
|
||||
|
||||
momo-cloud.backups.restic.solidtime = {
|
||||
paths = [
|
||||
backupDir
|
||||
"/var/lib/solidtime/storage"
|
||||
];
|
||||
initialize = true;
|
||||
backupPrepareCommand = ''
|
||||
${pkgs.docker-client}/bin/docker exec -t solidtime-db pg_dumpall -c -U solidtime > "${backupDir}/postgres.sql"
|
||||
'';
|
||||
backupCleanupCommand = ''
|
||||
rm -rf ${backupDir}/*
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
66
modules/static-website/default.nix
Normal file
66
modules/static-website/default.nix
Normal file
|
@ -0,0 +1,66 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{
|
||||
options.momo-cloud.static-website =
|
||||
let
|
||||
inherit (lib) mkOption mkEnableOption types;
|
||||
in
|
||||
{
|
||||
enable = mkEnableOption ''
|
||||
Enable static website config for the base HTTP server. This will run at www. and the bare domain.
|
||||
'';
|
||||
|
||||
root = mkOption {
|
||||
description = "Nix derivation or path that holds the static website files";
|
||||
type = types.oneOf [
|
||||
types.package
|
||||
types.path
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf config.momo-cloud.static-website.enable {
|
||||
momo-cloud.acme.enable = true;
|
||||
momo-cloud.http-server.enable = true;
|
||||
|
||||
services.nginx.virtualHosts = {
|
||||
"www.${config.momo-cloud.networking.domain}" = {
|
||||
enableACME = true;
|
||||
forceSSL = true;
|
||||
|
||||
extraConfig = ''
|
||||
error_log /dev/null;
|
||||
access_log /dev/null;
|
||||
'';
|
||||
|
||||
locations."/" = {
|
||||
extraConfig = ''
|
||||
return 301 https://${config.momo-cloud.networking.domain}$request_uri;
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
"${config.momo-cloud.networking.domain}" = {
|
||||
default = true;
|
||||
enableACME = true;
|
||||
forceSSL = true;
|
||||
|
||||
extraConfig = ''
|
||||
error_log /dev/null;
|
||||
access_log /dev/null;
|
||||
'';
|
||||
|
||||
locations = {
|
||||
"/" = {
|
||||
root = config.momo-cloud.static-website.root;
|
||||
index = "index.html";
|
||||
tryFiles = "$uri $uri/ =404";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
35
modules/unlock-luks-on-boot/default.nix
Normal file
35
modules/unlock-luks-on-boot/default.nix
Normal file
|
@ -0,0 +1,35 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{
|
||||
options.momo-cloud.unlock-luks-on-boot = with lib; {
|
||||
enable = mkEnableOption "Enable LUKS unlocking in initrd";
|
||||
};
|
||||
|
||||
config = lib.mkIf config.momo-cloud.unlock-luks-on-boot.enable {
|
||||
momo-cloud.http-server.enable = true;
|
||||
boot.initrd.network = {
|
||||
enable = true;
|
||||
ssh = {
|
||||
enable = true;
|
||||
# To prevent ssh clients from freaking out because a different host key is used,
|
||||
# a different port for ssh is useful (assuming the same host has also a regular sshd running)
|
||||
port = 2222;
|
||||
|
||||
# Please create this manually the first time.
|
||||
hostKeys = [ "/etc/secrets/initrd/ssh_host_ed25519_key" ];
|
||||
authorizedKeys = lib.lists.foldl (
|
||||
sshPubKeys: userConfig:
|
||||
sshPubKeys
|
||||
++ (if userConfig ? "sshPubKeys" then lib.attrsets.attrValues userConfig.sshPubKeys else [ ])
|
||||
) [ ] (lib.attrsets.attrValues config.momo-cloud.authentication.users);
|
||||
};
|
||||
postCommands = ''
|
||||
# Automatically ask for the password on SSH login
|
||||
echo 'cryptsetup-askpass || echo "Unlock was successful; exiting SSH session" && exit 1' >> /root/.profile
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
44
modules/unlock-zfs-on-boot/default.nix
Normal file
44
modules/unlock-zfs-on-boot/default.nix
Normal file
|
@ -0,0 +1,44 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{
|
||||
options.momo-cloud.unlock-zfs-on-boot = with lib; {
|
||||
enable = mkEnableOption "Enable ZFS unlocking in initrd";
|
||||
};
|
||||
|
||||
config = lib.mkIf config.momo-cloud.unlock-zfs-on-boot.enable {
|
||||
# From https://nixos.wiki/wiki/ZFS#Unlock_encrypted_zfs_via_ssh_on_boot
|
||||
boot.initrd.network = {
|
||||
enable = true;
|
||||
ssh = {
|
||||
enable = true;
|
||||
# To prevent ssh clients from freaking out because a different host key is used,
|
||||
# a different port for ssh is useful (assuming the same host has also a regular sshd running)
|
||||
port = 2222;
|
||||
|
||||
# Please create this manually the first time.
|
||||
hostKeys = [ "/etc/secrets/initrd/ssh_host_ed25519_key" ];
|
||||
authorizedKeys = lib.lists.foldl (
|
||||
sshPubKeys: userConfig:
|
||||
sshPubKeys
|
||||
++ (if userConfig ? "sshPubKeys" then lib.attrsets.attrValues userConfig.sshPubKeys else [ ])
|
||||
) [ ] (lib.attrsets.attrValues config.momo-cloud.authentication.users);
|
||||
};
|
||||
# this will automatically load the zfs password prompt on login
|
||||
# and kill the other prompt so boot can continue
|
||||
postCommands = ''
|
||||
cat <<EOF > /root/.profile
|
||||
if pgrep -x "zfs" > /dev/null
|
||||
then
|
||||
zfs load-key -a
|
||||
killall zfs
|
||||
else
|
||||
echo "zfs not running -- maybe the pool is taking some time to load for some unforseen reason."
|
||||
fi
|
||||
EOF
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
66
modules/wireguard/default.nix
Normal file
66
modules/wireguard/default.nix
Normal file
|
@ -0,0 +1,66 @@
|
|||
{
|
||||
config,
|
||||
flake,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
cfg = config.momo-cloud.wireguard;
|
||||
wireguardDevicesForUsers = import ../../lib/wireguardDevicesForUsers.nix { inherit lib; };
|
||||
in
|
||||
{
|
||||
options.momo-cloud.wireguard = with lib; {
|
||||
enable = mkEnableOption "Enable wireguard network";
|
||||
openFirewall = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
};
|
||||
privateKeyFile = mkOption { type = types.str; };
|
||||
listenPort = mkOption {
|
||||
type = types.int;
|
||||
default = 51820;
|
||||
};
|
||||
mtu = mkOption {
|
||||
type = types.int;
|
||||
default = 1300;
|
||||
};
|
||||
additionalPeers = mkOption {
|
||||
type = types.listOf types.attrs;
|
||||
default = [ ];
|
||||
};
|
||||
ipv4.address = mkOption { type = types.str; };
|
||||
ipv6.address = mkOption { type = types.str; };
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
networking.firewall.allowedUDPPorts = lib.mkIf cfg.openFirewall [ cfg.listenPort ];
|
||||
|
||||
networking.wireguard.interfaces = {
|
||||
wg-ssh = {
|
||||
listenPort = cfg.listenPort;
|
||||
mtu = cfg.mtu;
|
||||
ips = [
|
||||
"${config.momo-cloud.wireguard.ipv4.address}/32"
|
||||
"${config.momo-cloud.wireguard.ipv6.address}/96"
|
||||
];
|
||||
privateKeyFile = config.momo-cloud.wireguard.privateKeyFile;
|
||||
peers =
|
||||
(wireguardDevicesForUsers config.momo-cloud.authentication.users)
|
||||
++ cfg.additionalPeers;
|
||||
};
|
||||
};
|
||||
|
||||
services.openssh.openFirewall = true;
|
||||
#services.openssh.listenAddresses = [
|
||||
# {
|
||||
# addr = config.momo-cloud.wireguard.ipv4.address;
|
||||
# port = 22;
|
||||
# }
|
||||
# {
|
||||
# addr = "[${config.momo-cloud.wireguard.ipv6.address}]";
|
||||
# port = 22;
|
||||
# }
|
||||
#];
|
||||
};
|
||||
}
|
47
overlays/default.nix
Normal file
47
overlays/default.nix
Normal file
|
@ -0,0 +1,47 @@
|
|||
{
|
||||
lib,
|
||||
inputs,
|
||||
...
|
||||
}:
|
||||
{
|
||||
flake = {
|
||||
nixosModules = rec {
|
||||
overlays = (
|
||||
{ ... }:
|
||||
{
|
||||
nixpkgs.overlays = lib.mkForce [
|
||||
inputs.invoiceplane-template.overlays.default
|
||||
(final: prev: (import ../pkgs { pkgs = final; }))
|
||||
|
||||
(
|
||||
final: prev:
|
||||
let
|
||||
nixpkgs-unstable = import inputs.nixpkgs-unstable { system = prev.system; };
|
||||
|
||||
nixpkgs-master = import inputs.nixpkgs-master { system = prev.system; };
|
||||
|
||||
nixpkgs-nc-spreed-signaling = import inputs.nixpkgs-nc-spreed-signaling-pr {
|
||||
system = prev.system;
|
||||
};
|
||||
in
|
||||
{
|
||||
authelia = nixpkgs-unstable.authelia;
|
||||
kanidm-provision = prev.kanidm-provision.overrideAttrs (oldAttrs: {
|
||||
patches = (oldAttrs.patches or [ ]) ++ [
|
||||
(prev.fetchpatch {
|
||||
url = "https://patch-diff.githubusercontent.com/raw/oddlama/kanidm-provision/pull/19.diff";
|
||||
hash = "sha256-cfn2gBHd8XfGZ63vMPvqyIHmUDXnyb/6574ic43rJks=";
|
||||
})
|
||||
];
|
||||
});
|
||||
paperless-ngx = nixpkgs-master.paperless-ngx;
|
||||
|
||||
nextcloud-spreed-signaling = nixpkgs-nc-spreed-signaling.nextcloud-spreed-signaling;
|
||||
}
|
||||
)
|
||||
];
|
||||
}
|
||||
);
|
||||
};
|
||||
};
|
||||
}
|
46
pkgs/autofetch-hostingde-invoices.nix
Normal file
46
pkgs/autofetch-hostingde-invoices.nix
Normal file
|
@ -0,0 +1,46 @@
|
|||
self: with self; ''
|
||||
set -e
|
||||
|
||||
PATH="$PATH:${jq}/bin:${curl}/bin:${gnugrep}/bin"
|
||||
|
||||
SECRET_FILE=$1
|
||||
OUT_DIR=$2
|
||||
STATE_FILE=$3
|
||||
|
||||
AUTH_TOKEN=$(cat "$SECRET_FILE")
|
||||
|
||||
CURL_BODY=$(cat <<EOF
|
||||
{
|
||||
"limit": 30,
|
||||
"sort": {
|
||||
"field": "documentDate",
|
||||
"order": "DESC"
|
||||
},
|
||||
"authToken": "$AUTH_TOKEN"
|
||||
}
|
||||
EOF
|
||||
)
|
||||
CURL_URL="https://secure.hosting.de/api/billing/v1/json/documentsFind"
|
||||
echo "fetching $CURL_URL";
|
||||
documents=$(curl -X POST -H "Content-Type: application/json" -H "Accept: application/json" -d "$CURL_BODY" "$CURL_URL" | jq '.response.data.[].documentId' -rc)
|
||||
|
||||
for doc in $documents; do
|
||||
if [ "$(grep --count "$doc" "$STATE_FILE")" -gt 0 ]; then
|
||||
echo "Skipping already fetched $doc"
|
||||
continue
|
||||
fi
|
||||
|
||||
CURL_BODY=$(cat <<EOF
|
||||
{
|
||||
"id": "$doc",
|
||||
"authToken": "$AUTH_TOKEN"
|
||||
}
|
||||
EOF
|
||||
)
|
||||
CURL_URL="https://secure.hosting.de/api/billing/v1/json/accountingDocumentPdfGet"
|
||||
echo "fetching $doc";
|
||||
url=$(curl -X POST -H "Content-Type: application/json" -H "Accept: application/json" -d "$CURL_BODY" "$CURL_URL" | jq '.response' -rc)
|
||||
curl "$url" >> "$OUT_DIR/$doc.pdf"
|
||||
echo "$doc" >> "$STATE_FILE"
|
||||
done
|
||||
''
|
7
pkgs/default.nix
Normal file
7
pkgs/default.nix
Normal file
|
@ -0,0 +1,7 @@
|
|||
{ pkgs, ... }:
|
||||
{
|
||||
autofetch-hostingde-invoices = pkgs.writeShellApplication {
|
||||
name = "fetch-hostingde-invoices";
|
||||
text = (import ./autofetch-hostingde-invoices.nix pkgs);
|
||||
};
|
||||
}
|
463
staging/flake.lock
generated
Normal file
463
staging/flake.lock
generated
Normal file
|
@ -0,0 +1,463 @@
|
|||
{
|
||||
"nodes": {
|
||||
"agenix": {
|
||||
"inputs": {
|
||||
"darwin": "darwin",
|
||||
"home-manager": "home-manager",
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
],
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1736955230,
|
||||
"narHash": "sha256-uenf8fv2eG5bKM8C/UvFaiJMZ4IpUFaQxk9OH5t/1gA=",
|
||||
"owner": "ryantm",
|
||||
"repo": "agenix",
|
||||
"rev": "e600439ec4c273cf11e06fe4d9d906fb98fa097c",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "ryantm",
|
||||
"repo": "agenix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"blobs": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1604995301,
|
||||
"narHash": "sha256-wcLzgLec6SGJA8fx1OEN1yV/Py5b+U5iyYpksUY/yLw=",
|
||||
"owner": "simple-nixos-mailserver",
|
||||
"repo": "blobs",
|
||||
"rev": "2cccdf1ca48316f2cfd1c9a0017e8de5a7156265",
|
||||
"type": "gitlab"
|
||||
},
|
||||
"original": {
|
||||
"owner": "simple-nixos-mailserver",
|
||||
"repo": "blobs",
|
||||
"type": "gitlab"
|
||||
}
|
||||
},
|
||||
"darwin": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"agenix",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1700795494,
|
||||
"narHash": "sha256-gzGLZSiOhf155FW7262kdHo2YDeugp3VuIFb4/GGng0=",
|
||||
"owner": "lnl7",
|
||||
"repo": "nix-darwin",
|
||||
"rev": "4b9b83d5a92e8c1fbfd8eb27eda375908c11ec4d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "lnl7",
|
||||
"ref": "master",
|
||||
"repo": "nix-darwin",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"deploy-rs": {
|
||||
"inputs": {
|
||||
"flake-compat": "flake-compat",
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
],
|
||||
"utils": "utils"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1727447169,
|
||||
"narHash": "sha256-3KyjMPUKHkiWhwR91J1YchF6zb6gvckCAY1jOE+ne0U=",
|
||||
"owner": "serokell",
|
||||
"repo": "deploy-rs",
|
||||
"rev": "aa07eb05537d4cd025e2310397a6adcedfe72c76",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "serokell",
|
||||
"repo": "deploy-rs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"disko": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1744145203,
|
||||
"narHash": "sha256-I2oILRiJ6G+BOSjY+0dGrTPe080L3pbKpc+gCV3Nmyk=",
|
||||
"owner": "nix-community",
|
||||
"repo": "disko",
|
||||
"rev": "76c0a6dba345490508f36c1aa3c7ba5b6b460989",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "disko",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-compat": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1696426674,
|
||||
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-compat_2": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1696426674,
|
||||
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-parts": {
|
||||
"inputs": {
|
||||
"nixpkgs-lib": "nixpkgs-lib"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1743550720,
|
||||
"narHash": "sha256-hIshGgKZCgWh6AYJpJmRgFdR3WUbkY04o82X05xqQiY=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"rev": "c621e8422220273271f52058f618c94e405bb0f5",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-parts_2": {
|
||||
"inputs": {
|
||||
"nixpkgs-lib": "nixpkgs-lib_2"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1743550720,
|
||||
"narHash": "sha256-hIshGgKZCgWh6AYJpJmRgFdR3WUbkY04o82X05xqQiY=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"rev": "c621e8422220273271f52058f618c94e405bb0f5",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"home-manager": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"agenix",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1703113217,
|
||||
"narHash": "sha256-7ulcXOk63TIT2lVDSExj7XzFx09LpdSAPtvgtM7yQPE=",
|
||||
"owner": "nix-community",
|
||||
"repo": "home-manager",
|
||||
"rev": "3bfaacf46133c037bb356193bd2f1765d9dc82c1",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "home-manager",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"home-manager_2": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"momo-cloud",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1744117652,
|
||||
"narHash": "sha256-t7dFCDl4vIOOUMhEZnJF15aAzkpaup9x4ZRGToDFYWI=",
|
||||
"owner": "nix-community",
|
||||
"repo": "home-manager",
|
||||
"rev": "b4e98224ad1336751a2ac7493967a4c9f6d9cb3f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"ref": "release-24.11",
|
||||
"repo": "home-manager",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"invoiceplane-template": {
|
||||
"inputs": {
|
||||
"flake-parts": [
|
||||
"momo-cloud",
|
||||
"flake-parts"
|
||||
],
|
||||
"nixpkgs": [
|
||||
"momo-cloud",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1728398621,
|
||||
"narHash": "sha256-cNCgW0g012t7lZ2gxBpc+Uu6GHV2sTEsOV50nSZ96FM=",
|
||||
"ref": "refs/heads/main",
|
||||
"rev": "a4f2aa76583b5dfa3f2db12ff360ba9f229cfb2f",
|
||||
"revCount": 37,
|
||||
"type": "git",
|
||||
"url": "https://git.pub.solar/momo/invoiceplane-templates.git"
|
||||
},
|
||||
"original": {
|
||||
"type": "git",
|
||||
"url": "https://git.pub.solar/momo/invoiceplane-templates.git"
|
||||
}
|
||||
},
|
||||
"momo-cloud": {
|
||||
"inputs": {
|
||||
"flake-parts": "flake-parts_2",
|
||||
"home-manager": "home-manager_2",
|
||||
"invoiceplane-template": "invoiceplane-template",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"nixpkgs-master": "nixpkgs-master",
|
||||
"nixpkgs-nc-spreed-signaling-pr": "nixpkgs-nc-spreed-signaling-pr",
|
||||
"nixpkgs-unstable": "nixpkgs-unstable",
|
||||
"simple-nixos-mailserver": "simple-nixos-mailserver"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 0,
|
||||
"narHash": "sha256-aa6lQvfLkNheqULoJaqLWxfva0q64jnHm28nl6jyDPQ=",
|
||||
"path": "../",
|
||||
"type": "path"
|
||||
},
|
||||
"original": {
|
||||
"path": "../",
|
||||
"type": "path"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1744440957,
|
||||
"narHash": "sha256-FHlSkNqFmPxPJvy+6fNLaNeWnF1lZSgqVCl/eWaJRc4=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "26d499fc9f1d567283d5d56fcf367edd815dba1d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "nixos-24.11",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs-lib": {
|
||||
"locked": {
|
||||
"lastModified": 1743296961,
|
||||
"narHash": "sha256-b1EdN3cULCqtorQ4QeWgLMrd5ZGOjLSLemfa00heasc=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nixpkgs.lib",
|
||||
"rev": "e4822aea2a6d1cdd36653c134cacfd64c97ff4fa",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "nixpkgs.lib",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs-lib_2": {
|
||||
"locked": {
|
||||
"lastModified": 1743296961,
|
||||
"narHash": "sha256-b1EdN3cULCqtorQ4QeWgLMrd5ZGOjLSLemfa00heasc=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nixpkgs.lib",
|
||||
"rev": "e4822aea2a6d1cdd36653c134cacfd64c97ff4fa",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "nixpkgs.lib",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs-master": {
|
||||
"locked": {
|
||||
"lastModified": 1744734272,
|
||||
"narHash": "sha256-P32AWRtc13VZMfSubFKShFHacXRy6od/ILrwmEgkq9c=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "3e5bb71d1ab409b4110a66b8aa340d664892579a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "master",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs-nc-spreed-signaling-pr": {
|
||||
"locked": {
|
||||
"lastModified": 1742859343,
|
||||
"narHash": "sha256-20TWYfC3kaDgDwHrk/v1EXCNJ3AshgCdTAuxnza48WQ=",
|
||||
"owner": "hensoko",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "86025a170c7d3b8ac7b467b9501598885b8c8728",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "hensoko",
|
||||
"ref": "nextcloud-spreed-signaling",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs-unstable": {
|
||||
"locked": {
|
||||
"lastModified": 1744463964,
|
||||
"narHash": "sha256-LWqduOgLHCFxiTNYi3Uj5Lgz0SR+Xhw3kr/3Xd0GPTM=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "2631b0b7abcea6e640ce31cd78ea58910d31e650",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1744440957,
|
||||
"narHash": "sha256-FHlSkNqFmPxPJvy+6fNLaNeWnF1lZSgqVCl/eWaJRc4=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "26d499fc9f1d567283d5d56fcf367edd815dba1d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "nixos-24.11",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"agenix": "agenix",
|
||||
"deploy-rs": "deploy-rs",
|
||||
"disko": "disko",
|
||||
"flake-parts": "flake-parts",
|
||||
"momo-cloud": "momo-cloud",
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
}
|
||||
},
|
||||
"simple-nixos-mailserver": {
|
||||
"inputs": {
|
||||
"blobs": "blobs",
|
||||
"flake-compat": "flake-compat_2",
|
||||
"nixpkgs": [
|
||||
"momo-cloud",
|
||||
"nixpkgs-unstable"
|
||||
],
|
||||
"nixpkgs-24_11": [
|
||||
"momo-cloud",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1734884447,
|
||||
"narHash": "sha256-HA9fAmGNGf0cOYrhgoa+B6BxNVqGAYXfLyx8zIS0ZBY=",
|
||||
"owner": "simple-nixos-mailserver",
|
||||
"repo": "nixos-mailserver",
|
||||
"rev": "63209b1def2c9fc891ad271f474a3464a5833294",
|
||||
"type": "gitlab"
|
||||
},
|
||||
"original": {
|
||||
"owner": "simple-nixos-mailserver",
|
||||
"ref": "nixos-24.11",
|
||||
"repo": "nixos-mailserver",
|
||||
"type": "gitlab"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems_2": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"utils": {
|
||||
"inputs": {
|
||||
"systems": "systems_2"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1701680307,
|
||||
"narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "4022d587cbbfd70fe950c1e2083a02621806a725",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
98
staging/flake.nix
Normal file
98
staging/flake.nix
Normal file
|
@ -0,0 +1,98 @@
|
|||
{
|
||||
inputs = {
|
||||
# Track channels with commits tested and built by hydra
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11";
|
||||
|
||||
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||
|
||||
deploy-rs.url = "github:serokell/deploy-rs";
|
||||
deploy-rs.inputs.nixpkgs.follows = "nixpkgs";
|
||||
|
||||
disko.url = "github:nix-community/disko";
|
||||
disko.inputs.nixpkgs.follows = "nixpkgs";
|
||||
|
||||
agenix.url = "github:ryantm/agenix";
|
||||
agenix.inputs.nixpkgs.follows = "nixpkgs";
|
||||
|
||||
momo-cloud.url = "path:../";
|
||||
};
|
||||
|
||||
outputs =
|
||||
inputs@{ self, ... }:
|
||||
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
|
||||
systems = [
|
||||
"x86_64-linux"
|
||||
"aarch64-linux"
|
||||
];
|
||||
|
||||
imports = [
|
||||
inputs.flake-parts.flakeModules.easyOverlay
|
||||
./logins
|
||||
./lib
|
||||
./hosts
|
||||
];
|
||||
|
||||
perSystem =
|
||||
args@{
|
||||
system,
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{
|
||||
_module.args = {
|
||||
inherit inputs;
|
||||
pkgs = import inputs.nixpkgs {
|
||||
inherit system;
|
||||
overlays = [
|
||||
inputs.agenix.overlays.default
|
||||
inputs.momo-cloud.overlays.default
|
||||
];
|
||||
};
|
||||
unstable = import inputs.nixpkgs-unstable { inherit system; };
|
||||
};
|
||||
|
||||
checks =
|
||||
let
|
||||
machinesPerSystem = {
|
||||
aarch64-linux = [ ];
|
||||
x86_64-linux = [
|
||||
"miom-1"
|
||||
];
|
||||
};
|
||||
nixosMachines = inputs.nixpkgs.lib.mapAttrs' (n: inputs.nixpkgs.lib.nameValuePair "nixos-${n}") (
|
||||
inputs.nixpkgs.lib.genAttrs (machinesPerSystem.${system} or [ ]) (
|
||||
name: self.nixosConfigurations.${name}.config.system.build.toplevel
|
||||
)
|
||||
);
|
||||
in nixosMachines;
|
||||
|
||||
devShells.default = pkgs.mkShell {
|
||||
buildInputs = with pkgs; [
|
||||
deploy-rs
|
||||
agenix
|
||||
age-plugin-yubikey
|
||||
opentofu
|
||||
terraform-ls
|
||||
];
|
||||
};
|
||||
|
||||
devShells.ci = pkgs.mkShell { buildInputs = with pkgs; [ nodejs_22 ]; };
|
||||
};
|
||||
|
||||
flake = {
|
||||
checks = builtins.mapAttrs (
|
||||
system: deployLib: deployLib.deployChecks self.deploy
|
||||
) inputs.deploy-rs.lib;
|
||||
|
||||
formatter."x86_64-linux" = inputs.nixpkgs.legacyPackages."x86_64-linux".nixfmt-rfc-style;
|
||||
|
||||
deploy.nodes = self.lib.deploy.mkDeployNodes self.nixosConfigurations {
|
||||
cassiopeia = {
|
||||
hostname = "cassiopeia.staging.momo.koeln";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
21
staging/hosts/_template/configuration.nix
Normal file
21
staging/hosts/_template/configuration.nix
Normal file
|
@ -0,0 +1,21 @@
|
|||
{ config, lib, ... }:
|
||||
{
|
||||
boot.kernelParams = [ "ip=dhcp" ];
|
||||
boot.loader = {
|
||||
grub.enable = false;
|
||||
systemd-boot.enable = true;
|
||||
};
|
||||
|
||||
networking = {
|
||||
useDHCP = false;
|
||||
interfaces.enp3s0 = {
|
||||
useDHCP = true;
|
||||
};
|
||||
};
|
||||
|
||||
services.openssh.openFirewall = true;
|
||||
|
||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
||||
system.stateVersion = "24.11";
|
||||
}
|
9
staging/hosts/_template/default.nix
Normal file
9
staging/hosts/_template/default.nix
Normal file
|
@ -0,0 +1,9 @@
|
|||
{ modulesPath, ... }:
|
||||
{
|
||||
imports = [
|
||||
(modulesPath + "/profiles/qemu-guest.nix")
|
||||
|
||||
./configuration.nix
|
||||
./disko-config.nix
|
||||
];
|
||||
}
|
65
staging/hosts/_template/disko-config.nix
Normal file
65
staging/hosts/_template/disko-config.nix
Normal file
|
@ -0,0 +1,65 @@
|
|||
{ ... }:
|
||||
{
|
||||
disko.devices = {
|
||||
disk.main = {
|
||||
device = "/dev/sda";
|
||||
type = "disk";
|
||||
content = {
|
||||
type = "gpt";
|
||||
partitions = {
|
||||
esp = {
|
||||
name = "ESP";
|
||||
size = "500M";
|
||||
type = "EF00";
|
||||
content = {
|
||||
type = "filesystem";
|
||||
format = "vfat";
|
||||
mountOptions = [ "umask=0077" ];
|
||||
mountpoint = "/boot";
|
||||
};
|
||||
};
|
||||
luks = {
|
||||
name = "luks";
|
||||
size = "100%";
|
||||
content = {
|
||||
type = "luks";
|
||||
name = "cryptroot";
|
||||
settings = {
|
||||
allowDiscards = true;
|
||||
};
|
||||
content = {
|
||||
type = "lvm_pv";
|
||||
vg = "vg0";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
lvm_vg = {
|
||||
vg0 = {
|
||||
type = "lvm_vg";
|
||||
lvs = {
|
||||
swap = {
|
||||
size = "8192M";
|
||||
content = {
|
||||
type = "swap";
|
||||
};
|
||||
};
|
||||
root = {
|
||||
size = "80%FREE";
|
||||
content = {
|
||||
type = "filesystem";
|
||||
format = "ext4";
|
||||
mountpoint = "/";
|
||||
mountOptions = [
|
||||
"defaults"
|
||||
"discard"
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
18
staging/hosts/cassiopeia/acme.nix
Normal file
18
staging/hosts/cassiopeia/acme.nix
Normal file
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
flake,
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{
|
||||
age.secrets."hostingde-acme-secrets" = {
|
||||
file = "${flake.self}/secrets/momo/hostingde-acme-secrets.age";
|
||||
mode = "400";
|
||||
owner = "acme";
|
||||
};
|
||||
|
||||
momo-cloud.acme = {
|
||||
credentialsFile = config.age.secrets."hostingde-acme-secrets".path;
|
||||
};
|
||||
}
|
45
staging/hosts/cassiopeia/configuration.nix
Normal file
45
staging/hosts/cassiopeia/configuration.nix
Normal file
|
@ -0,0 +1,45 @@
|
|||
{ config, lib, ... }:
|
||||
{
|
||||
momo-cloud.unlock-luks-on-boot.enable = true;
|
||||
momo-cloud.networking.domain = "staging.momo.koeln";
|
||||
|
||||
boot.kernelParams = [ "ip=dhcp" ];
|
||||
boot.loader = {
|
||||
grub.enable = false;
|
||||
systemd-boot.enable = true;
|
||||
};
|
||||
|
||||
networking = {
|
||||
hostName = "cassiopeia";
|
||||
useDHCP = false;
|
||||
enableIPv6 = true;
|
||||
|
||||
interfaces.enp3s0 = {
|
||||
ipv4.addresses = [
|
||||
{
|
||||
address = "80.244.242.6";
|
||||
prefixLength = 29;
|
||||
}
|
||||
];
|
||||
ipv6.addresses = [
|
||||
{
|
||||
address = "2001:4d88:1ffa:26::6";
|
||||
prefixLength = 64;
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
defaultGateway = "80.244.242.1";
|
||||
defaultGateway6 = "2001:4d88:1ffa:26::1";
|
||||
nameservers = [
|
||||
"95.129.51.51"
|
||||
"80.244.244.244"
|
||||
];
|
||||
};
|
||||
|
||||
services.openssh.openFirewall = true;
|
||||
|
||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
||||
system.stateVersion = "24.05";
|
||||
}
|
19
staging/hosts/cassiopeia/default.nix
Normal file
19
staging/hosts/cassiopeia/default.nix
Normal file
|
@ -0,0 +1,19 @@
|
|||
{ modulesPath, ... }:
|
||||
{
|
||||
imports = [
|
||||
(modulesPath + "/profiles/qemu-guest.nix")
|
||||
|
||||
./configuration.nix
|
||||
./disko-config.nix
|
||||
./wireguard.nix
|
||||
|
||||
./smtp-settings.nix
|
||||
|
||||
./acme.nix
|
||||
./kanidm.nix
|
||||
./monitoring.nix
|
||||
./nextcloud.nix
|
||||
./nextcloud-signaling.nix
|
||||
./paperless.nix
|
||||
];
|
||||
}
|
65
staging/hosts/cassiopeia/disko-config.nix
Normal file
65
staging/hosts/cassiopeia/disko-config.nix
Normal file
|
@ -0,0 +1,65 @@
|
|||
{ ... }:
|
||||
{
|
||||
disko.devices = {
|
||||
disk.main = {
|
||||
device = "/dev/sda";
|
||||
type = "disk";
|
||||
content = {
|
||||
type = "gpt";
|
||||
partitions = {
|
||||
esp = {
|
||||
name = "ESP";
|
||||
size = "500M";
|
||||
type = "EF00";
|
||||
content = {
|
||||
type = "filesystem";
|
||||
format = "vfat";
|
||||
mountOptions = [ "umask=0077" ];
|
||||
mountpoint = "/boot";
|
||||
};
|
||||
};
|
||||
luks = {
|
||||
name = "luks";
|
||||
size = "100%";
|
||||
content = {
|
||||
type = "luks";
|
||||
name = "cryptroot";
|
||||
settings = {
|
||||
allowDiscards = true;
|
||||
};
|
||||
content = {
|
||||
type = "lvm_pv";
|
||||
vg = "vg0";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
lvm_vg = {
|
||||
vg0 = {
|
||||
type = "lvm_vg";
|
||||
lvs = {
|
||||
swap = {
|
||||
size = "8192M";
|
||||
content = {
|
||||
type = "swap";
|
||||
};
|
||||
};
|
||||
root = {
|
||||
size = "80%FREE";
|
||||
content = {
|
||||
type = "filesystem";
|
||||
format = "ext4";
|
||||
mountpoint = "/";
|
||||
mountOptions = [
|
||||
"defaults"
|
||||
"discard"
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
25
staging/hosts/cassiopeia/kanidm.nix
Normal file
25
staging/hosts/cassiopeia/kanidm.nix
Normal file
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
flake,
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{
|
||||
age.secrets."kanidm-admin-password" = {
|
||||
file = "${flake.self}/secrets/staging/kanidm-admin-password.age";
|
||||
mode = "400";
|
||||
owner = "kanidm";
|
||||
};
|
||||
age.secrets."kanidm-idm-admin-password" = {
|
||||
file = "${flake.self}/secrets/staging/kanidm-idm-admin-password.age";
|
||||
mode = "400";
|
||||
owner = "kanidm";
|
||||
};
|
||||
|
||||
momo-cloud.authentication = {
|
||||
enable = true;
|
||||
adminPasswordFile = config.age.secrets."kanidm-admin-password".path;
|
||||
idmAdminPasswordFile = config.age.secrets."kanidm-idm-admin-password".path;
|
||||
};
|
||||
}
|
38
staging/hosts/cassiopeia/monitoring.nix
Normal file
38
staging/hosts/cassiopeia/monitoring.nix
Normal file
|
@ -0,0 +1,38 @@
|
|||
{
|
||||
flake,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
{
|
||||
age.secrets.alloy-basic-auth-password = {
|
||||
file = "${flake.self}/secrets/staging/alloy-basic-auth-password.age";
|
||||
path = "/etc/alloy/secrets.alloy";
|
||||
symlink = false;
|
||||
mode = "400";
|
||||
};
|
||||
|
||||
momo-cloud.monitoring-client = {
|
||||
enable = true;
|
||||
basicAuthPasswordFile = config.age.secrets."alloy-basic-auth-password".path;
|
||||
};
|
||||
|
||||
age.secrets.grafana-oidc-secret = {
|
||||
file = "${flake.self}/secrets/staging/grafana-oidc-secret.age";
|
||||
owner = "grafana";
|
||||
group = "kanidm";
|
||||
mode = "440";
|
||||
};
|
||||
|
||||
age.secrets.grafana-admin-password = {
|
||||
file = "${flake.self}/secrets/staging/grafana-admin-password.age";
|
||||
owner = "grafana";
|
||||
mode = "400";
|
||||
};
|
||||
|
||||
momo-cloud.monitoring-server = {
|
||||
enable = true;
|
||||
loki.basicAuth = "loki:$2y$05$xpbTP5qcRwq4nPG6u9wdZOMvzHznBTZxRPMy/DjUbOwsyj66owxHG";
|
||||
grafana.oidcSecretFile = config.age.secrets."grafana-oidc-secret".path;
|
||||
grafana.adminPasswordFile = config.age.secrets."grafana-admin-password".path;
|
||||
};
|
||||
}
|
61
staging/hosts/cassiopeia/nextcloud-signaling.nix
Normal file
61
staging/hosts/cassiopeia/nextcloud-signaling.nix
Normal file
|
@ -0,0 +1,61 @@
|
|||
{ config, flake, ... }:
|
||||
|
||||
{
|
||||
age.secrets."signaling-nextcloud-secret" = {
|
||||
file = "${flake.self}/secrets/staging/signaling-nextcloud-secret.age";
|
||||
mode = "400";
|
||||
owner = "turnserver";
|
||||
group = "nextcloud";
|
||||
};
|
||||
|
||||
age.secrets."signaling-internal-secret" = {
|
||||
file = "${flake.self}/secrets/staging/signaling-internal-secret.age";
|
||||
mode = "400";
|
||||
owner = "turnserver";
|
||||
};
|
||||
|
||||
age.secrets."janus-api-key" = {
|
||||
file = "${flake.self}/secrets/staging/janus-api-key.age";
|
||||
mode = "400";
|
||||
owner = "janus";
|
||||
group = "turnserver";
|
||||
};
|
||||
|
||||
age.secrets."signaling-block-key" = {
|
||||
file = "${flake.self}/secrets/staging/signaling-block-key.age";
|
||||
mode = "400";
|
||||
owner = "turnserver";
|
||||
};
|
||||
|
||||
age.secrets."signaling-hash-key" = {
|
||||
file = "${flake.self}/secrets/staging/signaling-hash-key.age";
|
||||
mode = "400";
|
||||
owner = "turnserver";
|
||||
};
|
||||
|
||||
age.secrets."coturn-static-auth-secret" = {
|
||||
file = "${flake.self}/secrets/staging/coturn_static_auth_secret.age";
|
||||
mode = "400";
|
||||
owner = "turnserver";
|
||||
group = "nextcloud";
|
||||
};
|
||||
|
||||
momo-cloud.nextcloud-signaling = {
|
||||
enable = true;
|
||||
internalSecretFile = config.age.secrets."signaling-internal-secret".path;
|
||||
hashKeyFile = config.age.secrets."signaling-hash-key".path;
|
||||
blockKeyFile = config.age.secrets."signaling-block-key".path;
|
||||
janusApiKeyFile = config.age.secrets."janus-api-key".path;
|
||||
turnSecretFile = config.age.secrets."coturn-static-auth-secret".path;
|
||||
nextcloudSecretFile = config.age.secrets."signaling-nextcloud-secret".path;
|
||||
};
|
||||
momo-cloud.coturn.staticAuthSecretFile = config.age.secrets."coturn-static-auth-secret".path;
|
||||
|
||||
momo-cloud.nextcloud.talk = {
|
||||
enable = true;
|
||||
coturnStaticAuthSecretFile = config.age.secrets."coturn-static-auth-secret".path;
|
||||
signalingSecretFile = config.age.secrets."signaling-nextcloud-secret".path;
|
||||
};
|
||||
|
||||
momo-cloud.coturn.interface = "enp3s0";
|
||||
}
|
34
staging/hosts/cassiopeia/nextcloud.nix
Normal file
34
staging/hosts/cassiopeia/nextcloud.nix
Normal file
|
@ -0,0 +1,34 @@
|
|||
{
|
||||
flake,
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{
|
||||
age.secrets."nextcloud-secrets" = {
|
||||
file = "${flake.self}/secrets/staging/nextcloud-secrets.age";
|
||||
mode = "400";
|
||||
owner = "nextcloud";
|
||||
};
|
||||
|
||||
age.secrets."nextcloud-admin-pass" = {
|
||||
file = "${flake.self}/secrets/staging/nextcloud-admin-pass.age";
|
||||
mode = "400";
|
||||
owner = "nextcloud";
|
||||
};
|
||||
|
||||
age.secrets."nextcloud-oidc-secret" = {
|
||||
file = "${flake.self}/secrets/staging/nextcloud-oidc-secret.age";
|
||||
mode = "440";
|
||||
owner = "nextcloud";
|
||||
group = "kanidm";
|
||||
};
|
||||
|
||||
momo-cloud.nextcloud = {
|
||||
enable = true;
|
||||
adminPasswordFile = config.age.secrets."nextcloud-admin-pass".path;
|
||||
secretsFile = config.age.secrets."nextcloud-secrets".path;
|
||||
oidcSecretFile = config.age.secrets."nextcloud-oidc-secret".path;
|
||||
};
|
||||
}
|
34
staging/hosts/cassiopeia/paperless.nix
Normal file
34
staging/hosts/cassiopeia/paperless.nix
Normal file
|
@ -0,0 +1,34 @@
|
|||
{
|
||||
flake,
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
{
|
||||
age.secrets."paperless.env" = {
|
||||
file = "${flake.self}/secrets/staging/paperless.env.age";
|
||||
mode = "400";
|
||||
owner = "paperless";
|
||||
};
|
||||
|
||||
age.secrets."kanidm-paperless-secret" = {
|
||||
file = "${flake.self}/secrets/staging/kanidm-paperless-secret.age";
|
||||
mode = "400";
|
||||
owner = "kanidm";
|
||||
};
|
||||
|
||||
age.secrets."paperless-superuser-password" = {
|
||||
file = "${flake.self}/secrets/staging/paperless-superuser-password.age";
|
||||
mode = "400";
|
||||
owner = "kanidm";
|
||||
};
|
||||
|
||||
momo-cloud.paperless = {
|
||||
enable = true;
|
||||
setup = false;
|
||||
envFile = config.age.secrets."paperless.env".path;
|
||||
oidcSecretFile = config.age.secrets."kanidm-paperless-secret".path;
|
||||
superuserPasswordFile = config.age.secrets."paperless-superuser-password".path;
|
||||
};
|
||||
}
|
15
staging/hosts/cassiopeia/smtp-settings.nix
Normal file
15
staging/hosts/cassiopeia/smtp-settings.nix
Normal file
|
@ -0,0 +1,15 @@
|
|||
{ flake, config, ... }:
|
||||
|
||||
{
|
||||
age.secrets."email-smtp-password" = {
|
||||
file = "${flake.self}/secrets/staging/email-smtp-password.age";
|
||||
owner = "grafana";
|
||||
};
|
||||
|
||||
momo-cloud.email-smtp = {
|
||||
host = "mail.momo.koeln";
|
||||
port = "465";
|
||||
username = "admins@momo.koeln"; # TODO SECURITY: do use separate staging email account
|
||||
passwordFile = config.age.secrets."email-smtp-password".path;
|
||||
};
|
||||
}
|
20
staging/hosts/cassiopeia/wireguard.nix
Normal file
20
staging/hosts/cassiopeia/wireguard.nix
Normal file
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
config,
|
||||
flake,
|
||||
...
|
||||
}:
|
||||
let
|
||||
wireguardIPv4 = "10.30.31.1";
|
||||
wireguardIPv6 = "fd00:3031:3031:3031:3031:1::";
|
||||
in
|
||||
{
|
||||
age.secrets.wg-private-key.file = "${flake.self}/secrets/staging/cassiopeia-wg-private-key.age";
|
||||
|
||||
momo-cloud.wireguard = {
|
||||
enable = true;
|
||||
openFirewall = true;
|
||||
privateKeyFile = config.age.secrets.wg-private-key.path;
|
||||
ipv4.address = wireguardIPv4;
|
||||
ipv6.address = wireguardIPv6;
|
||||
};
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue