add a module for docker-desktop support

This commit is contained in:
nzbr
2022-02-08 12:23:46 +01:00
parent cc0e502b51
commit e844679c6a
4 changed files with 45 additions and 0 deletions
+7
View File
@@ -0,0 +1,7 @@
use_flake() {
watch_file flake.nix
watch_file flake.lock
eval "$(nix print-dev-env)"
}
use flake
+4
View File
@@ -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
+1
View File
@@ -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 {
+33
View File
@@ -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
];
};
}