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

43 lines
985 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
imports = [
2023-06-18 00:46:31 +00:00
(mkRenamedOptionModule ["wsl" "docker"] ["wsl" "docker-desktop"])
2022-08-30 14:29:44 +00:00
];
options.wsl.docker-desktop = with types; {
enable = mkEnableOption "Docker Desktop integration";
};
2023-06-18 00:46:31 +00:00
config = let
cfg = config.wsl.docker-desktop;
in
2022-08-30 14:29:44 +00:00
mkIf (config.wsl.enable && cfg.enable) {
environment.systemPackages = with pkgs; [
docker
docker-compose
];
systemd.services.docker-desktop-proxy = {
description = "Docker Desktop proxy";
script = ''
${config.wsl.automountPath}/wsl/docker-desktop/docker-desktop-user-distro proxy --docker-desktop-root ${config.wsl.automountPath}/wsl/docker-desktop
'';
2023-06-18 00:46:31 +00:00
wantedBy = ["multi-user.target"];
2022-08-30 14:29:44 +00:00
serviceConfig = {
Restart = "on-failure";
RestartSec = "30s";
};
};
users.groups.docker.members = [
config.wsl.defaultUser
];
};
}