about summary refs log tree commit diff
path: root/modules/nixos/docker.nix
blob: e64203082a8f2cdb487de185544bcfdc63f1086b (plain) (blame)
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 = "${pkgs.docker}/bin/docker";
      initExtra = mkAfter ''
        _complete_alias d _docker docker
      '';
    };
  };
}

Consider giving Nix/NixOS a try! <3