-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
container: init service for linux and mac #4331
Closed
+521
−0
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
{ config, lib, pkgs, ... }: | ||
|
||
let | ||
cfg = config.virtualisation.containers; | ||
|
||
inherit (lib) mkOption types; | ||
|
||
toml = pkgs.formats.toml { }; | ||
in { | ||
meta.maintainers = [ lib.maintainers.michaelCTS ]; | ||
|
||
options.virtualisation.containers = { | ||
enable = lib.mkEnableOption "the common containers configuration module"; | ||
|
||
ociSeccompBpfHook.enable = lib.mkEnableOption "the OCI seccomp BPF hook"; | ||
|
||
registries = { | ||
search = mkOption { | ||
type = types.listOf types.str; | ||
default = [ "docker.io" "quay.io" ]; | ||
description = '' | ||
List of repositories to search. | ||
''; | ||
}; | ||
|
||
insecure = mkOption { | ||
type = types.listOf types.str; | ||
default = [ ]; | ||
description = '' | ||
List of insecure repositories. | ||
''; | ||
}; | ||
|
||
block = mkOption { | ||
type = types.listOf types.str; | ||
default = [ ]; | ||
description = '' | ||
List of blocked repositories. | ||
''; | ||
}; | ||
}; | ||
|
||
policy = mkOption { | ||
type = types.attrs; | ||
default = { }; | ||
example = lib.literalExpression '' | ||
{ | ||
default = [ { type = "insecureAcceptAnything"; } ]; | ||
transports = { | ||
docker-daemon = { | ||
"" = [ { type = "insecureAcceptAnything"; } ]; | ||
}; | ||
}; | ||
} | ||
''; | ||
description = '' | ||
Signature verification policy file. | ||
If this option is empty the default policy file from | ||
`skopeo` will be used. | ||
''; | ||
}; | ||
}; | ||
|
||
config = lib.mkIf cfg.enable { | ||
xdg.configFile."containers/registries.conf".source = | ||
toml.generate "registries.conf" { | ||
registries = lib.mapAttrs (n: v: { registries = v; }) cfg.registries; | ||
}; | ||
|
||
xdg.configFile."containers/policy.json".source = if cfg.policy != { } then | ||
pkgs.writeText "policy.json" (builtins.toJSON cfg.policy) | ||
else | ||
"${pkgs.skopeo.src}/default-policy.json"; | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Equivalent of | ||
# https://github.com/NixOS/nixpkgs/blob/nixos-unstable/nixos/modules/virtualisation/oci-containers.nix | ||
{ config, lib, pkgs, ... }: | ||
|
||
let | ||
cfg = config.virtualisation.oci-containers; | ||
|
||
inherit (lib) mkDefault mkIf mkMerge mkOption types; | ||
|
||
defaultBackend = "podman"; | ||
in { | ||
meta.maintainers = [ pkgs.lib.maintainers.michaelCTS ]; | ||
|
||
options.virtualisation.oci-containers = { | ||
enable = lib.mkEnableOption | ||
"a convenience option to enable containers in platform-agnostic manner"; | ||
|
||
backend = mkOption { | ||
type = types.enum [ "podman" ]; | ||
default = defaultBackend; | ||
description = "Which service to use as a backend for containers."; | ||
}; | ||
}; | ||
|
||
config = mkIf (cfg.enable && cfg.backend == "podman") { | ||
virtualisation.podman.enable = true; | ||
}; | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand what "convenience option" means here? I think this should just be "containers"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is taken from
nixpkgs
https://github.com/NixOS/nixpkgs/blob/ec68439bdc77ee684a4b2846f03677c5c50920a9/nixos/modules/virtualisation/oci-containers.nix#L335-L349The problem with
containers
is that it used bypodman
. I'm not versed enough in nix and nixpkgs to not create a recursion problem withcontainers.enable
usingcontainers.backend
to enablepodman
which itself then setscontainers.enable
and configures the settings and other stuff. I gave it a shot and immediately ran into recursion errors.Since
nixpkgs
doesn't bother with that, I erred on the side of "they probably know better what they're doing that some 1 year nix scrub like me".