1
0
mirror of https://github.com/nix-community/home-manager synced 2024-06-01 04:23:34 +02:00
home-manager/modules/virtualisation/podman/podmactl
Michael Vogel faa4b16358
podman: add module
This module is a continuation of #2630 by MaeIsBad.

It also adds a module `virtualisation.oci-containers` that is
equivalent to the one in NixOS. Basically it allows a simple toggle to
activate oci-container services and commands.

We also support Podman on mac. Note, Podman requires a VM on mac,
which has to be started before any Podman commands can be executed.
Users might sometimes require VMs that use different architectures
than the default VM started by Podman. Thus, they get the option to
define the VM(s) that will be initialized and started by podman.

Since Podman has to start a machine, it's best to do it using launchd.
The configuration of the machines requires a JSON, generated from an
attrset in Home Manager, which is where Python script comes into play
to take care of diff-ing the `podman machine list` to CRUD them.

PR #4331

Co-authored-by: MaeIsBad <26093674+MaeIsBad@users.noreply.github.com>
2023-12-23 17:27:37 +01:00
..
default.nix podman: add module 2023-12-23 17:27:37 +01:00
podmactl.py podman: add module 2023-12-23 17:27:37 +01:00
README.md podman: add module 2023-12-23 17:27:37 +01:00
shell.nix podman: add module 2023-12-23 17:27:37 +01:00
test_podmactl.py podman: add module 2023-12-23 17:27:37 +01:00

podmactl

podmactl is a script to manage the podman machines declared in Home Manager.

How it works

main() is a (hopefully) straight-forward method to read, but the gist of it is:

  1. The declared machines and their configuration are passed in.
  2. Existing machines and their configuration are listed.
  3. A diff is made from the declared machines and existing machines.
  4. New machines are added.
  5. Existing machines are updated.
  6. Old machines are removed.
  7. The machine declared as active is started (if necessary).

Developing

Enter a devshell with nix-shell.

Make your changes and then run

# Code autoformatting
black .

# Unittests
python -m unittest