Merge branch 'master' into postgresql-socket-in-run
This commit is contained in:
@@ -165,6 +165,8 @@ let
|
||||
else
|
||||
"# No refind for ${targetArch}"
|
||||
;
|
||||
|
||||
grubPkgs = if config.boot.loader.grub.forcei686 then pkgs.pkgsi686Linux else pkgs;
|
||||
|
||||
grubMenuCfg = ''
|
||||
#
|
||||
@@ -241,7 +243,7 @@ let
|
||||
# Modules that may or may not be available per-platform.
|
||||
echo "Adding additional modules:"
|
||||
for mod in efi_uga; do
|
||||
if [ -f ${pkgs.grub2_efi}/lib/grub/${pkgs.grub2_efi.grubTarget}/$mod.mod ]; then
|
||||
if [ -f ${grubPkgs.grub2_efi}/lib/grub/${grubPkgs.grub2_efi.grubTarget}/$mod.mod ]; then
|
||||
echo " - $mod"
|
||||
MODULES+=" $mod"
|
||||
fi
|
||||
@@ -249,9 +251,9 @@ let
|
||||
|
||||
# Make our own efi program, we can't rely on "grub-install" since it seems to
|
||||
# probe for devices, even with --skip-fs-probe.
|
||||
${pkgs.grub2_efi}/bin/grub-mkimage -o $out/EFI/boot/boot${targetArch}.efi -p /EFI/boot -O ${pkgs.grub2_efi.grubTarget} \
|
||||
${grubPkgs.grub2_efi}/bin/grub-mkimage -o $out/EFI/boot/boot${targetArch}.efi -p /EFI/boot -O ${grubPkgs.grub2_efi.grubTarget} \
|
||||
$MODULES
|
||||
cp ${pkgs.grub2_efi}/share/grub/unicode.pf2 $out/EFI/boot/
|
||||
cp ${grubPkgs.grub2_efi}/share/grub/unicode.pf2 $out/EFI/boot/
|
||||
|
||||
cat <<EOF > $out/EFI/boot/grub.cfg
|
||||
|
||||
@@ -362,7 +364,7 @@ let
|
||||
|
||||
# Name used by UEFI for architectures.
|
||||
targetArch =
|
||||
if pkgs.stdenv.isi686 then
|
||||
if pkgs.stdenv.isi686 || config.boot.loader.grub.forcei686 then
|
||||
"ia32"
|
||||
else if pkgs.stdenv.isx86_64 then
|
||||
"x64"
|
||||
@@ -506,7 +508,7 @@ in
|
||||
# here and it causes a cyclic dependency.
|
||||
boot.loader.grub.enable = false;
|
||||
|
||||
environment.systemPackages = [ pkgs.grub2 pkgs.grub2_efi ]
|
||||
environment.systemPackages = [ grubPkgs.grub2 grubPkgs.grub2_efi ]
|
||||
++ optional canx86BiosBoot pkgs.syslinux
|
||||
;
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
./config/users-groups.nix
|
||||
./config/vpnc.nix
|
||||
./config/zram.nix
|
||||
./hardware/acpilight.nix
|
||||
./hardware/all-firmware.nix
|
||||
./hardware/bladeRF.nix
|
||||
./hardware/brightnessctl.nix
|
||||
@@ -136,6 +137,7 @@
|
||||
./programs/vim.nix
|
||||
./programs/wavemon.nix
|
||||
./programs/way-cooler.nix
|
||||
./programs/waybar.nix
|
||||
./programs/wireshark.nix
|
||||
./programs/xfs_quota.nix
|
||||
./programs/xonsh.nix
|
||||
@@ -310,6 +312,7 @@
|
||||
./services/hardware/ratbagd.nix
|
||||
./services/hardware/sane.nix
|
||||
./services/hardware/sane_extra_backends/brscan4.nix
|
||||
./services/hardware/sane_extra_backends/dsseries.nix
|
||||
./services/hardware/tcsd.nix
|
||||
./services/hardware/tlp.nix
|
||||
./services/hardware/thinkfan.nix
|
||||
@@ -577,6 +580,7 @@
|
||||
./services/networking/keepalived/default.nix
|
||||
./services/networking/keybase.nix
|
||||
./services/networking/kippo.nix
|
||||
./services/networking/knot.nix
|
||||
./services/networking/kresd.nix
|
||||
./services/networking/lambdabot.nix
|
||||
./services/networking/libreswan.nix
|
||||
@@ -764,6 +768,7 @@
|
||||
./services/web-servers/nginx/default.nix
|
||||
./services/web-servers/nginx/gitweb.nix
|
||||
./services/web-servers/phpfpm/default.nix
|
||||
./services/web-servers/unit/default.nix
|
||||
./services/web-servers/shellinabox.nix
|
||||
./services/web-servers/tomcat.nix
|
||||
./services/web-servers/traefik.nix
|
||||
@@ -871,9 +876,11 @@
|
||||
./tasks/trackpoint.nix
|
||||
./tasks/powertop.nix
|
||||
./testing/service-runner.nix
|
||||
./virtualisation/anbox.nix
|
||||
./virtualisation/container-config.nix
|
||||
./virtualisation/containers.nix
|
||||
./virtualisation/docker.nix
|
||||
./virtualisation/docker-containers.nix
|
||||
./virtualisation/ecs-agent.nix
|
||||
./virtualisation/libvirtd.nix
|
||||
./virtualisation/lxc.nix
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
{ lib, pkgs, config, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
{
|
||||
options.programs.waybar = {
|
||||
enable = mkEnableOption "waybar";
|
||||
};
|
||||
|
||||
config = mkIf config.programs.waybar.enable {
|
||||
systemd.user.services.waybar = {
|
||||
description = "Waybar as systemd service";
|
||||
wantedBy = [ "graphical-session.target" ];
|
||||
partOf = [ "graphical-session.target" ];
|
||||
script = "${pkgs.waybar}/bin/waybar";
|
||||
};
|
||||
};
|
||||
|
||||
meta.maintainers = [ maintainers.FlorianFranzen ];
|
||||
}
|
||||
@@ -87,9 +87,9 @@
|
||||
|
||||
<para>
|
||||
<emphasis>Please keep in mind that this is not compatible with
|
||||
<literal>programs.zsh.ohMyZsh.custom</literal> as it requires an immutable store
|
||||
path while <literal>custom</literal> shall remain mutable! An evaluation
|
||||
failure will be thrown if both <literal>custom</literal> and
|
||||
<literal>programs.zsh.ohMyZsh.custom</literal> as it requires an immutable
|
||||
store path while <literal>custom</literal> shall remain mutable! An
|
||||
evaluation failure will be thrown if both <literal>custom</literal> and
|
||||
<literal>customPkgs</literal> are set.</emphasis>
|
||||
</para>
|
||||
</section>
|
||||
|
||||
@@ -79,6 +79,33 @@ in
|
||||
type = types.lines;
|
||||
};
|
||||
|
||||
histSize = mkOption {
|
||||
default = 2000;
|
||||
description = ''
|
||||
Change history size.
|
||||
'';
|
||||
type = types.int;
|
||||
};
|
||||
|
||||
histFile = mkOption {
|
||||
default = "$HOME/.zsh_history";
|
||||
description = ''
|
||||
Change history file.
|
||||
'';
|
||||
type = types.str;
|
||||
};
|
||||
|
||||
setOptions = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [
|
||||
"HIST_IGNORE_DUPS" "SHARE_HISTORY" "HIST_FCNTL_LOCK"
|
||||
];
|
||||
example = [ "EXTENDED_HISTORY" "RM_STAR_WAIT" ];
|
||||
description = ''
|
||||
Configure zsh options.
|
||||
'';
|
||||
};
|
||||
|
||||
enableCompletion = mkOption {
|
||||
default = true;
|
||||
description = ''
|
||||
@@ -162,12 +189,12 @@ in
|
||||
|
||||
. /etc/zinputrc
|
||||
|
||||
# history defaults
|
||||
SAVEHIST=2000
|
||||
HISTSIZE=2000
|
||||
HISTFILE=$HOME/.zsh_history
|
||||
# Don't export these, otherwise other shells (bash) will try to use same histfile
|
||||
SAVEHIST=${toString cfg.histSize}
|
||||
HISTSIZE=${toString cfg.histSize}
|
||||
HISTFILE=${cfg.histFile}
|
||||
|
||||
setopt HIST_IGNORE_DUPS SHARE_HISTORY HIST_FCNTL_LOCK
|
||||
${optionalString (cfg.setOptions != []) "setopt ${concatStringsSep " " cfg.setOptions}"}
|
||||
|
||||
HELPDIR="${pkgs.zsh}/share/zsh/$ZSH_VERSION/help"
|
||||
|
||||
|
||||
@@ -199,10 +199,10 @@ in {
|
||||
|
||||
package = mkOption {
|
||||
type = types.package;
|
||||
default = pkgs.pythonPackages.buildbot-full;
|
||||
defaultText = "pkgs.pythonPackages.buildbot-full";
|
||||
default = pkgs.python3Packages.buildbot-full;
|
||||
defaultText = "pkgs.python3Packages.buildbot-full";
|
||||
description = "Package to use for buildbot.";
|
||||
example = literalExample "pkgs.python3Packages.buildbot-full";
|
||||
example = literalExample "pkgs.python3Packages.buildbot";
|
||||
};
|
||||
|
||||
packages = mkOption {
|
||||
|
||||
@@ -118,10 +118,10 @@ in {
|
||||
|
||||
package = mkOption {
|
||||
type = types.package;
|
||||
default = pkgs.pythonPackages.buildbot-worker;
|
||||
defaultText = "pkgs.pythonPackages.buildbot-worker";
|
||||
default = pkgs.python3Packages.buildbot-worker;
|
||||
defaultText = "pkgs.python3Packages.buildbot-worker";
|
||||
description = "Package to use for buildbot worker.";
|
||||
example = literalExample "pkgs.python3Packages.buildbot-worker";
|
||||
example = literalExample "pkgs.python2Packages.buildbot-worker";
|
||||
};
|
||||
|
||||
packages = mkOption {
|
||||
|
||||
@@ -9,6 +9,8 @@ let
|
||||
in
|
||||
{
|
||||
|
||||
meta.maintainers = pkgs.pantheon.maintainers;
|
||||
|
||||
###### interface
|
||||
|
||||
options = {
|
||||
|
||||
@@ -6,6 +6,8 @@ with lib;
|
||||
|
||||
{
|
||||
|
||||
meta.maintainers = pkgs.pantheon.maintainers;
|
||||
|
||||
###### interface
|
||||
|
||||
options = {
|
||||
|
||||
@@ -6,6 +6,8 @@ with lib;
|
||||
|
||||
{
|
||||
|
||||
meta.maintainers = pkgs.pantheon.maintainers;
|
||||
|
||||
###### interface
|
||||
|
||||
options = {
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
{
|
||||
options = {
|
||||
|
||||
hardware.sane.dsseries.enable =
|
||||
mkEnableOption "Brother DSSeries scan backend" // {
|
||||
description = ''
|
||||
When enabled, will automatically register the "dsseries" SANE backend.
|
||||
|
||||
This supports the Brother DSmobile scanner series, including the
|
||||
DS-620, DS-720D, DS-820W, and DS-920DW scanners.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf (config.hardware.sane.enable && config.hardware.sane.dsseries.enable) {
|
||||
|
||||
hardware.sane.extraBackends = [ pkgs.dsseries ];
|
||||
services.udev.packages = [ pkgs.dsseries ];
|
||||
boot.kernelModules = [ "sg" ];
|
||||
|
||||
};
|
||||
}
|
||||
@@ -14,9 +14,10 @@ let
|
||||
log.fields.service = "registry";
|
||||
storage = {
|
||||
cache.blobdescriptor = blobCache;
|
||||
filesystem.rootdirectory = cfg.storagePath;
|
||||
delete.enabled = cfg.enableDelete;
|
||||
};
|
||||
} // (if cfg.storagePath != null
|
||||
then { filesystem.rootdirectory = cfg.storagePath; }
|
||||
else {});
|
||||
http = {
|
||||
addr = "${cfg.listenAddress}:${builtins.toString cfg.port}";
|
||||
headers.X-Content-Type-Options = ["nosniff"];
|
||||
@@ -61,9 +62,12 @@ in {
|
||||
};
|
||||
|
||||
storagePath = mkOption {
|
||||
type = types.path;
|
||||
type = types.nullOr types.path;
|
||||
default = "/var/lib/docker-registry";
|
||||
description = "Docker registry storage path.";
|
||||
description = ''
|
||||
Docker registry storage path for the filesystem storage backend. Set to
|
||||
null to configure another backend via extraConfig.
|
||||
'';
|
||||
};
|
||||
|
||||
enableDelete = mkOption {
|
||||
@@ -140,9 +144,12 @@ in {
|
||||
startAt = optional cfg.enableGarbageCollect cfg.garbageCollectDates;
|
||||
};
|
||||
|
||||
users.users.docker-registry = {
|
||||
createHome = true;
|
||||
home = cfg.storagePath;
|
||||
};
|
||||
users.users.docker-registry =
|
||||
if cfg.storagePath != null
|
||||
then {
|
||||
createHome = true;
|
||||
home = cfg.storagePath;
|
||||
}
|
||||
else {};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -235,7 +235,7 @@ in {
|
||||
'';
|
||||
script = ''
|
||||
export DD_API_KEY=$(head -n 1 ${cfg.apiKeyFile})
|
||||
exec ${datadogPkg}/bin/agent start -c /etc/datadog-agent/datadog.yaml
|
||||
exec ${datadogPkg}/bin/agent run -c /etc/datadog-agent/datadog.yaml
|
||||
'';
|
||||
serviceConfig.PermissionsStartOnly = true;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.services.knot;
|
||||
|
||||
configFile = pkgs.writeText "knot.conf" cfg.extraConfig;
|
||||
socketFile = "/run/knot/knot.sock";
|
||||
|
||||
knotConfCheck = file: pkgs.runCommand "knot-config-checked"
|
||||
{ buildInputs = [ cfg.package ]; } ''
|
||||
ln -s ${configFile} $out
|
||||
knotc --config=${configFile} conf-check
|
||||
'';
|
||||
|
||||
knot-cli-wrappers = pkgs.stdenv.mkDerivation {
|
||||
name = "knot-cli-wrappers";
|
||||
buildInputs = [ pkgs.makeWrapper ];
|
||||
buildCommand = ''
|
||||
mkdir -p $out/bin
|
||||
makeWrapper ${cfg.package}/bin/knotc "$out/bin/knotc" \
|
||||
--add-flags "--config=${configFile}" \
|
||||
--add-flags "--socket=${socketFile}"
|
||||
makeWrapper ${cfg.package}/bin/keymgr "$out/bin/keymgr" \
|
||||
--add-flags "--config=${configFile}"
|
||||
for executable in kdig khost kjournalprint knsec3hash knsupdate kzonecheck
|
||||
do
|
||||
ln -s "${cfg.package}/bin/$executable" "$out/bin/$executable"
|
||||
done
|
||||
mkdir -p "$out/share"
|
||||
ln -s '${cfg.package}/share/man' "$out/share/"
|
||||
'';
|
||||
};
|
||||
in {
|
||||
options = {
|
||||
services.knot = {
|
||||
enable = mkEnableOption "Knot authoritative-only DNS server";
|
||||
|
||||
extraArgs = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [];
|
||||
description = ''
|
||||
List of additional command line paramters for knotd
|
||||
'';
|
||||
};
|
||||
|
||||
extraConfig = mkOption {
|
||||
type = types.lines;
|
||||
default = "";
|
||||
description = ''
|
||||
Extra lines to be added verbatim to knot.conf
|
||||
'';
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
type = types.package;
|
||||
default = pkgs.knot-dns;
|
||||
description = ''
|
||||
Which Knot DNS package to use
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf config.services.knot.enable {
|
||||
systemd.services.knot = {
|
||||
unitConfig.Documentation = "man:knotd(8) man:knot.conf(5) man:knotc(8) https://www.knot-dns.cz/docs/${cfg.package.version}/html/";
|
||||
description = cfg.package.meta.description;
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
wants = [ "network.target" ];
|
||||
after = ["network.target" ];
|
||||
|
||||
serviceConfig = {
|
||||
Type = "notify";
|
||||
ExecStart = "${cfg.package}/bin/knotd --config=${knotConfCheck configFile} --socket=${socketFile} ${concatStringsSep " " cfg.extraArgs}";
|
||||
ExecReload = "${knot-cli-wrappers}/bin/knotc reload";
|
||||
CapabilityBoundingSet = "CAP_NET_BIND_SERVICE CAP_SETPCAP";
|
||||
AmbientCapabilities = "CAP_NET_BIND_SERVICE CAP_SETPCAP";
|
||||
NoNewPrivileges = true;
|
||||
DynamicUser = "yes";
|
||||
RuntimeDirectory = "knot";
|
||||
StateDirectory = "knot";
|
||||
StateDirectoryMode = "0700";
|
||||
PrivateDevices = true;
|
||||
RestrictAddressFamilies = "AF_UNIX AF_INET AF_INET6";
|
||||
SystemCallArchitectures = "native";
|
||||
Restart = "on-abort";
|
||||
};
|
||||
};
|
||||
|
||||
environment.systemPackages = [ knot-cli-wrappers ];
|
||||
};
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ in {
|
||||
startAt = cfg.interval;
|
||||
serviceConfig = {
|
||||
ExecStart =
|
||||
"${pkgs.python3Packages.elasticsearch-curator}/bin/curator" +
|
||||
"${pkgs.elasticsearch-curator}/bin/curator" +
|
||||
" --config ${curatorConfig} ${curatorAction}";
|
||||
};
|
||||
};
|
||||
|
||||
@@ -12,15 +12,15 @@
|
||||
An automatic setup is not suported by Matomo, so you need to configure Matomo
|
||||
itself in the browser-based Matomo setup.
|
||||
</para>
|
||||
|
||||
<section xml:id="module-services-matomo-database-setup">
|
||||
<title>Database Setup</title>
|
||||
|
||||
<para>
|
||||
You also need to configure a MariaDB or MySQL database and -user for Matomo
|
||||
yourself, and enter those credentials in your browser. You can use
|
||||
passwordless database authentication via the UNIX_SOCKET authentication
|
||||
plugin with the following SQL commands:
|
||||
<programlisting>
|
||||
<programlisting>
|
||||
# For MariaDB
|
||||
INSTALL PLUGIN unix_socket SONAME 'auth_socket';
|
||||
CREATE DATABASE matomo;
|
||||
@@ -46,30 +46,32 @@
|
||||
database is not on the same host.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section xml:id="module-services-matomo-archive-processing">
|
||||
<title>Archive Processing</title>
|
||||
|
||||
<para>
|
||||
This module comes with the systemd service <literal>matomo-archive-processing.service</literal>
|
||||
and a timer that automatically triggers archive processing every hour.
|
||||
This means that you can safely
|
||||
This module comes with the systemd service
|
||||
<literal>matomo-archive-processing.service</literal> and a timer that
|
||||
automatically triggers archive processing every hour. This means that you
|
||||
can safely
|
||||
<link xlink:href="https://matomo.org/docs/setup-auto-archiving/#disable-browser-triggers-for-matomo-archiving-and-limit-matomo-reports-to-updating-every-hour">
|
||||
disable browser triggers for Matomo archiving
|
||||
</link> at <literal>Administration > System > General Settings</literal>.
|
||||
disable browser triggers for Matomo archiving </link> at
|
||||
<literal>Administration > System > General Settings</literal>.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
With automatic archive processing, you can now also enable to
|
||||
<link xlink:href="https://matomo.org/docs/privacy/#step-2-delete-old-visitors-logs">
|
||||
delete old visitor logs
|
||||
</link> at <literal>Administration > System > Privacy</literal>,
|
||||
but make sure that you run <literal>systemctl start matomo-archive-processing.service</literal>
|
||||
at least once without errors if you have already collected data before,
|
||||
so that the reports get archived before the source data gets deleted.
|
||||
delete old visitor logs </link> at <literal>Administration > System >
|
||||
Privacy</literal>, but make sure that you run <literal>systemctl start
|
||||
matomo-archive-processing.service</literal> at least once without errors if
|
||||
you have already collected data before, so that the reports get archived
|
||||
before the source data gets deleted.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section xml:id="module-services-matomo-backups">
|
||||
<title>Backup</title>
|
||||
|
||||
<para>
|
||||
You only need to take backups of your MySQL database and the
|
||||
<filename>/var/lib/matomo/config/config.ini.php</filename> file. Use a user
|
||||
@@ -78,9 +80,9 @@
|
||||
<link xlink:href="https://matomo.org/faq/how-to-install/faq_138/" />.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section xml:id="module-services-matomo-issues">
|
||||
<title>Issues</title>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
@@ -97,7 +99,6 @@
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</section>
|
||||
|
||||
<section xml:id="module-services-matomo-other-web-servers">
|
||||
<title>Using other Web Servers than nginx</title>
|
||||
|
||||
|
||||
@@ -4,24 +4,26 @@
|
||||
version="5.0"
|
||||
xml:id="module-services-nextcloud">
|
||||
<title>Nextcloud</title>
|
||||
|
||||
<para>
|
||||
<link xlink:href="https://nextcloud.com/">Nextcloud</link> is an open-source, self-hostable cloud
|
||||
platform. The server setup can be automated using
|
||||
<link linkend="opt-services.nextcloud.enable">services.nextcloud</link>. A desktop client is packaged
|
||||
at <literal>pkgs.nextcloud-client</literal>.
|
||||
<link xlink:href="https://nextcloud.com/">Nextcloud</link> is an open-source,
|
||||
self-hostable cloud platform. The server setup can be automated using
|
||||
<link linkend="opt-services.nextcloud.enable">services.nextcloud</link>. A
|
||||
desktop client is packaged at <literal>pkgs.nextcloud-client</literal>.
|
||||
</para>
|
||||
|
||||
<section xml:id="module-services-nextcloud-basic-usage">
|
||||
<title>Basic usage</title>
|
||||
|
||||
<para>
|
||||
Nextcloud is a PHP-based application which requires an HTTP server
|
||||
(<literal><link linkend="opt-services.nextcloud.enable">services.nextcloud</link></literal> optionally supports
|
||||
<literal><link linkend="opt-services.nginx.enable">services.nginx</link></literal>) and a database
|
||||
(it's recommended to use <literal><link linkend="opt-services.postgresql.enable">services.postgresql</link></literal>).
|
||||
(<literal><link linkend="opt-services.nextcloud.enable">services.nextcloud</link></literal>
|
||||
optionally supports
|
||||
<literal><link linkend="opt-services.nginx.enable">services.nginx</link></literal>)
|
||||
and a database (it's recommended to use
|
||||
<literal><link linkend="opt-services.postgresql.enable">services.postgresql</link></literal>).
|
||||
</para>
|
||||
|
||||
<para>
|
||||
A very basic configuration may look like this:
|
||||
A very basic configuration may look like this:
|
||||
<programlisting>{ pkgs, ... }:
|
||||
{
|
||||
services.nextcloud = {
|
||||
@@ -55,45 +57,59 @@
|
||||
<link linkend="opt-networking.firewall.allowedTCPPorts">networking.firewall.allowedTCPPorts</link> = [ 80 443 ];
|
||||
}</programlisting>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The options <literal>hostName</literal> and <literal>nginx.enable</literal> are used internally to configure an
|
||||
HTTP server using <literal><link xlink:href="https://php-fpm.org/">PHP-FPM</link></literal> and <literal>nginx</literal>.
|
||||
The <literal>config</literal> attribute set is used for the <literal>config.php</literal> which is used
|
||||
for the application's configuration.
|
||||
<emphasis>Beware: this isn't entirely pure since the config is modified by the application's runtime!</emphasis>
|
||||
The options <literal>hostName</literal> and <literal>nginx.enable</literal>
|
||||
are used internally to configure an HTTP server using
|
||||
<literal><link xlink:href="https://php-fpm.org/">PHP-FPM</link></literal>
|
||||
and <literal>nginx</literal>. The <literal>config</literal> attribute set is
|
||||
used for the <literal>config.php</literal> which is used for the
|
||||
application's configuration. <emphasis>Beware: this isn't entirely pure
|
||||
since the config is modified by the application's runtime!</emphasis>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
In case the application serves multiple hosts (those are checked with
|
||||
<literal><link xlink:href="http://php.net/manual/en/reserved.variables.server.php">$_SERVER['HTTP_HOST']</link></literal>)
|
||||
those can be added using
|
||||
<literal><link linkend="opt-services.nextcloud.config.extraTrustedDomains">services.nextcloud.config.extraTrustedDomains</link></literal>.
|
||||
In case the application serves multiple hosts (those are checked with
|
||||
<literal><link xlink:href="http://php.net/manual/en/reserved.variables.server.php">$_SERVER['HTTP_HOST']</link></literal>)
|
||||
those can be added using
|
||||
<literal><link linkend="opt-services.nextcloud.config.extraTrustedDomains">services.nextcloud.config.extraTrustedDomains</link></literal>.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section xml:id="module-services-nextcloud-pitfalls-during-upgrade">
|
||||
<title>Pitfalls</title>
|
||||
|
||||
<para>
|
||||
Unfortunately Nextcloud appears to be very stateful when it comes to managing its own configuration. The
|
||||
config file lives in the home directory of the <literal>nextcloud</literal> user (by default
|
||||
<literal>/var/lib/nextcloud/config/config.php</literal>) and is also used to track several
|
||||
states of the application (e.g. whether installed or not).
|
||||
Unfortunately Nextcloud appears to be very stateful when it comes to
|
||||
managing its own configuration. The config file lives in the home directory
|
||||
of the <literal>nextcloud</literal> user (by default
|
||||
<literal>/var/lib/nextcloud/config/config.php</literal>) and is also used to
|
||||
track several states of the application (e.g. whether installed or not).
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Right now changes to the <literal>services.nextcloud.config</literal> attribute set won't take effect
|
||||
after the first install
|
||||
(except <literal><link linkend="opt-services.nextcloud.config.extraTrustedDomains">services.nextcloud.config.extraTrustedDomains</link></literal>) since the actual configuration
|
||||
file is generated by the NextCloud installer which also sets up critical parts such as the database
|
||||
structure.
|
||||
Right now changes to the <literal>services.nextcloud.config</literal>
|
||||
attribute set won't take effect after the first install (except
|
||||
<literal><link linkend="opt-services.nextcloud.config.extraTrustedDomains">services.nextcloud.config.extraTrustedDomains</link></literal>)
|
||||
since the actual configuration file is generated by the NextCloud installer
|
||||
which also sets up critical parts such as the database structure.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
<emphasis>Warning: don't delete <literal>config.php</literal>! This file tracks the application's state and a deletion can cause unwanted side-effects!</emphasis>
|
||||
<emphasis>Warning: don't delete <literal>config.php</literal>! This file
|
||||
tracks the application's state and a deletion can cause unwanted
|
||||
side-effects!</emphasis>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
<emphasis>Warning: don't rerun <literal>nextcloud-occ maintenance:install</literal>! This command tries to install the application and can cause unwanted side-effects!</emphasis>
|
||||
<emphasis>Warning: don't rerun <literal>nextcloud-occ
|
||||
maintenance:install</literal>! This command tries to install the application
|
||||
and can cause unwanted side-effects!</emphasis>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The issues are known and reported in <link xlink:href="https://github.com/NixOS/nixpkgs/issues/49783">#49783</link>, for now it's unfortunately necessary to manually work around these issues.
|
||||
The issues are known and reported in
|
||||
<link xlink:href="https://github.com/NixOS/nixpkgs/issues/49783">#49783</link>,
|
||||
for now it's unfortunately necessary to manually work around these issues.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
</chapter>
|
||||
|
||||
@@ -86,11 +86,19 @@ in with lib; {
|
||||
default = false;
|
||||
description = "Serve and listen only through HTTPS.";
|
||||
};
|
||||
|
||||
videoPaths = mkOption {
|
||||
type = types.listOf types.path;
|
||||
default = [];
|
||||
example = [ "/home/okina/Videos/tehe_pero.webm" ];
|
||||
description = "Videos that will be symlinked into www/videos.";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
security.sudo.enable = cfg.enable;
|
||||
services.postgresql.enable = cfg.enable;
|
||||
services.postgresql.package = pkgs.postgresql_11;
|
||||
services.meguca.passwordFile = mkDefault (pkgs.writeText "meguca-password-file" cfg.password);
|
||||
services.meguca.postgresArgsFile = mkDefault (pkgs.writeText "meguca-postgres-args" cfg.postgresArgs);
|
||||
services.meguca.postgresArgs = mkDefault "user=meguca password=${cfg.password} dbname=meguca sslmode=disable";
|
||||
@@ -102,8 +110,16 @@ in with lib; {
|
||||
|
||||
preStart = ''
|
||||
# Ensure folder exists or create it and links and permissions are correct
|
||||
mkdir -p ${escapeShellArg cfg.dataDir}
|
||||
ln -sf ${pkgs.meguca}/share/meguca/www ${escapeShellArg cfg.dataDir}
|
||||
mkdir -p ${escapeShellArg cfg.dataDir}/www
|
||||
rm -rf ${escapeShellArg cfg.dataDir}/www/videos
|
||||
ln -sf ${pkgs.meguca}/share/meguca/www/* ${escapeShellArg cfg.dataDir}/www
|
||||
unlink ${escapeShellArg cfg.dataDir}/www/videos
|
||||
mkdir -p ${escapeShellArg cfg.dataDir}/www/videos
|
||||
|
||||
for vid in ${escapeShellArg cfg.videoPaths}; do
|
||||
ln -sf $vid ${escapeShellArg cfg.dataDir}/www/videos
|
||||
done
|
||||
|
||||
chmod 750 ${escapeShellArg cfg.dataDir}
|
||||
chown -R meguca:meguca ${escapeShellArg cfg.dataDir}
|
||||
|
||||
|
||||
@@ -197,7 +197,7 @@ let
|
||||
listenString = { addr, port, ssl, extraParameters ? [], ... }:
|
||||
"listen ${addr}:${toString port} "
|
||||
+ optionalString ssl "ssl "
|
||||
+ optionalString vhost.http2 "http2 "
|
||||
+ optionalString (ssl && vhost.http2) "http2 "
|
||||
+ optionalString vhost.default "default_server "
|
||||
+ optionalString (extraParameters != []) (concatStringsSep " " extraParameters)
|
||||
+ ";";
|
||||
@@ -276,6 +276,7 @@ let
|
||||
${optionalString (config.tryFiles != null) "try_files ${config.tryFiles};"}
|
||||
${optionalString (config.root != null) "root ${config.root};"}
|
||||
${optionalString (config.alias != null) "alias ${config.alias};"}
|
||||
${optionalString (config.return != null) "return ${config.return};"}
|
||||
${config.extraConfig}
|
||||
${optionalString (config.proxyPass != null && cfg.recommendedProxySettings) "include ${recommendedProxyConfig};"}
|
||||
}
|
||||
@@ -373,7 +374,7 @@ in
|
||||
preStart = mkOption {
|
||||
type = types.lines;
|
||||
default = ''
|
||||
test -d ${cfg.stateDir}/logs || mkdir -m 750 -p ${cfg.stateDir}/logs
|
||||
test -d ${cfg.stateDir}/logs || mkdir -m 750 -p ${cfg.stateDir}/logs
|
||||
test `stat -c %a ${cfg.stateDir}` = "750" || chmod 750 ${cfg.stateDir}
|
||||
test `stat -c %a ${cfg.stateDir}/logs` = "750" || chmod 750 ${cfg.stateDir}/logs
|
||||
chown -R ${cfg.user}:${cfg.group} ${cfg.stateDir}
|
||||
|
||||
@@ -64,6 +64,15 @@ with lib;
|
||||
'';
|
||||
};
|
||||
|
||||
return = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
example = "301 http://example.com$request_uri;";
|
||||
description = ''
|
||||
Adds a return directive, for e.g. redirections.
|
||||
'';
|
||||
};
|
||||
|
||||
extraConfig = mkOption {
|
||||
type = types.lines;
|
||||
default = "";
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.services.unit;
|
||||
|
||||
configFile = pkgs.writeText "unit.json" cfg.config;
|
||||
|
||||
in {
|
||||
options = {
|
||||
services.unit = {
|
||||
enable = mkEnableOption "Unit App Server";
|
||||
package = mkOption {
|
||||
type = types.package;
|
||||
default = pkgs.unit;
|
||||
defaultText = "pkgs.unit";
|
||||
description = "Unit package to use.";
|
||||
};
|
||||
user = mkOption {
|
||||
type = types.str;
|
||||
default = "unit";
|
||||
description = "User account under which unit runs.";
|
||||
};
|
||||
group = mkOption {
|
||||
type = types.str;
|
||||
default = "unit";
|
||||
description = "Group account under which unit runs.";
|
||||
};
|
||||
stateDir = mkOption {
|
||||
default = "/var/spool/unit";
|
||||
description = "Unit data directory.";
|
||||
};
|
||||
logDir = mkOption {
|
||||
default = "/var/log/unit";
|
||||
description = "Unit log directory.";
|
||||
};
|
||||
config = mkOption {
|
||||
type = types.str;
|
||||
default = ''
|
||||
{
|
||||
"listeners": {},
|
||||
"applications": {}
|
||||
}
|
||||
'';
|
||||
example = literalExample ''
|
||||
{
|
||||
"listeners": {
|
||||
"*:8300": {
|
||||
"application": "example-php-72"
|
||||
}
|
||||
},
|
||||
"applications": {
|
||||
"example-php-72": {
|
||||
"type": "php 7.2",
|
||||
"processes": 4,
|
||||
"user": "nginx",
|
||||
"group": "nginx",
|
||||
"root": "/var/www",
|
||||
"index": "index.php",
|
||||
"options": {
|
||||
"file": "/etc/php.d/default.ini",
|
||||
"admin": {
|
||||
"max_execution_time": "30",
|
||||
"max_input_time": "30",
|
||||
"display_errors": "off",
|
||||
"display_startup_errors": "off",
|
||||
"open_basedir": "/dev/urandom:/proc/cpuinfo:/proc/meminfo:/etc/ssl/certs:/var/www",
|
||||
"disable_functions": "exec,passthru,shell_exec,system"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
'';
|
||||
description = "Unit configuration in JSON format. More details here https://unit.nginx.org/configuration";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
|
||||
environment.systemPackages = [ cfg.package ];
|
||||
|
||||
systemd.tmpfiles.rules = [
|
||||
"d '${cfg.stateDir}' 0750 ${cfg.user} ${cfg.group} - -"
|
||||
"d '${cfg.logDir}' 0750 ${cfg.user} ${cfg.group} - -"
|
||||
];
|
||||
|
||||
systemd.services.unit = {
|
||||
description = "Unit App Server";
|
||||
after = [ "network.target" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
path = with pkgs; [ curl ];
|
||||
preStart = ''
|
||||
test -f '/run/unit/control.unit.sock' || rm -f '/run/unit/control.unit.sock'
|
||||
'';
|
||||
postStart = ''
|
||||
curl -X PUT --data-binary '@${configFile}' --unix-socket '/run/unit/control.unit.sock' 'http://localhost/config'
|
||||
'';
|
||||
serviceConfig = {
|
||||
User = cfg.user;
|
||||
Group = cfg.group;
|
||||
AmbientCapabilities = "CAP_NET_BIND_SERVICE CAP_SETGID CAP_SETUID";
|
||||
CapabilityBoundingSet = "CAP_NET_BIND_SERVICE CAP_SETGID CAP_SETUID";
|
||||
ExecStart = ''
|
||||
${cfg.package}/bin/unitd --control 'unix:/run/unit/control.unit.sock' --pid '/run/unit/unit.pid' \
|
||||
--log '${cfg.logDir}/unit.log' --state '${cfg.stateDir}' --no-daemon \
|
||||
--user ${cfg.user} --group ${cfg.group}
|
||||
'';
|
||||
RuntimeDirectory = "unit";
|
||||
RuntimeDirectoryMode = "0750";
|
||||
};
|
||||
};
|
||||
|
||||
users.users = optionalAttrs (cfg.user == "unit") (singleton {
|
||||
name = "unit";
|
||||
group = cfg.group;
|
||||
});
|
||||
|
||||
users.groups = optionalAttrs (cfg.group == "unit") (singleton {
|
||||
name = "unit";
|
||||
});
|
||||
};
|
||||
}
|
||||
@@ -14,6 +14,9 @@ let
|
||||
in
|
||||
|
||||
{
|
||||
|
||||
meta.maintainers = pkgs.pantheon.maintainers;
|
||||
|
||||
options = {
|
||||
|
||||
services.xserver.desktopManager.pantheon = {
|
||||
@@ -108,26 +111,26 @@ in
|
||||
([ pkgs.pantheon.switchboard-plug-power ])
|
||||
(mkIf config.services.printing.enable ([pkgs.system-config-printer]) )
|
||||
];
|
||||
services.pantheon.contractor.enable = true;
|
||||
services.pantheon.contractor.enable = mkDefault true;
|
||||
services.geoclue2.enable = mkDefault true;
|
||||
# pantheon has pantheon-agent-geoclue2
|
||||
services.geoclue2.enableDemoAgent = false;
|
||||
services.gnome3.at-spi2-core.enable = true;
|
||||
services.gnome3.evolution-data-server.enable = true;
|
||||
services.gnome3.file-roller.enable = true;
|
||||
services.gnome3.file-roller.enable = mkDefault true;
|
||||
# TODO: gnome-keyring's xdg autostarts will still be in the environment (from elementary-session-settings) if disabled forcefully
|
||||
services.gnome3.gnome-keyring.enable = true;
|
||||
services.gnome3.gnome-settings-daemon.enable = true;
|
||||
services.gnome3.gnome-settings-daemon.package = pkgs.pantheon.elementary-settings-daemon;
|
||||
services.gnome3.gvfs.enable = true;
|
||||
services.gnome3.rygel.enable = true;
|
||||
services.gsignond.enable = true;
|
||||
services.gnome3.rygel.enable = mkDefault true;
|
||||
services.gsignond.enable = mkDefault true;
|
||||
services.gsignond.plugins = with pkgs.gsignondPlugins; [ lastfm mail oauth ];
|
||||
services.udisks2.enable = true;
|
||||
services.upower.enable = config.powerManagement.enable;
|
||||
services.xserver.libinput.enable = mkDefault true;
|
||||
services.xserver.updateDbusEnvironment = true;
|
||||
services.zeitgeist.enable = true;
|
||||
services.zeitgeist.enable = mkDefault true;
|
||||
|
||||
networking.networkmanager.enable = mkDefault true;
|
||||
networking.networkmanager.basePackages =
|
||||
@@ -152,19 +155,15 @@ in
|
||||
"/share"
|
||||
];
|
||||
|
||||
environment.systemPackages = pkgs.pantheon.artwork ++ pkgs.pantheon.desktop ++ pkgs.pantheon.services ++ cfg.sessionPath
|
||||
++ (pkgs.gnome3.removePackagesByName pkgs.pantheon.apps config.environment.pantheon.excludePackages)
|
||||
++ (with pkgs.gnome3;
|
||||
[
|
||||
adwaita-icon-theme
|
||||
dconf
|
||||
epiphany
|
||||
environment.systemPackages =
|
||||
pkgs.pantheon.artwork ++ pkgs.pantheon.desktop ++ pkgs.pantheon.services ++ cfg.sessionPath
|
||||
++ (with pkgs; gnome3.removePackagesByName
|
||||
([
|
||||
gnome3.geary
|
||||
gnome3.epiphany
|
||||
gnome3.gnome-font-viewer
|
||||
evince
|
||||
geary
|
||||
gnome-bluetooth
|
||||
gnome-font-viewer
|
||||
gnome-power-manager
|
||||
])
|
||||
] ++ pantheon.apps) config.environment.pantheon.excludePackages)
|
||||
++ (with pkgs;
|
||||
[
|
||||
adwaita-qt
|
||||
@@ -172,6 +171,8 @@ in
|
||||
glib
|
||||
glib-networking
|
||||
gnome-menus
|
||||
gnome3.adwaita-icon-theme
|
||||
gnome3.dconf
|
||||
gtk3.out
|
||||
hicolor-icon-theme
|
||||
lightlocker
|
||||
@@ -187,6 +188,7 @@ in
|
||||
roboto-mono
|
||||
pantheon.elementary-redacted-script # needed by screenshot-tool
|
||||
];
|
||||
|
||||
fonts.fontconfig.defaultFonts = {
|
||||
monospace = [ "Roboto Mono" ];
|
||||
sansSerif = [ "Open Sans" ];
|
||||
|
||||
@@ -25,7 +25,7 @@ in
|
||||
{ name = "dwm";
|
||||
start =
|
||||
''
|
||||
${pkgs.dwm}/bin/dwm &
|
||||
dwm &
|
||||
waitPID=$!
|
||||
'';
|
||||
};
|
||||
|
||||
@@ -246,7 +246,7 @@ in
|
||||
default = [ "ati" "cirrus" "vesa" "vmware" "modesetting" ];
|
||||
example = [
|
||||
"ati_unfree" "amdgpu" "amdgpu-pro"
|
||||
"nv" "nvidia" "nvidiaLegacy340" "nvidiaLegacy304"
|
||||
"nv" "nvidia" "nvidiaLegacy390" "nvidiaLegacy340" "nvidiaLegacy304"
|
||||
];
|
||||
# TODO(@oxij): think how to easily add the rest, like those nvidia things
|
||||
relatedPackages = concatLists
|
||||
@@ -259,6 +259,11 @@ in
|
||||
The names of the video drivers the configuration
|
||||
supports. They will be tried in order until one that
|
||||
supports your card is found.
|
||||
Don't combine those with "incompatible" OpenGL implementations,
|
||||
e.g. free ones (mesa-based) with proprietary ones.
|
||||
|
||||
For unfree "nvidia*", the supported GPU lists are on
|
||||
https://www.nvidia.com/object/unix.html
|
||||
'';
|
||||
};
|
||||
|
||||
|
||||
@@ -8,13 +8,17 @@ let
|
||||
|
||||
efi = config.boot.loader.efi;
|
||||
|
||||
realGrub = if cfg.version == 1 then pkgs.grub
|
||||
else if cfg.zfsSupport then pkgs.grub2.override { zfsSupport = true; }
|
||||
grubPkgs =
|
||||
# Package set of targeted architecture
|
||||
if cfg.forcei686 then pkgs.pkgsi686Linux else pkgs;
|
||||
|
||||
realGrub = if cfg.version == 1 then grubPkgs.grub
|
||||
else if cfg.zfsSupport then grubPkgs.grub2.override { zfsSupport = true; }
|
||||
else if cfg.trustedBoot.enable
|
||||
then if cfg.trustedBoot.isHPLaptop
|
||||
then pkgs.trustedGrub-for-HP
|
||||
else pkgs.trustedGrub
|
||||
else pkgs.grub2;
|
||||
then grubPkgs.trustedGrub-for-HP
|
||||
else grubPkgs.trustedGrub
|
||||
else grubPkgs.grub2;
|
||||
|
||||
grub =
|
||||
# Don't include GRUB if we're only generating a GRUB menu (e.g.,
|
||||
@@ -58,14 +62,10 @@ let
|
||||
version extraConfig extraPerEntryConfig extraEntries forceInstall useOSProber
|
||||
extraEntriesBeforeNixOS extraPrepareConfig extraInitrd configurationLimit copyKernels
|
||||
default fsIdentifier efiSupport efiInstallAsRemovable gfxmodeEfi gfxmodeBios;
|
||||
path = (makeBinPath ([
|
||||
pkgs.coreutils pkgs.gnused pkgs.gnugrep pkgs.findutils pkgs.diffutils pkgs.btrfs-progs
|
||||
pkgs.utillinux ]
|
||||
++ (optional (cfg.efiSupport && (cfg.version == 2)) pkgs.efibootmgr)
|
||||
++ (optionals cfg.useOSProber [pkgs.busybox pkgs.os-prober])
|
||||
)) + ":" + (makeSearchPathOutput "bin" "sbin" [
|
||||
pkgs.mdadm pkgs.utillinux
|
||||
]);
|
||||
path = with pkgs; makeBinPath (
|
||||
[ coreutils gnused gnugrep findutils diffutils btrfs-progs utillinux mdadm ]
|
||||
++ optional (cfg.efiSupport && (cfg.version == 2)) efibootmgr
|
||||
++ optionals cfg.useOSProber [ busybox os-prober ]);
|
||||
font = if cfg.font == null then ""
|
||||
else (if lib.last (lib.splitString "." cfg.font) == "pf2"
|
||||
then cfg.font
|
||||
@@ -512,6 +512,15 @@ in
|
||||
'';
|
||||
};
|
||||
|
||||
forcei686 = mkOption {
|
||||
default = false;
|
||||
type = types.bool;
|
||||
description = ''
|
||||
Whether to force the use of a ia32 boot loader on x64 systems. Required
|
||||
to install and run NixOS on 64bit x86 systems with 32bit (U)EFI.
|
||||
'';
|
||||
};
|
||||
|
||||
trustedBoot = {
|
||||
|
||||
enable = mkOption {
|
||||
|
||||
@@ -209,10 +209,17 @@ in
|
||||
|
||||
assertions = let
|
||||
ls = sep: concatMapStringsSep sep (x: x.mountPoint);
|
||||
notAutoResizable = fs: fs.autoResize && !(hasPrefix "ext" fs.fsType || fs.fsType == "f2fs");
|
||||
in [
|
||||
{ assertion = ! (fileSystems' ? "cycle");
|
||||
message = "The ‘fileSystems’ option can't be topologically sorted: mountpoint dependency path ${ls " -> " fileSystems'.cycle} loops to ${ls ", " fileSystems'.loops}";
|
||||
}
|
||||
{ assertion = ! (any notAutoResizable fileSystems);
|
||||
message = let
|
||||
fs = head (filter notAutoResizable fileSystems);
|
||||
in
|
||||
"Mountpoint '${fs.mountPoint}': 'autoResize = true' is not supported for 'fsType = \"${fs.fsType}\"':${if fs.fsType == "auto" then " fsType has to be explicitly set and" else ""} only the ext filesystems and f2fs support it.";
|
||||
}
|
||||
];
|
||||
|
||||
# Export for use in other modules
|
||||
|
||||
@@ -31,6 +31,7 @@ in
|
||||
|
||||
fileSystems."/" = {
|
||||
device = "/dev/disk/by-label/nixos";
|
||||
fsType = "ext4";
|
||||
autoResize = true;
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
cfg = config.virtualisation.anbox;
|
||||
kernelPackages = config.boot.kernelPackages;
|
||||
addrOpts = v: addr: pref: name: {
|
||||
address = mkOption {
|
||||
default = addr;
|
||||
type = types.str;
|
||||
description = ''
|
||||
IPv${toString v} ${name} address.
|
||||
'';
|
||||
};
|
||||
|
||||
prefixLength = mkOption {
|
||||
default = pref;
|
||||
type = types.addCheck types.int (n: n >= 0 && n <= (if v == 4 then 32 else 128));
|
||||
description = ''
|
||||
Subnet mask of the ${name} address, specified as the number of
|
||||
bits in the prefix (<literal>${if v == 4 then "24" else "64"}</literal>).
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
in
|
||||
|
||||
{
|
||||
|
||||
options.virtualisation.anbox = {
|
||||
|
||||
enable = mkEnableOption "Anbox";
|
||||
|
||||
image = mkOption {
|
||||
default = pkgs.anbox.image;
|
||||
example = literalExample "pkgs.anbox.image";
|
||||
type = types.package;
|
||||
description = ''
|
||||
Base android image for Anbox.
|
||||
'';
|
||||
};
|
||||
|
||||
extraInit = mkOption {
|
||||
type = types.lines;
|
||||
default = "";
|
||||
description = ''
|
||||
Extra shell commands to be run inside the container image during init.
|
||||
'';
|
||||
};
|
||||
|
||||
ipv4 = {
|
||||
container = addrOpts 4 "192.168.250.2" 24 "Container";
|
||||
gateway = addrOpts 4 "192.168.250.1" 24 "Host";
|
||||
|
||||
dns = mkOption {
|
||||
default = "1.1.1.1";
|
||||
type = types.string;
|
||||
description = ''
|
||||
Container DNS server.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
|
||||
assertions = singleton {
|
||||
assertion = versionAtLeast (getVersion config.boot.kernelPackages.kernel) "4.18";
|
||||
message = "Anbox needs user namespace support to work properly";
|
||||
};
|
||||
|
||||
environment.systemPackages = with pkgs; [ anbox ];
|
||||
|
||||
boot.kernelModules = [ "ashmem_linux" "binder_linux" ];
|
||||
boot.extraModulePackages = [ kernelPackages.anbox ];
|
||||
|
||||
services.udev.extraRules = ''
|
||||
KERNEL=="ashmem", NAME="%k", MODE="0666"
|
||||
KERNEL=="binder*", NAME="%k", MODE="0666"
|
||||
'';
|
||||
|
||||
virtualisation.lxc.enable = true;
|
||||
networking.bridges.anbox0.interfaces = [];
|
||||
networking.interfaces.anbox0.ipv4.addresses = [ cfg.ipv4.gateway ];
|
||||
|
||||
networking.nat = {
|
||||
enable = true;
|
||||
internalInterfaces = [ "anbox0" ];
|
||||
};
|
||||
|
||||
systemd.services.anbox-container-manager = let
|
||||
anboxloc = "/var/lib/anbox";
|
||||
in {
|
||||
description = "Anbox Container Management Daemon";
|
||||
|
||||
environment.XDG_RUNTIME_DIR="${anboxloc}";
|
||||
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "systemd-udev-settle.service" ];
|
||||
preStart = let
|
||||
initsh = let
|
||||
ip = cfg.ipv4.container.address;
|
||||
gw = cfg.ipv4.gateway.address;
|
||||
dns = cfg.ipv4.dns;
|
||||
in
|
||||
pkgs.writeText "nixos-init" (''
|
||||
#!/system/bin/sh
|
||||
setprop nixos.version ${config.system.nixos.version}
|
||||
|
||||
# we don't have radio
|
||||
setprop ro.radio.noril yes
|
||||
stop ril-daemon
|
||||
|
||||
# speed up boot
|
||||
setprop debug.sf.nobootanimation 1
|
||||
'' + cfg.extraInit);
|
||||
initshloc = "${anboxloc}/rootfs-overlay/system/etc/init.goldfish.sh";
|
||||
in ''
|
||||
mkdir -p ${anboxloc}
|
||||
mkdir -p $(dirname ${initshloc})
|
||||
[ -f ${initshloc} ] && rm ${initshloc}
|
||||
cp ${initsh} ${initshloc}
|
||||
chown 100000:100000 ${initshloc}
|
||||
chmod +x ${initshloc}
|
||||
'';
|
||||
|
||||
serviceConfig = {
|
||||
ExecStart = ''
|
||||
${pkgs.anbox}/bin/anbox container-manager \
|
||||
--data-path=${anboxloc} \
|
||||
--android-image=${cfg.image} \
|
||||
--container-network-address=${cfg.ipv4.container.address} \
|
||||
--container-network-gateway=${cfg.ipv4.gateway.address} \
|
||||
--container-network-dns-servers=${cfg.ipv4.dns} \
|
||||
--use-rootfs-overlay \
|
||||
--privileged
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
@@ -36,8 +36,9 @@ let
|
||||
#! ${pkgs.runtimeShell} -e
|
||||
|
||||
# Initialise the container side of the veth pair.
|
||||
if [ -n "$HOST_ADDRESS" ] || [ -n "$LOCAL_ADDRESS" ] || [ -n "$HOST_BRIDGE" ]; then
|
||||
|
||||
if [ -n "$HOST_ADDRESS" ] || [ -n "$HOST_ADDRESS6" ] ||
|
||||
[ -n "$LOCAL_ADDRESS" ] || [ -n "$LOCAL_ADDRESS6" ] ||
|
||||
[ -n "$HOST_BRIDGE" ]; then
|
||||
ip link set host0 name eth0
|
||||
ip link set dev eth0 up
|
||||
|
||||
@@ -88,7 +89,8 @@ let
|
||||
extraFlags+=" --private-network"
|
||||
fi
|
||||
|
||||
if [ -n "$HOST_ADDRESS" ] || [ -n "$LOCAL_ADDRESS" ]; then
|
||||
if [ -n "$HOST_ADDRESS" ] || [ -n "$LOCAL_ADDRESS" ] ||
|
||||
[ -n "$HOST_ADDRESS6" ] || [ -n "$LOCAL_ADDRESS6" ]; then
|
||||
extraFlags+=" --network-veth"
|
||||
fi
|
||||
|
||||
@@ -159,7 +161,8 @@ let
|
||||
# Clean up existing machined registration and interfaces.
|
||||
machinectl terminate "$INSTANCE" 2> /dev/null || true
|
||||
|
||||
if [ -n "$HOST_ADDRESS" ] || [ -n "$LOCAL_ADDRESS" ]; then
|
||||
if [ -n "$HOST_ADDRESS" ] || [ -n "$LOCAL_ADDRESS" ] ||
|
||||
[ -n "$HOST_ADDRESS6" ] || [ -n "$LOCAL_ADDRESS6" ]; then
|
||||
ip link del dev "ve-$INSTANCE" 2> /dev/null || true
|
||||
ip link del dev "vb-$INSTANCE" 2> /dev/null || true
|
||||
fi
|
||||
@@ -208,7 +211,8 @@ let
|
||||
'';
|
||||
in
|
||||
''
|
||||
if [ -n "$HOST_ADDRESS" ] || [ -n "$LOCAL_ADDRESS" ]; then
|
||||
if [ -n "$HOST_ADDRESS" ] || [ -n "$LOCAL_ADDRESS" ] ||
|
||||
[ -n "$HOST_ADDRESS6" ] || [ -n "$LOCAL_ADDRESS6" ]; then
|
||||
if [ -z "$HOST_BRIDGE" ]; then
|
||||
ifaceHost=ve-$INSTANCE
|
||||
ip link set dev $ifaceHost up
|
||||
|
||||
@@ -0,0 +1,233 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
let
|
||||
cfg = config.docker-containers;
|
||||
|
||||
dockerContainer =
|
||||
{ name, config, ... }: {
|
||||
|
||||
options = {
|
||||
|
||||
image = mkOption {
|
||||
type = types.str;
|
||||
description = "Docker image to run.";
|
||||
example = "library/hello-world";
|
||||
};
|
||||
|
||||
cmd = mkOption {
|
||||
type = with types; listOf str;
|
||||
default = [];
|
||||
description = "Commandline arguments to pass to the image's entrypoint.";
|
||||
example = literalExample ''
|
||||
["--port=9000"]
|
||||
'';
|
||||
};
|
||||
|
||||
entrypoint = mkOption {
|
||||
type = with types; nullOr str;
|
||||
description = "Overwrite the default entrypoint of the image.";
|
||||
default = null;
|
||||
example = "/bin/my-app";
|
||||
};
|
||||
|
||||
environment = mkOption {
|
||||
type = with types; attrsOf str;
|
||||
default = {};
|
||||
description = "Environment variables to set for this container.";
|
||||
example = literalExample ''
|
||||
{
|
||||
DATABASE_HOST = "db.example.com";
|
||||
DATABASE_PORT = "3306";
|
||||
}
|
||||
'';
|
||||
};
|
||||
|
||||
log-driver = mkOption {
|
||||
type = types.str;
|
||||
default = "none";
|
||||
description = ''
|
||||
Logging driver for the container. The default of
|
||||
<literal>"none"</literal> means that the container's logs will be
|
||||
handled as part of the systemd unit. Setting this to
|
||||
<literal>"journald"</literal> will result in duplicate logging, but
|
||||
the container's logs will be visible to the <command>docker
|
||||
logs</command> command.
|
||||
|
||||
For more details and a full list of logging drivers, refer to the
|
||||
<link xlink:href="https://docs.docker.com/engine/reference/run/#logging-drivers---log-driver">
|
||||
Docker engine documentation</link>
|
||||
'';
|
||||
};
|
||||
|
||||
ports = mkOption {
|
||||
type = with types; listOf str;
|
||||
default = [];
|
||||
description = ''
|
||||
Network ports to publish from the container to the outer host.
|
||||
</para>
|
||||
<para>
|
||||
Valid formats:
|
||||
</para>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal><ip>:<hostPort>:<containerPort></literal>
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal><ip>::<containerPort></literal>
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal><hostPort>:<containerPort></literal>
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<literal><containerPort></literal>
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
<para>
|
||||
Both <literal>hostPort</literal> and
|
||||
<literal>containerPort</literal> can be specified as a range of
|
||||
ports. When specifying ranges for both, the number of container
|
||||
ports in the range must match the number of host ports in the
|
||||
range. Example: <literal>1234-1236:1234-1236/tcp</literal>
|
||||
</para>
|
||||
<para>
|
||||
When specifying a range for <literal>hostPort</literal> only, the
|
||||
<literal>containerPort</literal> must <emphasis>not</emphasis> be a
|
||||
range. In this case, the container port is published somewhere
|
||||
within the specified <literal>hostPort</literal> range. Example:
|
||||
<literal>1234-1236:1234/tcp</literal>
|
||||
</para>
|
||||
<para>
|
||||
Refer to the
|
||||
<link xlink:href="https://docs.docker.com/engine/reference/run/#expose-incoming-ports">
|
||||
Docker engine documentation</link> for full details.
|
||||
'';
|
||||
example = literalExample ''
|
||||
[
|
||||
"8080:9000"
|
||||
]
|
||||
'';
|
||||
};
|
||||
|
||||
user = mkOption {
|
||||
type = with types; nullOr str;
|
||||
default = null;
|
||||
description = ''
|
||||
Override the username or UID (and optionally groupname or GID) used
|
||||
in the container.
|
||||
'';
|
||||
example = "nobody:nogroup";
|
||||
};
|
||||
|
||||
volumes = mkOption {
|
||||
type = with types; listOf str;
|
||||
default = [];
|
||||
description = ''
|
||||
List of volumes to attach to this container.
|
||||
|
||||
Note that this is a list of <literal>"src:dst"</literal> strings to
|
||||
allow for <literal>src</literal> to refer to
|
||||
<literal>/nix/store</literal> paths, which would difficult with an
|
||||
attribute set. There are also a variety of mount options available
|
||||
as a third field; please refer to the
|
||||
<link xlink:href="https://docs.docker.com/engine/reference/run/#volume-shared-filesystems">
|
||||
docker engine documentation</link> for details.
|
||||
'';
|
||||
example = literalExample ''
|
||||
[
|
||||
"volume_name:/path/inside/container"
|
||||
"/path/on/host:/path/inside/container"
|
||||
]
|
||||
'';
|
||||
};
|
||||
|
||||
workdir = mkOption {
|
||||
type = with types; nullOr str;
|
||||
default = null;
|
||||
description = "Override the default working directory for the container.";
|
||||
example = "/var/lib/hello_world";
|
||||
};
|
||||
|
||||
extraDockerOptions = mkOption {
|
||||
type = with types; listOf str;
|
||||
default = [];
|
||||
description = "Extra options for <command>docker run</command>.";
|
||||
example = literalExample ''
|
||||
["--network=host"]
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
mkService = name: container: {
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "docker.service" "docker.socket" ];
|
||||
requires = [ "docker.service" "docker.socket" ];
|
||||
serviceConfig = {
|
||||
ExecStart = concatStringsSep " \\\n " ([
|
||||
"${pkgs.docker}/bin/docker run"
|
||||
"--rm"
|
||||
"--name=%n"
|
||||
"--log-driver=${container.log-driver}"
|
||||
] ++ optional (! isNull container.entrypoint)
|
||||
"--entrypoint=${escapeShellArg container.entrypoint}"
|
||||
++ (mapAttrsToList (k: v: "-e ${escapeShellArg k}=${escapeShellArg v}") container.environment)
|
||||
++ map (p: "-p ${escapeShellArg p}") container.ports
|
||||
++ optional (! isNull container.user) "-u ${escapeShellArg container.user}"
|
||||
++ map (v: "-v ${escapeShellArg v}") container.volumes
|
||||
++ optional (! isNull container.workdir) "-w ${escapeShellArg container.workdir}"
|
||||
++ map escapeShellArg container.extraDockerOptions
|
||||
++ [container.image]
|
||||
++ map escapeShellArg container.cmd
|
||||
);
|
||||
ExecStartPre = "-${pkgs.docker}/bin/docker rm -f %n";
|
||||
ExecStop = "${pkgs.docker}/bin/docker stop %n";
|
||||
ExecStopPost = "-${pkgs.docker}/bin/docker rm -f %n";
|
||||
|
||||
### There is no generalized way of supporting `reload` for docker
|
||||
### containers. Some containers may respond well to SIGHUP sent to their
|
||||
### init process, but it is not guaranteed; some apps have other reload
|
||||
### mechanisms, some don't have a reload signal at all, and some docker
|
||||
### images just have broken signal handling. The best compromise in this
|
||||
### case is probably to leave ExecReload undefined, so `systemctl reload`
|
||||
### will at least result in an error instead of potentially undefined
|
||||
### behaviour.
|
||||
###
|
||||
### Advanced users can still override this part of the unit to implement
|
||||
### a custom reload handler, since the result of all this is a normal
|
||||
### systemd service from the perspective of the NixOS module system.
|
||||
###
|
||||
# ExecReload = ...;
|
||||
###
|
||||
|
||||
TimeoutStartSec = 0;
|
||||
TimeoutStopSec = 120;
|
||||
Restart = "always";
|
||||
};
|
||||
};
|
||||
|
||||
in {
|
||||
|
||||
options.docker-containers = mkOption {
|
||||
default = {};
|
||||
type = types.attrsOf (types.submodule dockerContainer);
|
||||
description = "Docker containers to run as systemd services.";
|
||||
};
|
||||
|
||||
config = mkIf (cfg != []) {
|
||||
|
||||
systemd.services = mapAttrs' (n: v: nameValuePair "docker-${n}" (mkService n v)) cfg;
|
||||
|
||||
virtualisation.docker.enable = true;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
@@ -20,6 +20,7 @@ in
|
||||
config = {
|
||||
fileSystems."/" = {
|
||||
device = "/dev/disk/by-label/nixos";
|
||||
fsType = "ext4";
|
||||
autoResize = true;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user