Skip to content

Commit

Permalink
Optimize NixOS-WSL
Browse files Browse the repository at this point in the history
  • Loading branch information
573 committed Nov 8, 2024
1 parent 6a97c37 commit 4181d9f
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 28 deletions.
17 changes: 17 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions home/programs/helix.nix
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ in
name = "nix";
formatter.command = "nixfmt";
language-servers = [
language-server.nixd = with pkgs.nixd; [
command = "${nixd}/bin/nixd";
args = ["--inlay-hints" "--semantic-tokens"];
config.nixd.options.home-manager.expr = '(builtins.getFlake "${rootDir}").homeConfigurations.nix-on-droid.options';
# language-server.nixd = with pkgs.nixd; [
# command = "${nixd}/bin/nixd";
# args = ["--inlay-hints" "--semantic-tokens"];
# config.nixd.options.home-manager.expr = '(builtins.getFlake "${rootDir}").homeConfigurations.nix-on-droid.options';
];
}
{
Expand Down
30 changes: 17 additions & 13 deletions nixos/programs/docker.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
Same as written in ./../../flake/builders/mkNixos.nix should apply here (regarding `specialArgs` injection) as the anonymous module is a module next to `"${rootPath}/hosts/${name}/configuration.nix"` there
*/
{
config,
lib, # unstable,
{ config
, lib
, # unstable,
...
}:

Expand Down Expand Up @@ -40,28 +40,32 @@ in
# https://github.com/nix-community/NixOS-WSL/issues/433
# https://github.com/nix-community/NixOS-WSL/pull/478
virtualisation = {
# see https://github.com/nix-community/NixOS-WSL/issues/578 and https://github.com/nix-community/NixOS-WSL/discussions/487
docker = {
enable = true;
#package = pkgs.docker_24; #unstable.docker_25;
# enableNvidia = true;

storageDriver = "overlay2";
###storageDriver = "overlay2";
# https://github.com/NVIDIA/nvidia-docker/issues/942
#virtualisation.docker.enableNvidia = true;
# TODO Encapsulate in work.enable the case where rootless is not used
rootless = {
enable = true;
# for the "whole" discussion of it (rootless or not) i. e. https://discourse.nixos.org/t/docker-rootless-with-nvidia-support/37069
setSocketVariable = true; # false for driver exact support
/*
daemon.settings = {
runtimes = {
nvidia = {
path = "${pkgs.nvidia-docker}/bin/nvidia-container-runtime";
};
};
};
*/
daemon.settings = {
/* runtimes = {
nvidia = {
path = "${pkgs.nvidia-docker}/bin/nvidia-container-runtime";
};
}; */
features.cdi = true;
cdi-spec-dirs = [ "/home/${username}/.cdi" ];
};
};
daemon.settings = {
features.cdi = true;
};
};
};
Expand Down
31 changes: 20 additions & 11 deletions nixos/system/nvidia.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
config,
lib,
system,
...
{ config
, lib
, system
, ...
}:

let
Expand Down Expand Up @@ -35,10 +34,20 @@ in
# enable32Bit = true;
#};
# TODO Separate nvidia.nix
hardware.opengl = {
enable = true;
driSupport32Bit = true;
hardware = {
opengl = {
enable = true;
driSupport32Bit = true;
};
nvidia = {
modesetting.enable = true;
nvidiaSettings = false;
open = false;
};
nvidia-container-toolkit.enable = true;
};

services.xserver.videoDrivers = [ "nvidia" ];
/*
# Load nvidia driver for Xorg and Wayland
services.xserver.videoDrivers = [ "nvidia" ];
Expand All @@ -63,7 +72,7 @@ in
open = false;
# Enable the Nvidia settings menu,
# accessible via `nvidia-settings`.
# accessible via `nvidia-settings`.
nvidiaSettings = true;
# Optionally, you may need to select the appropriate driver version for your specific GPU.
Expand All @@ -72,8 +81,8 @@ in
environment.systemPackages = attrValues {# with pkgs; [
inherit (unstable.cudaPackages)
cudatoolkit
;
cudatoolkit
;
};
*/
};
Expand Down
20 changes: 20 additions & 0 deletions nixos/wsl/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,26 @@ in
stdenv.cc.cc # for libstdc++.so.6
];
};

services.locate = {
enable = true;
localuser = null; # silence warning
package = pkgs.plocate; # use faster locate implementation
prunePaths = [
"/media"
"/mnt/c" # don't index windows drives in WSL
"/mnt/d"
"/mnt/e"
"/mnt/f"
"/mnt/wsl"
"/nix/store"
"/nix/var/log/nix"
"/tmp"
"/var/spool"
"/var/tmp"
];
};

/*
environment.variables = {
NIX_LD_LIBRARY_PATH = lib.mkDefault (lib.makeLibraryPath [
Expand Down

0 comments on commit 4181d9f

Please sign in to comment.