dotfiles/nix-conf/system/nixos-wsl/modules/docker-native.nix

45 lines
1016 B
Nix
Raw Normal View History

2023-06-18 00:46:31 +00:00
{
config,
lib,
pkgs,
...
}:
with builtins;
with lib; {
2022-08-30 14:29:44 +00:00
options.wsl.docker-native = with types; {
enable = mkEnableOption "Native Docker integration in NixOS.";
addToDockerGroup = mkOption {
type = bool;
default = config.security.sudo.wheelNeedsPassword;
description = ''
Wether to add the default user to the docker group.
This is not recommended, if you have a password, because it essentially permits unauthenticated root access.
'';
};
};
2023-06-18 00:46:31 +00:00
config = let
cfg = config.wsl.docker-native;
in
2022-08-30 14:29:44 +00:00
mkIf (config.wsl.enable && cfg.enable) {
nixpkgs.overlays = [
(self: super: {
2023-06-18 00:46:31 +00:00
docker = super.docker.override {iptables = pkgs.iptables-legacy;};
2022-08-30 14:29:44 +00:00
})
];
environment.systemPackages = with pkgs; [
docker
docker-compose
];
virtualisation.docker.enable = true;
users.groups.docker.members = lib.mkIf cfg.addToDockerGroup [
config.wsl.defaultUser
];
};
}