From 9e1b423720f67d54f0825a404f22d7612079c741 Mon Sep 17 00:00:00 2001 From: Frank LoTurco Date: Fri, 9 Oct 2026 13:14:57 -0400 Subject: [PATCH] devenv: add support for compiling to msvc targets with llvm/clang --- .gitignore | 4 ++++ devenv.nix | 24 +++++++++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index da23fc6..e4a4ce1 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,7 @@ workspaces/** # wine wineprefix + +# msvc +xwin +.xwin-cache diff --git a/devenv.nix b/devenv.nix index 4b59c14..95bd0da 100644 --- a/devenv.nix +++ b/devenv.nix @@ -29,6 +29,8 @@ in pkg-config tree unzip + lld + xxd ]; languages = { @@ -47,11 +49,27 @@ in WINEPREFIX = "${config.env.DEVENV_ROOT}/wineprefix"; }; - enterShell = '' - wineboot + scripts = { + "clang-msvc".exec = '' + clang-cl -v -fuse-ld=lld -target x86_64-pc-windows-msvc \ + -vctoolsdir $DEVENV_ROOT/xwin/crt -winsdkdir $DEVENV_ROOT/xwin/sdk \ + "$@" \ + /link /subsystem:console + ''; + }; - if [[ ! -e ./workspaces ]]; then + enterShell = '' + if [[ ! -e ${config.env.DEVENV_ROOT}/wineprefix ]]; then + wineboot + fi + + if [[ ! -e ${config.env.DEVENV_ROOT}/workspaces ]]; then mkdir ./workspaces fi + + if [[ ! -e ${config.env.DEVENV_ROOT}/xwin ]]; then + cargo install xwin + xwin --accept-license splat --preserve-ms-arch-notation --output ./xwin + fi ''; }