mirror of
https://github.com/sstent/vmimages.git
synced 2025-12-06 06:01:51 +00:00
85 lines
2.6 KiB
Nix
85 lines
2.6 KiB
Nix
{
|
|
lib,
|
|
inputs,
|
|
outputs,
|
|
config,
|
|
pkgs,
|
|
...
|
|
}:
|
|
with lib; let
|
|
cfg = config.custom.wsl;
|
|
in {
|
|
options.custom.wsl.enable = mkEnableOption "Enable WSL2 settings";
|
|
|
|
config = mkIf cfg.enable {
|
|
# Enable native Docker support
|
|
virtualisation.docker.enable = true;
|
|
|
|
wsl.extraBin = [
|
|
# Required by VS Code's Remote WSL extension
|
|
# Required by VS Code's Remote WSL extension
|
|
{src = "${pkgs.coreutils}/bin/dirname";}
|
|
{src = "${pkgs.coreutils}/bin/readlink";}
|
|
{src = "${pkgs.coreutils}/bin/uname";}
|
|
{src = "${pkgs.coreutils}/bin/mkdir";}
|
|
{src = "${pkgs.coreutils}/bin/rm";}
|
|
{src = "${pkgs.coreutils}/bin/wc";}
|
|
{src = "${pkgs.coreutils}/bin/date";}
|
|
{src = "${pkgs.coreutils}/bin/mv";}
|
|
{src = "${pkgs.coreutils}/bin/sleep";}
|
|
{src = "${pkgs.gnutar}/bin/tar";}
|
|
{src = "${pkgs.gzip}/bin/gzip";}
|
|
];
|
|
# programs.nix-ld = {
|
|
# enable = true;
|
|
# libraries = [
|
|
# # Required by NodeJS installed by VS Code's Remote WSL extension
|
|
# pkgs.stdenv.cc.cc
|
|
# ];
|
|
|
|
# # Use `nix-ld-rs` instead of `nix-ld`, because VS Code's Remote WSL extension launches a non-login non-interactive shell, which is not supported by `nix-ld`, while `nix-ld-rs` works in non-login non-interactive shells.
|
|
# package = inputs.nix-ld-rs.packages.${pkgs.system}.nix-ld-rs;
|
|
# };
|
|
|
|
wsl = {
|
|
enable = true;
|
|
wslConf.automount.root = "/mnt";
|
|
defaultUser = "sstent";
|
|
startMenuLaunchers = true;
|
|
wslConf.network.generateResolvConf = false;
|
|
# wslConf.interop.appendWindowsPath = false;
|
|
#No longer needed in 23.05
|
|
#interop.preserveArgvZero = true;
|
|
# docker-native.enable = true;
|
|
|
|
#nativeSystemd = true;
|
|
# Enable integration with Docker Desktop (needs to be installed)
|
|
# docker-desktop.enable = true;
|
|
};
|
|
|
|
systemd.services.nixs-wsl-systemd-fix = {
|
|
description = "Fix the /dev/shm symlink to be a mount";
|
|
unitConfig = {
|
|
DefaultDependencies = "no";
|
|
Before = [
|
|
"sysinit.target"
|
|
"systemd-tmpfiles-setup-dev.service"
|
|
"systemd-tmpfiles-setup.service"
|
|
"systemd-sysctl.service"
|
|
];
|
|
ConditionPathExists = "/dev/shm";
|
|
ConditionPathIsSymbolicLink = "/dev/shm";
|
|
ConditionPathIsMountPoint = "/run/shm";
|
|
};
|
|
serviceConfig = {
|
|
Type = "oneshot";
|
|
ExecStart = [
|
|
"${pkgs.coreutils-full}/bin/rm /dev/shm"
|
|
"/run/wrappers/bin/mount --bind -o X-mount.mkdir /run/shm /dev/shm"
|
|
];
|
|
};
|
|
wantedBy = ["sysinit.target"];
|
|
};
|
|
};
|
|
}
|