about summary refs log tree commit diff
path: root/modules/nixos/docker.nix
blob: 62dc095d03ae61afec28233769621884c2890f43 (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
{
  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 = cfg.enable -> !config.nixfiles.modules.podman.enable;
        message = "Pick only one!";
      }
    ];

    nixfiles.modules.common.shell.aliases.d = "docker";

    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" ];
  };
}

Consider giving Nix/NixOS a try! <3