mirror of
https://github.com/nix-community/NixOS-WSL.git
synced 2026-11-07 14:59:35 +00:00
add a module for docker-desktop support
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
use_flake() {
|
||||
watch_file flake.nix
|
||||
watch_file flake.lock
|
||||
eval "$(nix print-dev-env)"
|
||||
}
|
||||
|
||||
use flake
|
||||
@@ -12,6 +12,7 @@ in
|
||||
"${modulesPath}/profiles/minimal.nix"
|
||||
|
||||
build-tarball
|
||||
docker-desktop
|
||||
wsl-distro
|
||||
];
|
||||
|
||||
@@ -20,6 +21,9 @@ in
|
||||
automountPath = "/mnt";
|
||||
defaultUser = "nixos";
|
||||
startMenuLaunchers = true;
|
||||
|
||||
# Enable integration with Docker Desktop (needs to be installed)
|
||||
# docker.enable = true;
|
||||
};
|
||||
|
||||
# Enable nix-flakes by default
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
nixosModules = {
|
||||
build-tarball = import ./modules/build-tarball.nix;
|
||||
wsl-distro = import ./modules/wsl-distro.nix;
|
||||
docker-desktop = import ./modules/docker-desktop.nix;
|
||||
};
|
||||
|
||||
nixosConfigurations.mysystem = nixpkgs.lib.nixosSystem {
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
with builtins; with lib; {
|
||||
|
||||
options.wsl.docker = with types; {
|
||||
enable = mkEnableOption "Docker Desktop integration";
|
||||
};
|
||||
|
||||
config =
|
||||
let
|
||||
cfg = config.wsl.docker;
|
||||
in
|
||||
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-proxy -docker-desktop-root ${config.wsl.automountPath}/wsl/docker-desktop
|
||||
'';
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
};
|
||||
|
||||
users.groups.docker.members = [
|
||||
config.wsl.defaultUser
|
||||
];
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user