summaryrefslogtreecommitdiff
path: root/modules/nixos/docker.nix
blob: 31c0dda551405b0f19c3867f00ce54779c8ddbb5 (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
{
  config,
  inputs,
  lib,
  pkgs,
  ...
}:
with lib; let
  cfg = config.nixfiles.modules.docker;
in {
  options.nixfiles.modules.docker.enable = mkEnableOption "Docker";

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

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

    virtualisation.docker.enable = true;

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

    my.extraGroups = ["docker"];

    hm.programs.bash = {
      shellAliases.d = "docker";
      initExtra = mkAfter ''
        _complete_alias d _docker docker
      '';
    };
  };
}