Skip to content

Commit

Permalink
nixos/containers: format
Browse files Browse the repository at this point in the history
  • Loading branch information
minijackson committed Nov 22, 2024
1 parent 4c7d10d commit 1481d3f
Showing 1 changed file with 27 additions and 22 deletions.
49 changes: 27 additions & 22 deletions nixos/modules/virtualisation/containers.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{ config, lib, pkgs, ... }:
{
config,
lib,
pkgs,
...
}:
let
cfg = config.virtualisation.containers;

Expand All @@ -22,14 +27,13 @@ in

options.virtualisation.containers = {

enable =
mkOption {
type = types.bool;
default = false;
description = ''
This option enables the common /etc/containers configuration module.
'';
};
enable = mkOption {
type = types.bool;
default = false;
description = ''
This option enables the common /etc/containers configuration module.
'';
};

ociSeccompBpfHook.enable = mkOption {
type = types.bool;
Expand Down Expand Up @@ -155,11 +159,13 @@ in

virtualisation.containers.containersConf.settings = {
network.cni_plugin_dirs = map (p: "${lib.getBin p}/bin") cfg.containersConf.cniPlugins;
engine = {
init_path = "${pkgs.catatonit}/bin/catatonit";
} // lib.optionalAttrs cfg.ociSeccompBpfHook.enable {
hooks_dir = [ config.boot.kernelPackages.oci-seccomp-bpf-hook ];
};
engine =
{
init_path = "${pkgs.catatonit}/bin/catatonit";
}
// lib.optionalAttrs cfg.ociSeccompBpfHook.enable {
hooks_dir = [ config.boot.kernelPackages.oci-seccomp-bpf-hook ];
};
};

virtualisation.containers.storage.settings.storage = {
Expand All @@ -169,18 +175,17 @@ in
};

environment.etc = {
"containers/containers.conf".source =
toml.generate "containers.conf" cfg.containersConf.settings;
"containers/containers.conf".source = toml.generate "containers.conf" cfg.containersConf.settings;

"containers/storage.conf".source =
toml.generate "storage.conf" cfg.storage.settings;
"containers/storage.conf".source = toml.generate "storage.conf" cfg.storage.settings;

"containers/registries.conf".source =
toml.generate "registries.conf" cfg.registries.settings;
"containers/registries.conf".source = toml.generate "registries.conf" cfg.registries.settings;

"containers/policy.json".source =
if cfg.policy != { } then pkgs.writeText "policy.json" (builtins.toJSON cfg.policy)
else "${pkgs.skopeo.policy}/default-policy.json";
if cfg.policy != { } then
pkgs.writeText "policy.json" (builtins.toJSON cfg.policy)
else
"${pkgs.skopeo.policy}/default-policy.json";
};

};
Expand Down

0 comments on commit 1481d3f

Please sign in to comment.