summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAlex Jackson <ajaxbits@pm.me>2022-04-18 13:39:33 +0000
committerAlex Jackson <ajaxbits@pm.me>2022-04-18 13:39:33 +0000
commit06adb40b4892dcc0aeb5bb74c04d9c93323d4bef (patch)
tree2aaef704cb71023a2de07a07f38691b5a13a9d04 /modules
parentc4b7e5f11dfde3cbc6e53c17fd4534db4b8cd69d (diff)
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.
Diffstat (limited to 'modules')
-rw-r--r--modules/docker-native.nix31
1 files changed, 31 insertions, 0 deletions
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
+ ];
+ };
+
+}