From ff57c8dc58f707299379fd538c6b6ec77980f7cf Mon Sep 17 00:00:00 2001 From: nzbr Date: Tue, 12 Sep 2023 12:19:14 +0200 Subject: Refactor (#291) * move module imports to default.nix * move docker modules to subdirectory * add an otion for adding files to /bin. Fixes #279 * move recovery script to own module * reorder options * move systemd related code to separate modules * move utils to repo root * devShell -> devShells.default * fix utils imports * fix bashWrapper --- modules/docker/native.nix | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 modules/docker/native.nix (limited to 'modules/docker/native.nix') diff --git a/modules/docker/native.nix b/modules/docker/native.nix new file mode 100644 index 0000000..88f48d9 --- /dev/null +++ b/modules/docker/native.nix @@ -0,0 +1,34 @@ +{ config, lib, pkgs, ... }: +with builtins; with lib; { + + 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. + ''; + }; + }; + + config = + let + cfg = config.wsl.docker-native; + in + mkIf (config.wsl.enable && cfg.enable) { + environment.systemPackages = with pkgs; [ + docker-compose + ]; + + virtualisation.docker.package = (pkgs.docker.override { iptables = pkgs.iptables-legacy; }); + virtualisation.docker.enable = true; + + users.groups.docker.members = lib.mkIf cfg.addToDockerGroup [ + config.wsl.defaultUser + ]; + }; +} -- cgit v1.2.3