Skip to content

Commit

Permalink
Podman DNS match pattern for nftables
Browse files Browse the repository at this point in the history
  • Loading branch information
aksiksi committed Feb 1, 2025
1 parent abb340f commit b2778f7
Show file tree
Hide file tree
Showing 59 changed files with 275 additions and 259 deletions.
2 changes: 1 addition & 1 deletion nixos-test/docker-compose.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Auto-generated using compose2nix v0.3.2-pre.
{ pkgs, lib, ... }:
{ pkgs, lib, config, ... }:

{
# Runtime
Expand Down
12 changes: 8 additions & 4 deletions nixos-test/podman-compose.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Auto-generated using compose2nix v0.3.2-pre.
{ pkgs, lib, ... }:
{ pkgs, lib, config, ... }:

{
# Runtime
Expand All @@ -13,9 +13,13 @@
};
};

# Enable container name DNS for non-default Podman networks.
# https://github.com/NixOS/nixpkgs/issues/226365
networking.firewall.interfaces."podman+".allowedUDPPorts = [ 53 ];
# Enable container name DNS for all Podman networks.
# See: https://github.com/NixOS/nixpkgs/issues/226365
networking.firewall.interfaces = let
matchAll = if !config.networking.nftables.enable then "podman+" else "podman*";
in {
"${matchAll}".allowedUDPPorts = [ 53 ];
};

virtualisation.oci-containers.backend = "podman";

Expand Down
18 changes: 9 additions & 9 deletions templates/main.nix.tmpl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{{- if .Version -}}
# Auto-generated using compose2nix v{{.Version}}.
{ pkgs, lib, ... }:
{ pkgs, lib, config, ... }:
{{- else -}}
{ pkgs, lib, ... }:
{ pkgs, lib, config, ... }:
{{- end}}

{
Expand All @@ -13,17 +13,17 @@
autoPrune.enable = true;
{{- if eq (.Runtime | printf "%s") "podman"}}
dockerCompat = true;
defaultNetwork.settings = {
# Required for container networking to be able to use names.
dns_enabled = true;
};
{{- end}}
};
{{- if eq (.Runtime | printf "%s") "podman"}}

# Enable container name DNS for non-default Podman networks.
# https://github.com/NixOS/nixpkgs/issues/226365
networking.firewall.interfaces."podman+".allowedUDPPorts = [ 53 ];
# Enable container name DNS for all Podman networks.
# See: https://github.com/NixOS/nixpkgs/issues/226365
networking.firewall.interfaces = let
matchAll = if !config.networking.nftables.enable then "podman+" else "podman*";
in {
"${matchAll}".allowedUDPPorts = [ 53 ];
};

virtualisation.oci-containers.backend = "{{.Runtime}}";
{{- else}}
Expand Down
2 changes: 1 addition & 1 deletion testdata/TestAutoStart.docker.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ pkgs, lib, ... }:
{ pkgs, lib, config, ... }:

{
# Runtime
Expand Down
16 changes: 8 additions & 8 deletions testdata/TestAutoStart.podman.nix
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{ pkgs, lib, ... }:
{ pkgs, lib, config, ... }:

{
# Runtime
virtualisation.podman = {
enable = true;
autoPrune.enable = true;
dockerCompat = true;
defaultNetwork.settings = {
# Required for container networking to be able to use names.
dns_enabled = true;
};
};

# Enable container name DNS for non-default Podman networks.
# https://github.com/NixOS/nixpkgs/issues/226365
networking.firewall.interfaces."podman+".allowedUDPPorts = [ 53 ];
# Enable container name DNS for all Podman networks.
# See: https://github.com/NixOS/nixpkgs/issues/226365
networking.firewall.interfaces = let
matchAll = if !config.networking.nftables.enable then "podman+" else "podman*";
in {
"${matchAll}".allowedUDPPorts = [ 53 ];
};

virtualisation.oci-containers.backend = "podman";

Expand Down
2 changes: 1 addition & 1 deletion testdata/TestBasic.docker.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ pkgs, lib, ... }:
{ pkgs, lib, config, ... }:

{
# Runtime
Expand Down
16 changes: 8 additions & 8 deletions testdata/TestBasic.podman.nix
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{ pkgs, lib, ... }:
{ pkgs, lib, config, ... }:

{
# Runtime
virtualisation.podman = {
enable = true;
autoPrune.enable = true;
dockerCompat = true;
defaultNetwork.settings = {
# Required for container networking to be able to use names.
dns_enabled = true;
};
};

# Enable container name DNS for non-default Podman networks.
# https://github.com/NixOS/nixpkgs/issues/226365
networking.firewall.interfaces."podman+".allowedUDPPorts = [ 53 ];
# Enable container name DNS for all Podman networks.
# See: https://github.com/NixOS/nixpkgs/issues/226365
networking.firewall.interfaces = let
matchAll = if !config.networking.nftables.enable then "podman+" else "podman*";
in {
"${matchAll}".allowedUDPPorts = [ 53 ];
};

virtualisation.oci-containers.backend = "podman";

Expand Down
7 changes: 6 additions & 1 deletion testdata/TestBasicAutoFormat.docker.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{ pkgs, lib, ... }:
{
pkgs,
lib,
config,
...
}:

{
# Runtime
Expand Down
23 changes: 15 additions & 8 deletions testdata/TestBasicAutoFormat.podman.nix
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
{ pkgs, lib, ... }:
{
pkgs,
lib,
config,
...
}:

{
# Runtime
virtualisation.podman = {
enable = true;
autoPrune.enable = true;
dockerCompat = true;
defaultNetwork.settings = {
# Required for container networking to be able to use names.
dns_enabled = true;
};
};

# Enable container name DNS for non-default Podman networks.
# https://github.com/NixOS/nixpkgs/issues/226365
networking.firewall.interfaces."podman+".allowedUDPPorts = [ 53 ];
# Enable container name DNS for all Podman networks.
# See: https://github.com/NixOS/nixpkgs/issues/226365
networking.firewall.interfaces =
let
matchAll = if !config.networking.nftables.enable then "podman+" else "podman*";
in
{
"${matchAll}".allowedUDPPorts = [ 53 ];
};

virtualisation.oci-containers.backend = "podman";

Expand Down
2 changes: 1 addition & 1 deletion testdata/TestBuildSpec.docker.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ pkgs, lib, ... }:
{ pkgs, lib, config, ... }:

{
# Runtime
Expand Down
16 changes: 8 additions & 8 deletions testdata/TestBuildSpec.podman.nix
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{ pkgs, lib, ... }:
{ pkgs, lib, config, ... }:

{
# Runtime
virtualisation.podman = {
enable = true;
autoPrune.enable = true;
dockerCompat = true;
defaultNetwork.settings = {
# Required for container networking to be able to use names.
dns_enabled = true;
};
};

# Enable container name DNS for non-default Podman networks.
# https://github.com/NixOS/nixpkgs/issues/226365
networking.firewall.interfaces."podman+".allowedUDPPorts = [ 53 ];
# Enable container name DNS for all Podman networks.
# See: https://github.com/NixOS/nixpkgs/issues/226365
networking.firewall.interfaces = let
matchAll = if !config.networking.nftables.enable then "podman+" else "podman*";
in {
"${matchAll}".allowedUDPPorts = [ 53 ];
};

virtualisation.oci-containers.backend = "podman";

Expand Down
2 changes: 1 addition & 1 deletion testdata/TestBuildSpec_BuildEnabled.docker.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ pkgs, lib, ... }:
{ pkgs, lib, config, ... }:

{
# Runtime
Expand Down
16 changes: 8 additions & 8 deletions testdata/TestBuildSpec_BuildEnabled.podman.nix
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{ pkgs, lib, ... }:
{ pkgs, lib, config, ... }:

{
# Runtime
virtualisation.podman = {
enable = true;
autoPrune.enable = true;
dockerCompat = true;
defaultNetwork.settings = {
# Required for container networking to be able to use names.
dns_enabled = true;
};
};

# Enable container name DNS for non-default Podman networks.
# https://github.com/NixOS/nixpkgs/issues/226365
networking.firewall.interfaces."podman+".allowedUDPPorts = [ 53 ];
# Enable container name DNS for all Podman networks.
# See: https://github.com/NixOS/nixpkgs/issues/226365
networking.firewall.interfaces = let
matchAll = if !config.networking.nftables.enable then "podman+" else "podman*";
in {
"${matchAll}".allowedUDPPorts = [ 53 ];
};

virtualisation.oci-containers.backend = "podman";

Expand Down
2 changes: 1 addition & 1 deletion testdata/TestCommandAndEntrypoint.docker.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ pkgs, lib, ... }:
{ pkgs, lib, config, ... }:

{
# Runtime
Expand Down
16 changes: 8 additions & 8 deletions testdata/TestCommandAndEntrypoint.podman.nix
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{ pkgs, lib, ... }:
{ pkgs, lib, config, ... }:

{
# Runtime
virtualisation.podman = {
enable = true;
autoPrune.enable = true;
dockerCompat = true;
defaultNetwork.settings = {
# Required for container networking to be able to use names.
dns_enabled = true;
};
};

# Enable container name DNS for non-default Podman networks.
# https://github.com/NixOS/nixpkgs/issues/226365
networking.firewall.interfaces."podman+".allowedUDPPorts = [ 53 ];
# Enable container name DNS for all Podman networks.
# See: https://github.com/NixOS/nixpkgs/issues/226365
networking.firewall.interfaces = let
matchAll = if !config.networking.nftables.enable then "podman+" else "podman*";
in {
"${matchAll}".allowedUDPPorts = [ 53 ];
};

virtualisation.oci-containers.backend = "podman";

Expand Down
2 changes: 1 addition & 1 deletion testdata/TestComposeEnvFiles.docker.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ pkgs, lib, ... }:
{ pkgs, lib, config, ... }:

{
# Runtime
Expand Down
16 changes: 8 additions & 8 deletions testdata/TestComposeEnvFiles.podman.nix
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{ pkgs, lib, ... }:
{ pkgs, lib, config, ... }:

{
# Runtime
virtualisation.podman = {
enable = true;
autoPrune.enable = true;
dockerCompat = true;
defaultNetwork.settings = {
# Required for container networking to be able to use names.
dns_enabled = true;
};
};

# Enable container name DNS for non-default Podman networks.
# https://github.com/NixOS/nixpkgs/issues/226365
networking.firewall.interfaces."podman+".allowedUDPPorts = [ 53 ];
# Enable container name DNS for all Podman networks.
# See: https://github.com/NixOS/nixpkgs/issues/226365
networking.firewall.interfaces = let
matchAll = if !config.networking.nftables.enable then "podman+" else "podman*";
in {
"${matchAll}".allowedUDPPorts = [ 53 ];
};

virtualisation.oci-containers.backend = "podman";

Expand Down
2 changes: 1 addition & 1 deletion testdata/TestDeployDevices.docker.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ pkgs, lib, ... }:
{ pkgs, lib, config, ... }:

{
# Runtime
Expand Down
16 changes: 8 additions & 8 deletions testdata/TestDeployDevices.podman.nix
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{ pkgs, lib, ... }:
{ pkgs, lib, config, ... }:

{
# Runtime
virtualisation.podman = {
enable = true;
autoPrune.enable = true;
dockerCompat = true;
defaultNetwork.settings = {
# Required for container networking to be able to use names.
dns_enabled = true;
};
};

# Enable container name DNS for non-default Podman networks.
# https://github.com/NixOS/nixpkgs/issues/226365
networking.firewall.interfaces."podman+".allowedUDPPorts = [ 53 ];
# Enable container name DNS for all Podman networks.
# See: https://github.com/NixOS/nixpkgs/issues/226365
networking.firewall.interfaces = let
matchAll = if !config.networking.nftables.enable then "podman+" else "podman*";
in {
"${matchAll}".allowedUDPPorts = [ 53 ];
};

virtualisation.oci-containers.backend = "podman";

Expand Down
2 changes: 1 addition & 1 deletion testdata/TestEmptyEnv.docker.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ pkgs, lib, ... }:
{ pkgs, lib, config, ... }:

{
# Runtime
Expand Down
16 changes: 8 additions & 8 deletions testdata/TestEmptyEnv.podman.nix
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{ pkgs, lib, ... }:
{ pkgs, lib, config, ... }:

{
# Runtime
virtualisation.podman = {
enable = true;
autoPrune.enable = true;
dockerCompat = true;
defaultNetwork.settings = {
# Required for container networking to be able to use names.
dns_enabled = true;
};
};

# Enable container name DNS for non-default Podman networks.
# https://github.com/NixOS/nixpkgs/issues/226365
networking.firewall.interfaces."podman+".allowedUDPPorts = [ 53 ];
# Enable container name DNS for all Podman networks.
# See: https://github.com/NixOS/nixpkgs/issues/226365
networking.firewall.interfaces = let
matchAll = if !config.networking.nftables.enable then "podman+" else "podman*";
in {
"${matchAll}".allowedUDPPorts = [ 53 ];
};

virtualisation.oci-containers.backend = "podman";

Expand Down
2 changes: 1 addition & 1 deletion testdata/TestEnvFiles.docker.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ pkgs, lib, ... }:
{ pkgs, lib, config, ... }:

{
# Runtime
Expand Down
Loading

0 comments on commit b2778f7

Please sign in to comment.