diff --git a/flake.lock b/flake.lock index bec3755..c799bdb 100644 --- a/flake.lock +++ b/flake.lock @@ -142,6 +142,22 @@ "url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz" } }, + "flake-compat_2": { + "flake": false, + "locked": { + "lastModified": 1765121682, + "narHash": "sha256-4VBOP18BFeiPkyhy9o4ssBNQEvfvv1kXkasAYd0+rrA=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "65f23138d8d09a92e30f1e5c87611b23ef451bf3", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, "flake-parts": { "inputs": { "nixpkgs-lib": [ @@ -462,6 +478,28 @@ "type": "github" } }, + "nixos-wsl": { + "inputs": { + "flake-compat": "flake-compat_2", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1765483419, + "narHash": "sha256-w6wznH1lBzlSH3+pWDkE+L6xA0F02drFAzu2E7PD/Jo=", + "owner": "nix-community", + "repo": "NixOS-WSL", + "rev": "0c040f28b44b18e0d4240e027096078e34dbb029", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "main", + "repo": "NixOS-WSL", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1732981179, @@ -574,6 +612,7 @@ "lazyvim-nixvim": "lazyvim-nixvim", "nixos-generators": "nixos-generators", "nixos-hardware": "nixos-hardware", + "nixos-wsl": "nixos-wsl", "nixpkgs": "nixpkgs_2", "nixpkgs-old-kernel": "nixpkgs-old-kernel", "vscode-server": "vscode-server" diff --git a/flake.nix b/flake.nix index deea56b..15717e8 100644 --- a/flake.nix +++ b/flake.nix @@ -47,6 +47,12 @@ url = "github:nix-community/nixos-generators"; inputs.nixpkgs.follows = "nixpkgs"; }; + + # WSL Support + nixos-wsl = { + url = "github:nix-community/NixOS-WSL/main"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; outputs = inputs@{ diff --git a/hosts/types/nix-wsl.nix b/hosts/types/nix-wsl.nix new file mode 100644 index 0000000..acae4ca --- /dev/null +++ b/hosts/types/nix-wsl.nix @@ -0,0 +1,28 @@ +{ inputs, ... }: +[ + inputs.nixos-wsl.nixosModules.default + inputs.vscode-server.nixosModules.default + ({ lib, ... }: { + wsl.enable = true; + wsl.defaultUser = "engr-ugaif"; + + # Enable the headless software profile + modules.sw.enable = true; + modules.sw.type = "headless"; + + # Fix for VS Code Server in WSL if needed, though vscode-server input exists + services.vscode-server.enable = true; + + # Disable Disko and Bootloader for WSL + disko.enableConfig = lib.mkForce false; + boot.loader.systemd-boot.enable = lib.mkForce false; + boot.loader.grub.enable = lib.mkForce false; + + # Disable networking for wsl (it manages its own networking) + systemd.network.enable = lib.mkForce false; + + # Provide dummy values for required options from boot.nix + host.filesystem.device = "/dev/null"; + host.filesystem.swapSize = "0G"; + }) +] diff --git a/inventory.nix b/inventory.nix index e1f09f4..6dad491 100644 --- a/inventory.nix +++ b/inventory.nix @@ -61,6 +61,16 @@ }; }; + # WSL Configuration + nix-wsl = { + count = 1; + devices = { + "1" = { + hostname = "nix-wsl-alireza"; + }; + }; + }; + # Ephemeral Configuration (Live ISO / Netboot) nix-ephemeral.count = 1; } diff --git a/users.nix b/users.nix index 14e627d..653a547 100644 --- a/users.nix +++ b/users.nix @@ -38,5 +38,13 @@ # Example of using an external flake for configuration: # flakeUrl = "github:hdh20267/dotfiles"; }; + sv22900 = { + description = "Alireza Vaezi"; + extraGroups = [ + "networkmanager" + "wheel" + ]; + shell = pkgs.zsh; + }; }; }