From 06adb40b4892dcc0aeb5bb74c04d9c93323d4bef Mon Sep 17 00:00:00 2001 From: Alex Jackson Date: Mon, 18 Apr 2022 13:39:33 +0000 Subject: add docker-native module for native docker support in NixOS Addresses [#59](https://github.com/nix-community/NixOS-WSL/issues/59#issuecomment-1092657189) by overlaying legacy iptables on the docker package. --- modules/docker-native.nix | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 modules/docker-native.nix (limited to 'modules') diff --git a/modules/docker-native.nix b/modules/docker-native.nix new file mode 100644 index 0000000..a8396e7 --- /dev/null +++ b/modules/docker-native.nix @@ -0,0 +1,31 @@ +{ config, lib, pkgs, ... }: +with builtins; with lib; { + + options.wsl.docker-native = with types; { + enable = mkEnableOption "Native Docker integration in NixOS."; + }; + + config = + let + cfg = config.wsl.docker-native; + in + mkIf (config.wsl.enable && cfg.enable) { + nixpkgs.overlays = [ + (self: super: { + docker = super.docker.override { iptables = pkgs.iptables-legacy; }; + }) + ]; + + environment.systemPackages = with pkgs; [ + docker + docker-compose + ]; + + virtualisation.docker.enable = true; + + users.groups.docker.members = [ + config.wsl.defaultUser + ]; + }; + +} -- cgit v1.2.3