treewide: Format all Nix files
Format all Nix files using the officially approved formatter,
making the CI check introduced in the previous commit succeed:
nix-build ci -A fmt.check
This is the next step of the of the [implementation](https://github.com/NixOS/nixfmt/issues/153)
of the accepted [RFC 166](https://github.com/NixOS/rfcs/pull/166).
This commit will lead to merge conflicts for a number of PRs,
up to an estimated ~1100 (~33%) among the PRs with activity in the past 2
months, but that should be lower than what it would be without the previous
[partial treewide format](https://github.com/NixOS/nixpkgs/pull/322537).
Merge conflicts caused by this commit can now automatically be resolved while rebasing using the
[auto-rebase script](8616af08d9/maintainers/scripts/auto-rebase).
If you run into any problems regarding any of this, please reach out to the
[formatting team](https://nixos.org/community/teams/formatting/) by
pinging @NixOS/nix-formatting.
This commit is contained in:
@@ -1,4 +1,10 @@
|
||||
{ config, lib, utils, pkgs, ... }:
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
utils,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.virtualisation.podman;
|
||||
json = pkgs.formats.json { };
|
||||
@@ -6,29 +12,42 @@ let
|
||||
inherit (lib) mkOption types;
|
||||
|
||||
# Provides a fake "docker" binary mapping to podman
|
||||
dockerCompat = pkgs.runCommand "${cfg.package.pname}-docker-compat-${cfg.package.version}"
|
||||
{
|
||||
outputs = [ "out" "man" ];
|
||||
inherit (cfg.package) meta;
|
||||
preferLocalBuild = true;
|
||||
} ''
|
||||
mkdir -p $out/bin
|
||||
ln -s ${cfg.package}/bin/podman $out/bin/docker
|
||||
dockerCompat =
|
||||
pkgs.runCommand "${cfg.package.pname}-docker-compat-${cfg.package.version}"
|
||||
{
|
||||
outputs = [
|
||||
"out"
|
||||
"man"
|
||||
];
|
||||
inherit (cfg.package) meta;
|
||||
preferLocalBuild = true;
|
||||
}
|
||||
''
|
||||
mkdir -p $out/bin
|
||||
ln -s ${cfg.package}/bin/podman $out/bin/docker
|
||||
|
||||
mkdir -p $man/share/man/man1
|
||||
for f in ${cfg.package.man}/share/man/man1/*; do
|
||||
basename=$(basename $f | sed s/podman/docker/g)
|
||||
ln -s $f $man/share/man/man1/$basename
|
||||
done
|
||||
'';
|
||||
mkdir -p $man/share/man/man1
|
||||
for f in ${cfg.package.man}/share/man/man1/*; do
|
||||
basename=$(basename $f | sed s/podman/docker/g)
|
||||
ln -s $f $man/share/man/man1/$basename
|
||||
done
|
||||
'';
|
||||
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
(lib.mkRemovedOptionModule [ "virtualisation" "podman" "defaultNetwork" "dnsname" ]
|
||||
"Use virtualisation.podman.defaultNetwork.settings.dns_enabled instead.")
|
||||
(lib.mkRemovedOptionModule [ "virtualisation" "podman" "defaultNetwork" "extraPlugins" ]
|
||||
"Netavark isn't compatible with CNI plugins.")
|
||||
(lib.mkRemovedOptionModule [
|
||||
"virtualisation"
|
||||
"podman"
|
||||
"defaultNetwork"
|
||||
"dnsname"
|
||||
] "Use virtualisation.podman.defaultNetwork.settings.dns_enabled instead.")
|
||||
(lib.mkRemovedOptionModule [
|
||||
"virtualisation"
|
||||
"podman"
|
||||
"defaultNetwork"
|
||||
"extraPlugins"
|
||||
] "Netavark isn't compatible with CNI plugins.")
|
||||
./network-socket.nix
|
||||
];
|
||||
|
||||
@@ -38,17 +57,16 @@ in
|
||||
|
||||
options.virtualisation.podman = {
|
||||
|
||||
enable =
|
||||
mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
This option enables Podman, a daemonless container engine for
|
||||
developing, managing, and running OCI Containers on your Linux System.
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
This option enables Podman, a daemonless container engine for
|
||||
developing, managing, and running OCI Containers on your Linux System.
|
||||
|
||||
It is a drop-in replacement for the {command}`docker` command.
|
||||
'';
|
||||
};
|
||||
It is a drop-in replacement for the {command}`docker` command.
|
||||
'';
|
||||
};
|
||||
|
||||
dockerSocket.enable = mkOption {
|
||||
type = types.bool;
|
||||
@@ -108,7 +126,7 @@ in
|
||||
|
||||
flags = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [];
|
||||
default = [ ];
|
||||
example = [ "--all" ];
|
||||
description = ''
|
||||
Any additional flags passed to {command}`podman system prune`.
|
||||
@@ -126,22 +144,38 @@ in
|
||||
};
|
||||
};
|
||||
|
||||
package = (lib.mkPackageOption pkgs "podman" {
|
||||
extraDescription = ''
|
||||
This package will automatically include extra packages and runtimes.
|
||||
'';
|
||||
}) // {
|
||||
apply = pkg: pkg.override {
|
||||
extraPackages = cfg.extraPackages ++ [
|
||||
"/run/wrappers" # setuid shadow
|
||||
config.systemd.package # To allow systemd-based container healthchecks
|
||||
] ++ lib.optional (config.boot.supportedFilesystems.zfs or false) config.boot.zfs.package;
|
||||
extraRuntimes = [ pkgs.runc ]
|
||||
++ lib.optionals (config.virtualisation.containers.containersConf.settings.network.default_rootless_network_cmd or "" == "slirp4netns") (with pkgs; [
|
||||
slirp4netns
|
||||
]);
|
||||
package =
|
||||
(lib.mkPackageOption pkgs "podman" {
|
||||
extraDescription = ''
|
||||
This package will automatically include extra packages and runtimes.
|
||||
'';
|
||||
})
|
||||
// {
|
||||
apply =
|
||||
pkg:
|
||||
pkg.override {
|
||||
extraPackages =
|
||||
cfg.extraPackages
|
||||
++ [
|
||||
"/run/wrappers" # setuid shadow
|
||||
config.systemd.package # To allow systemd-based container healthchecks
|
||||
]
|
||||
++ lib.optional (config.boot.supportedFilesystems.zfs or false) config.boot.zfs.package;
|
||||
extraRuntimes =
|
||||
[ pkgs.runc ]
|
||||
++ lib.optionals
|
||||
(
|
||||
config.virtualisation.containers.containersConf.settings.network.default_rootless_network_cmd or ""
|
||||
== "slirp4netns"
|
||||
)
|
||||
(
|
||||
with pkgs;
|
||||
[
|
||||
slirp4netns
|
||||
]
|
||||
);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
defaultNetwork.settings = lib.mkOption {
|
||||
type = json.type;
|
||||
@@ -156,17 +190,27 @@ in
|
||||
|
||||
config =
|
||||
let
|
||||
networkConfig = ({
|
||||
dns_enabled = false;
|
||||
driver = "bridge";
|
||||
id = "0000000000000000000000000000000000000000000000000000000000000000";
|
||||
internal = false;
|
||||
ipam_options = { driver = "host-local"; };
|
||||
ipv6_enabled = false;
|
||||
name = "podman";
|
||||
network_interface = "podman0";
|
||||
subnets = [{ gateway = "10.88.0.1"; subnet = "10.88.0.0/16"; }];
|
||||
} // cfg.defaultNetwork.settings);
|
||||
networkConfig = (
|
||||
{
|
||||
dns_enabled = false;
|
||||
driver = "bridge";
|
||||
id = "0000000000000000000000000000000000000000000000000000000000000000";
|
||||
internal = false;
|
||||
ipam_options = {
|
||||
driver = "host-local";
|
||||
};
|
||||
ipv6_enabled = false;
|
||||
name = "podman";
|
||||
network_interface = "podman0";
|
||||
subnets = [
|
||||
{
|
||||
gateway = "10.88.0.1";
|
||||
subnet = "10.88.0.0/16";
|
||||
}
|
||||
];
|
||||
}
|
||||
// cfg.defaultNetwork.settings
|
||||
);
|
||||
inherit (networkConfig) dns_enabled network_interface;
|
||||
in
|
||||
lib.mkIf cfg.enable {
|
||||
@@ -176,8 +220,7 @@ in
|
||||
''
|
||||
];
|
||||
|
||||
environment.systemPackages = [ cfg.package ]
|
||||
++ lib.optional cfg.dockerCompat dockerCompat;
|
||||
environment.systemPackages = [ cfg.package ] ++ lib.optional cfg.dockerCompat dockerCompat;
|
||||
|
||||
# https://github.com/containers/podman/blob/097cc6eb6dd8e598c0e8676d21267b4edb11e144/docs/tutorials/basic_networking.md#default-network
|
||||
environment.etc."containers/networks/podman.json" = lib.mkIf (cfg.defaultNetwork.settings != { }) {
|
||||
@@ -204,12 +247,15 @@ in
|
||||
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
ExecStart = utils.escapeSystemdExecArgs ([
|
||||
(lib.getExe cfg.package)
|
||||
"system"
|
||||
"prune"
|
||||
"-f"
|
||||
] ++ cfg.autoPrune.flags);
|
||||
ExecStart = utils.escapeSystemdExecArgs (
|
||||
[
|
||||
(lib.getExe cfg.package)
|
||||
"system"
|
||||
"prune"
|
||||
"-f"
|
||||
]
|
||||
++ cfg.autoPrune.flags
|
||||
);
|
||||
};
|
||||
|
||||
startAt = lib.optional cfg.autoPrune.enable cfg.autoPrune.dates;
|
||||
@@ -223,8 +269,9 @@ in
|
||||
# Podman does not support multiple sockets, as of podman 5.0.2, so we use
|
||||
# a symlink. Unfortunately this does not let us use an alternate group,
|
||||
# such as `docker`.
|
||||
systemd.sockets.podman.socketConfig.Symlinks =
|
||||
lib.mkIf cfg.dockerSocket.enable [ "/run/docker.sock" ];
|
||||
systemd.sockets.podman.socketConfig.Symlinks = lib.mkIf cfg.dockerSocket.enable [
|
||||
"/run/docker.sock"
|
||||
];
|
||||
|
||||
systemd.user.services.podman.environment = config.networking.proxy.envVars;
|
||||
systemd.user.sockets.podman.wantedBy = [ "sockets.target" ];
|
||||
@@ -237,15 +284,18 @@ in
|
||||
systemd.tmpfiles.packages = [
|
||||
# The /run/podman rule interferes with our podman group, so we remove
|
||||
# it and let the systemd socket logic take care of it.
|
||||
(pkgs.runCommand "podman-tmpfiles-nixos" {
|
||||
package = cfg.package;
|
||||
preferLocalBuild = true;
|
||||
} ''
|
||||
mkdir -p $out/lib/tmpfiles.d/
|
||||
grep -v 'D! /run/podman 0700 root root' \
|
||||
<$package/lib/tmpfiles.d/podman.conf \
|
||||
>$out/lib/tmpfiles.d/podman.conf
|
||||
'')
|
||||
(pkgs.runCommand "podman-tmpfiles-nixos"
|
||||
{
|
||||
package = cfg.package;
|
||||
preferLocalBuild = true;
|
||||
}
|
||||
''
|
||||
mkdir -p $out/lib/tmpfiles.d/
|
||||
grep -v 'D! /run/podman 0700 root root' \
|
||||
<$package/lib/tmpfiles.d/podman.conf \
|
||||
>$out/lib/tmpfiles.d/podman.conf
|
||||
''
|
||||
)
|
||||
];
|
||||
|
||||
users.groups.podman = { };
|
||||
|
||||
Reference in New Issue
Block a user