summaryrefslogtreecommitdiff
path: root/modules/nixos/podman.nix
blob: ec9b3461be96a268ad219b429319b06e2dbe68d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
{
  config,
  inputs,
  lib,
  pkgs,
  ...
}:
with lib; let
  cfg = config.nixfiles.modules.podman;
in {
  options.nixfiles.modules.podman.enable = mkEnableOption "Podman";

  config = mkIf cfg.enable {
    assertions = [
      {
        assertion = !config.nixfiles.modules.docker.enable;
        message = "Pick only one!";
      }
    ];

    secrets.containers-auth = {
      file = "${inputs.self}/secrets/containers-auth";
      path = "${config.dirs.config}/containers/auth.json";
      owner = my.username;
      inherit (config.my) group;
    };

    virtualisation.podman.enable = true;

    environment.systemPackages = with pkgs; [podman-compose];

    my.extraGroups = ["podman"];

    hm = {
      xdg.configFile = {
        # This removes a really annoying registry search. 100% of the time I
        # would need to look up stuff from the Docker and not Quay!
        "containers/registries.conf".text = ''
          [registries.search]
          registries = ["docker.io"]
        '';

        # As for plain OverlayFS in Podman over ZFS[1]... I guess we are waiting
        # for Podman to catch up now.
        #
        # [1]: https://github.com/openzfs/zfs/pull/14070#issuecomment-1309116666
        "containers/storage.conf".text = optionalString config.boot.zfs.enabled ''
          [storage]
          driver = "overlay"

          [storage.options]
          mount_program = "${pkgs.fuse-overlayfs}/bin/fuse-overlayfs"
          mountopt = "noatime,nodev,nosuid"
        '';
      };

      programs.bash = {
        shellAliases = {
          podman = "grc -es ${pkgs.podman}/bin/podman";
          p = "podman";
        };
        initExtra = mkAfter ''
          _complete_alias p __start_podman podman
        '';
      };
    };
  };
}