From 560e8e5a0087a8a9a5d6d1401f79fae0c761ecff Mon Sep 17 00:00:00 2001 From: Michael Thomson Date: Tue, 8 Jul 2025 14:52:17 +0000 Subject: [PATCH] update: add WSL --- flake.lock | 61 ++++++++++++++++++++++++++++++++++--- flake.nix | 9 ++++++ hosts/wsl/configuration.nix | 42 +++++++++++++++++++++++++ hosts/wsl/home.nix | 26 ++++++++++++++++ 4 files changed, 134 insertions(+), 4 deletions(-) create mode 100644 hosts/wsl/configuration.nix create mode 100644 hosts/wsl/home.nix diff --git a/flake.lock b/flake.lock index dd65459..24429a3 100644 --- a/flake.lock +++ b/flake.lock @@ -133,6 +133,22 @@ } }, "flake-compat_2": { + "flake": false, + "locked": { + "lastModified": 1747046372, + "narHash": "sha256-CIVLLkVgvHYbgI2UpXvIIBJ12HWgX+fjA8Xf8PUmqCY=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "9100a0f413b0c601e0533d1d94ffd501ce2e7885", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_3": { "locked": { "lastModified": 1747046372, "narHash": "sha256-CIVLLkVgvHYbgI2UpXvIIBJ12HWgX+fjA8Xf8PUmqCY=", @@ -703,6 +719,26 @@ "type": "github" } }, + "nixos-wsl": { + "inputs": { + "flake-compat": "flake-compat_2", + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1749574455, + "narHash": "sha256-fm2/8KPOYvvIAnNVtjDlTt/My00lIbZQ+LMrfQIWVzs=", + "owner": "nix-community", + "repo": "NixOS-WSL", + "rev": "917af390377c573932d84b5e31dd9f2c1b5c0f09", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "main", + "repo": "NixOS-WSL", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1750365781, @@ -752,6 +788,22 @@ } }, "nixpkgs_2": { + "locked": { + "lastModified": 1749173751, + "narHash": "sha256-ENY3y3v6S9ZmLDDLI3LUT8MXmfXg/fSt2eA4GCnMVCE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "ed29f002b6d6e5e7e32590deb065c34a31dc3e91", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-24.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { "locked": { "lastModified": 1750741721, "narHash": "sha256-Z0djmTa1YmnGMfE9jEe05oO4zggjDmxOGKwt844bUhE=", @@ -767,7 +819,7 @@ "type": "github" } }, - "nixpkgs_3": { + "nixpkgs_4": { "locked": { "lastModified": 1748460289, "narHash": "sha256-7doLyJBzCllvqX4gszYtmZUToxKvMUrg45EUWaUYmBg=", @@ -895,7 +947,8 @@ "nix-on-droid": "nix-on-droid", "nixCats": "nixCats", "nixos-hardware": "nixos-hardware", - "nixpkgs": "nixpkgs_2", + "nixos-wsl": "nixos-wsl", + "nixpkgs": "nixpkgs_3", "stylix": "stylix" } }, @@ -922,12 +975,12 @@ "base16-helix": "base16-helix", "base16-vim": "base16-vim", "firefox-gnome-theme": "firefox-gnome-theme", - "flake-compat": "flake-compat_2", + "flake-compat": "flake-compat_3", "flake-parts": "flake-parts", "git-hooks": "git-hooks", "gnome-shell": "gnome-shell", "home-manager": "home-manager_2", - "nixpkgs": "nixpkgs_3", + "nixpkgs": "nixpkgs_4", "nur": "nur", "systems": "systems_2", "tinted-foot": "tinted-foot", diff --git a/flake.nix b/flake.nix index 97594c2..606db8d 100644 --- a/flake.nix +++ b/flake.nix @@ -25,6 +25,7 @@ nixCats = { url = "github:BirdeeHub/nixCats-nvim"; }; + nixos-wsl.url = "github:nix-community/NixOS-WSL/main"; stylix.url = "github:danth/stylix"; }; @@ -32,6 +33,7 @@ nixpkgs, nix-darwin, nix-on-droid, + nixos-wsl, ... }: { nixosConfigurations = { @@ -56,6 +58,13 @@ ./hosts/macvm/configuration.nix ]; }; + wsl = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + specialArgs = {inherit inputs;}; + modules = [ + ./hosts/wsl/configuration.nix + ]; + }; }; darwinConfigurations = { diff --git a/hosts/wsl/configuration.nix b/hosts/wsl/configuration.nix new file mode 100644 index 0000000..50fb532 --- /dev/null +++ b/hosts/wsl/configuration.nix @@ -0,0 +1,42 @@ +# Edit this configuration file to define what should be installed on +# your system. Help is available in the configuration.nix(5) man page, on +# https://search.nixos.org/options and in the NixOS manual (`nixos-help`). + +# NixOS-WSL specific options are documented on the NixOS-WSL repository: +# https://github.com/nix-community/NixOS-WSL + +{ config, lib, pkgs, inputs, ... }: + +{ + imports = [ + inputs.nixos-wsl.nixosModules.default + inputs.home-manager.nixosModules.default + ../../modules/nixos/user.nix + ]; + + wsl.enable = true; + wsl.defaultUser = "mthomson"; + + networking.hostName = "wsl"; + + environment.systemPackages = with pkgs; [ + git + wget + vim + ]; + + nixpkgs.config.allowUnfree = true; + + nix.settings.experimental-features = ["nix-command" "flakes"]; + + home-manager = { + extraSpecialArgs = {inherit inputs;}; + useGlobalPkgs = true; + useUserPackages = true; + users = { + mthomson = import ./home.nix; + }; + }; + + system.stateVersion = "24.11"; +} diff --git a/hosts/wsl/home.nix b/hosts/wsl/home.nix new file mode 100644 index 0000000..316f357 --- /dev/null +++ b/hosts/wsl/home.nix @@ -0,0 +1,26 @@ +{ + config, + pkgs, + ... +}: { + imports = [ + ../../modules/home-manager/git.nix + ../../modules/home-manager/nixcats + ../../modules/home-manager/zsh.nix + ../../modules/home-manager/tmux.nix + ../../modules/home-manager/direnv.nix + ../../modules/home-manager/jq.nix + ../../modules/home-manager/lazygit.nix + ../../modules/home-manager/man.nix + ../../modules/home-manager/emacs + ]; + home.username = "mthomson"; + home.homeDirectory = "/home/mthomson"; + home.stateVersion = "24.11"; + + home.packages = with pkgs; [ + gcc + ]; + + programs.home-manager.enable = true; +}