Skip to content

Repository files navigation

system-flakes — NixOS-WSL/Home Manger configuration

This project is based on the flake-parts' ez-configs module, with binary caching supported by Cachix.

Custom commands

To push a specific version of the flake inputs to the cache, run this command on the root of a local checkout of this repository:

flake-archive | cachix-cache push

Useful commands

nix flake show

Show the outpus provided by a flake.

Variants:

  • nix flake show . --no-pure-eval
  • nix flake show 'github:nix-community/NixOS-WSL'
  • nix flake show 'github:karaolidis/NixOS-WSL/wl-clipboard-wsl'
  • nix flake show 'github:nixos/nixpkgs/nixpkgs-unstable'

nix run

Run a Nix application.

Variants:

  • nix run 'github:nixos/nixpkgs/nixpkgs-unstable#jq'

glxinfo -B

Variants:

  • nix run 'github:nixos/nixpkgs/nixpkgs-unstable#jq'
  • GALLIUM_DRIVER=d3d12 MESA_D3D12_DEFAULT_ADAPTER_NAME=NVIDIA glxinfo -B | grep "OpenGL renderer"

vulkaninfo

Variants:

  • vulkaninfo --summary

Garbage collecting

nix-collect-garbage --delete-old 2>&1 | tail -n 10
deleting '/nix/store/2gnb756mawrfc4dbn3yv81l4xzj041p3-python3.14-isort-8.0.1'
deleting '/nix/store/12qfwcqn2nwa9lbjx6ycx8acbyx57hbf-source.drv'
deleting '/nix/store/5ska9gv7cnn8c6n165ldbs9sh70yhg68-source'
deleting '/nix/store/fkqc9qh7vsv4pdbskx395hrdrxvpybmj-source.drv'
deleting '/nix/store/hl8ixlmpd3qzdqd0xy0j6rl665fgb2wy-nlohmann_json-3.12.0'
deleting '/nix/store/z25irbb8f4gv5l4i6qq5wjqz3872p852-source'
deleting '/nix/store/a3kjvvlm7f8abcmxh6f8dndiwc4vp726-clang-21.1.8-lib'
deleting unused links...
note: hard linking is currently saving 26.6 GiB
501 store paths deleted, 5.5 GiB freed
sudo nix-collect-garbage --delete-old 2>&1 | tail -n 10
deleting '/nix/store/850b4zyayws7mkdyx5zqixzpag2c44g3-unit-home-manager-tarci.service.drv'
deleting '/nix/store/3znpblzlgnlhy9g5jdbrafr34cpcfb28-unit-home-manager-tarci.service'
deleting '/nix/store/px8ssq044g81jgal46p04a8fh2r0jqpm-home-manager-generation'
deleting '/nix/store/wl7pmzg97ys7h0g2d2ljkk2sys8pji8b-home-manager-path'
deleting '/nix/store/vh9nbjysif1l84b0p98ds0v1jd7r12cx-home-manager-generation.drv'
deleting '/nix/store/d3rxsi829hg1vhc0hw2cwbgz887fn0ss-activation-script.drv'
deleting '/nix/store/k83dswfmz40nmcssh3vqqsk95skvm1i2-home-manager-path.drv'
deleting unused links...
note: hard linking is currently saving 26.6 GiB
14 store paths deleted, 2.9 MiB freed

nix fmt

Calls the flake default formatter.

Warning

This will run commands embedded in markdown.

After a successful and non-idempotent just switch, it may make sense to free up disk space by running nix-collect-garbage. Formatting the README.md file is an unusual way to accomplish this:

touch README.md
nix fmt

Optimizing VHD size

Be sure to know the name of your WSL distribution:

wsl --list -v
  NAME                      STATE           VERSION
* NixOS                     Running         2
  podman-machine-default    Stopped         2
  docker-desktop            Stopped         2

It must not be sparsed already:

wsl --manage NixOS --set-sparse false

Learn the path of its VHDX file:

Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Lxss\*"
State               : 1
Version             : 2
BasePath            : C:\Users\tarci\AppData\Local\wsl\{7527fb51-83d7-4564-bc19-617c2e6b096a}
Flags               : 15
DefaultUid          : 0
RunOOBE             : 0
VhdFileName         : ext4.vhdx
DistributionName    : NixOS
Modern              : 1
ShortcutPath        : C:\Users\tarci\AppData\Roaming\Microsoft\Windows\Start Menu\NixOS.lnk
TerminalProfilePath : C:\Users\tarci\AppData\Local\Microsoft\Windows Terminal\Fragments\Microsoft.WSL\{96dc692a-1006-5fa5-bc6b-f63e8df2226b}.json
Flavor              : nixos
OsVersion           : 26.11
PSPath              : Microsoft.PowerShell.Core\Registry::HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss\{7527fb51-83d7-4564-bc19-617c2e6b096a}
PSParentPath        : Microsoft.PowerShell.Core\Registry::HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss
PSChildName         : {7527fb51-83d7-4564-bc19-617c2e6b096a}
PSDrive             : HKCU
PSProvider          : Microsoft.PowerShell.Core\Registry

Optimize the disk:

optimize-vhd -Path  'C:\Users\tarci\AppData\Local\wsl\{7527fb51-83d7-4564-bc19-617c2e6b096a}\ext4.vhdx'  -Mode full

(Re)Enable sparse mode:

wsl --manage NixOS --set-sparse true --allow-unsafe

Related projects

References

Troubleshooting

home.pointerCursor = {
  gtk.enable = true;
  x11.enable = true;
  package = pkgs.vanilla-dmz;
  name = "Vanilla-DMZ";
  size = 28;
};

Verify:

env | grep -i cursor

Expected:

XCURSOR_PATH=/home/tarci/.nix-profile/share/icons:/home/tarci/.icons:/home/tarci/.local/share/icons:/home/tarci/.nix-profile/share/icons:/home/tarci/.nix-profile/share/pixmaps:/nix/profile/share/icons:/nix/profile/share/pixmaps:/home/tarci/.local/state/nix/profile/share/icons:/home/tarci/.local/state/nix/profile/share/pixmaps:/etc/profiles/per-user/tarci/share/icons:/etc/profiles/per-user/tarci/share/pixmaps:/nix/var/nix/profiles/default/share/icons:/nix/var/nix/profiles/default/share/pixmaps:/run/current-system/sw/share/icons:/run/current-system/sw/share/pixmaps
XCURSOR_SIZE=28
XCURSOR_THEME=Vanilla-DMZ

About

NixOS-WSL/home-manager configuration — read-only mirror of codeberg.org/tarcisio/system-flakes

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages