containers
This commit is contained in:
@@ -49,31 +49,42 @@ rec {
|
|||||||
{
|
{
|
||||||
name,
|
name,
|
||||||
localAddress ? "127.0.0.1",
|
localAddress ? "127.0.0.1",
|
||||||
port ? "80",
|
ports ? [ "80" ],
|
||||||
bindMounts ? { },
|
bindMounts ? { },
|
||||||
config ? { },
|
config ? { },
|
||||||
}:
|
}:
|
||||||
{ lib, ... }:
|
{ lib, ... }:
|
||||||
{
|
{
|
||||||
containers.${name} = {
|
containers.${name} = {
|
||||||
inherit localAddress bindMounts config;
|
inherit localAddress bindMounts;
|
||||||
|
|
||||||
|
config = config // {
|
||||||
|
networking = {
|
||||||
|
firewall = {
|
||||||
|
enable = true;
|
||||||
|
allowedTCPPorts = ports;
|
||||||
|
};
|
||||||
|
# Use systemd-resolved inside the container
|
||||||
|
# Workaround for bug https://github.com/NixOS/nixpkgs/issues/162686
|
||||||
|
useHostResolvConf = lib.mkForce false;
|
||||||
|
};
|
||||||
|
|
||||||
|
services.resolved.enable = true;
|
||||||
|
system.stateVersion = "23.11";
|
||||||
|
};
|
||||||
autoStart = lib.mkDefault true;
|
autoStart = lib.mkDefault true;
|
||||||
privateNetwork = lib.mkDefault true;
|
privateNetwork = lib.mkDefault true;
|
||||||
hostAddress = lib.mkDefault "10.0.1.3";
|
hostAddress = lib.mkDefault "10.0.1.3";
|
||||||
};
|
};
|
||||||
|
|
||||||
networking = {
|
networking = {
|
||||||
nat = {
|
nat.forwardPorts = map (port: {
|
||||||
forwardPorts = [
|
destination = lib.mkDefault "${localAddress}:${toString port}";
|
||||||
{
|
sourcePort = lib.mkDefault port;
|
||||||
destination = lib.mkDefault "${localAddress}:${toString port}";
|
}) ports;
|
||||||
sourcePort = lib.mkDefault port;
|
|
||||||
}
|
|
||||||
];
|
|
||||||
};
|
|
||||||
firewall = {
|
firewall = {
|
||||||
allowedTCPPorts = [ port ];
|
allowedTCPPorts = ports;
|
||||||
allowedUDPPorts = [ port ];
|
allowedUDPPorts = ports;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -65,19 +65,6 @@ let
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
networking = {
|
|
||||||
firewall = {
|
|
||||||
enable = true;
|
|
||||||
allowedTCPPorts = [ cfg.port ];
|
|
||||||
};
|
|
||||||
# Use systemd-resolved inside the container
|
|
||||||
# Workaround for bug https://github.com/NixOS/nixpkgs/issues/162686
|
|
||||||
useHostResolvConf = lib.mkForce false;
|
|
||||||
};
|
|
||||||
|
|
||||||
services.resolved.enable = true;
|
|
||||||
system.stateVersion = "23.11";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
bindMounts = {
|
bindMounts = {
|
||||||
@@ -99,7 +86,7 @@ let
|
|||||||
(lib.${namespace}.mkContainer {
|
(lib.${namespace}.mkContainer {
|
||||||
name = "actual";
|
name = "actual";
|
||||||
localAddress = cfg.localAddress;
|
localAddress = cfg.localAddress;
|
||||||
port = cfg.port;
|
ports = [ cfg.port ];
|
||||||
bindMounts = bindMounts;
|
bindMounts = bindMounts;
|
||||||
config = actualConfig;
|
config = actualConfig;
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ let
|
|||||||
metricsTokenFile = config.sops.secrets."jallen-nas/gitea/metrics-key".path;
|
metricsTokenFile = config.sops.secrets."jallen-nas/gitea/metrics-key".path;
|
||||||
|
|
||||||
serviceConfig =
|
serviceConfig =
|
||||||
{ lib, ... }:
|
{ ... }:
|
||||||
{
|
{
|
||||||
services.gitea = {
|
services.gitea = {
|
||||||
enable = true;
|
enable = true;
|
||||||
@@ -48,19 +48,6 @@ let
|
|||||||
extraGroups = [ "keys" ];
|
extraGroups = [ "keys" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
networking = {
|
|
||||||
firewall = {
|
|
||||||
enable = true;
|
|
||||||
allowedTCPPorts = [
|
|
||||||
cfg.httpPort
|
|
||||||
cfg.sshPort
|
|
||||||
];
|
|
||||||
};
|
|
||||||
# Use systemd-resolved inside the container
|
|
||||||
# Workaround for bug https://github.com/NixOS/nixpkgs/issues/162686
|
|
||||||
useHostResolvConf = lib.mkForce false;
|
|
||||||
};
|
|
||||||
|
|
||||||
# Create and set permissions for required directories
|
# Create and set permissions for required directories
|
||||||
system.activationScripts.gitea-dirs = ''
|
system.activationScripts.gitea-dirs = ''
|
||||||
mkdir -p /var/lib/gitea
|
mkdir -p /var/lib/gitea
|
||||||
@@ -70,9 +57,6 @@ let
|
|||||||
chown -R gitea:gitea /run/secrets/jallen-nas
|
chown -R gitea:gitea /run/secrets/jallen-nas
|
||||||
chmod -R 775 /run/secrets/jallen-nas
|
chmod -R 775 /run/secrets/jallen-nas
|
||||||
'';
|
'';
|
||||||
|
|
||||||
services.resolved.enable = true;
|
|
||||||
system.stateVersion = "23.11";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
bindMounts = {
|
bindMounts = {
|
||||||
@@ -99,7 +83,10 @@ let
|
|||||||
(lib.${namespace}.mkContainer {
|
(lib.${namespace}.mkContainer {
|
||||||
name = "gitea";
|
name = "gitea";
|
||||||
localAddress = cfg.localAddress;
|
localAddress = cfg.localAddress;
|
||||||
port = cfg.httpPort;
|
ports = [
|
||||||
|
cfg.httpPort
|
||||||
|
cfg.sshPort
|
||||||
|
];
|
||||||
bindMounts = bindMounts;
|
bindMounts = bindMounts;
|
||||||
config = serviceConfig;
|
config = serviceConfig;
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -117,18 +117,6 @@ let
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
networking = {
|
|
||||||
firewall = {
|
|
||||||
enable = true;
|
|
||||||
allowedTCPPorts = [ cfg.port ];
|
|
||||||
allowedUDPPorts = [ cfg.port ];
|
|
||||||
};
|
|
||||||
# Use systemd-resolved inside the container
|
|
||||||
# Workaround for bug https://github.com/NixOS/nixpkgs/issues/162686
|
|
||||||
useHostResolvConf = lib.mkForce false;
|
|
||||||
};
|
|
||||||
services.resolved.enable = true;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
bindMounts = {
|
bindMounts = {
|
||||||
@@ -150,7 +138,7 @@ let
|
|||||||
(lib.${namespace}.mkContainer {
|
(lib.${namespace}.mkContainer {
|
||||||
name = "matrix-synapse";
|
name = "matrix-synapse";
|
||||||
localAddress = cfg.localAddress;
|
localAddress = cfg.localAddress;
|
||||||
port = cfg.port;
|
ports = [ cfg.port ];
|
||||||
bindMounts = bindMounts;
|
bindMounts = bindMounts;
|
||||||
config = matrixConfig;
|
config = matrixConfig;
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -30,18 +30,6 @@ let
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
networking = {
|
|
||||||
firewall = {
|
|
||||||
enable = true;
|
|
||||||
allowedTCPPorts = [ cfg.port ];
|
|
||||||
allowedUDPPorts = [ cfg.port ];
|
|
||||||
};
|
|
||||||
# Use systemd-resolved inside the container
|
|
||||||
# Workaround for bug https://github.com/NixOS/nixpkgs/issues/162686
|
|
||||||
useHostResolvConf = lib.mkForce false;
|
|
||||||
};
|
|
||||||
services.resolved.enable = true;
|
|
||||||
# Create and set permissions for required directories
|
# Create and set permissions for required directories
|
||||||
system.activationScripts.ntfy-dirs = ''
|
system.activationScripts.ntfy-dirs = ''
|
||||||
mkdir -p /var/lib/ntfy-sh
|
mkdir -p /var/lib/ntfy-sh
|
||||||
@@ -75,7 +63,7 @@ let
|
|||||||
(lib.${namespace}.mkContainer {
|
(lib.${namespace}.mkContainer {
|
||||||
name = "ntfy";
|
name = "ntfy";
|
||||||
localAddress = cfg.localAddress;
|
localAddress = cfg.localAddress;
|
||||||
port = cfg.port;
|
ports = [ cfg.port ];
|
||||||
bindMounts = bindMounts;
|
bindMounts = bindMounts;
|
||||||
config = ntfyConfig;
|
config = ntfyConfig;
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user