Skip to content
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

nixos/virtualisation: add hostname option to oci-containers. #258299

Merged
merged 1 commit into from
Nov 5, 2023
Merged

nixos/virtualisation: add hostname option to oci-containers. #258299

merged 1 commit into from
Nov 5, 2023

Conversation

Arcayr
Copy link
Contributor

@Arcayr Arcayr commented Sep 30, 2023

Description of changes

Adds the hostname option to the virtualisation.oci-containers.<name> set. This maps to the --hostname argument for podman and docker. While they can be set using extraOptions it's nicer to not. Being able to set the hostname also allows for dynamic container lookup using dnsmasq or systemd-resolved with the podman dns resolver.

Reviewed points
  • changes are backward compatible
    • hostname is optional.
  • removed options are declared with mkRemovedOptionModule
  • changes that are not backward compatible are documented in release notes
  • module tests succeed on ARCHITECTURE
  • options types are appropriate
  • options description is set
  • options example is provided
  • documentation affected by the changes is updated
    • option documentation added.
Possible improvements
Comments

Testing with the following set:

virtualisation.oci-containers.containers = {
    "hello-world" = {
      image = "docker.io/library/hello-world:latest";
      autoStart = true;
      hostname = "not-hello-world.podman";
    };
  };
$ sudo podman inspect hello-world | jq .[].Config.Hostname
"not-hello-world.podman"
$ cat /nix/store/qz4z7mnadd69p7qhi637sgng6mf75gzg-unit-script-podman-hello-world-start/bin/podman-hello-world-start
set -e
exec podman run \
  --rm \
  --name='hello-world' \
  --log-driver=journald \
  --hostname='not-hello-world.podman' \
  --cidfile=/run/podman-'hello-world'.ctr-id \
  --cgroups=no-conmon \
  --sdnotify=conmon \
  -d \
  --replace \
  docker.io/library/hello-world:latest

@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` labels Sep 30, 2023
@Arcayr Arcayr requested a review from a team September 30, 2023 23:35
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild 10.rebuild-linux: 1-10 labels Sep 30, 2023
Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🐯

@Arcayr Arcayr added the 12.approvals: 1 This PR was reviewed and approved by one reputable person label Oct 2, 2023
@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-already-reviewed/2617/1200

@adisbladis adisbladis merged commit a1592fb into NixOS:master Nov 5, 2023
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild 10.rebuild-linux: 1-10 12.approvals: 1 This PR was reviewed and approved by one reputable person
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants