From 78361944cbce2d23c849c0bdcd3b3954e25e1d85 Mon Sep 17 00:00:00 2001 From: Nickiel12 Date: Thu, 4 Jul 2024 23:30:56 +0000 Subject: [PATCH] Added WSL host --- flake.lock | 103 ++++++++++++++++++++++++++++++++++++++---- flake.nix | 37 +++++++++++++++ home.nix | 19 ++++---- hosts/WSL/default.nix | 13 ++++++ 4 files changed, 156 insertions(+), 16 deletions(-) create mode 100644 hosts/WSL/default.nix diff --git a/flake.lock b/flake.lock index 5ec94e7..ee287d4 100644 --- a/flake.lock +++ b/flake.lock @@ -25,7 +25,7 @@ }, "devshell": { "inputs": { - "flake-utils": "flake-utils_4", + "flake-utils": "flake-utils_5", "nixpkgs": [ "nixvim", "nixpkgs" @@ -103,6 +103,22 @@ } }, "flake-compat_2": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_3": { "locked": { "lastModified": 1696426674, "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", @@ -116,7 +132,7 @@ "url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz" } }, - "flake-compat_3": { + "flake-compat_4": { "flake": false, "locked": { "lastModified": 1696426674, @@ -211,6 +227,24 @@ "inputs": { "systems": "systems_4" }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_5": { + "inputs": { + "systems": "systems_5" + }, "locked": { "lastModified": 1701680307, "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", @@ -227,7 +261,7 @@ }, "git-hooks": { "inputs": { - "flake-compat": "flake-compat_3", + "flake-compat": "flake-compat_4", "gitignore": "gitignore", "nixpkgs": [ "nixvim", @@ -399,6 +433,27 @@ "type": "github" } }, + "nixos-wsl": { + "inputs": { + "flake-compat": "flake-compat_2", + "flake-utils": "flake-utils_4", + "nixpkgs": "nixpkgs_6" + }, + "locked": { + "lastModified": 1719220171, + "narHash": "sha256-xywM6JoGT8AwfoOFJBTv8GRlvNu8LYqqqMS/OQ6uCgE=", + "owner": "nix-community", + "repo": "NixOS-WSL", + "rev": "269411cfed6aab694e46f719277c972de96177bb", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "main", + "repo": "NixOS-WSL", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1699099776, @@ -496,6 +551,22 @@ } }, "nixpkgs_6": { + "locked": { + "lastModified": 1718835956, + "narHash": "sha256-wM9v2yIxClRYsGHut5vHICZTK7xdrUGfrLkXvSuv6s4=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "dd457de7e08c6d06789b1f5b88fc9327f4d96309", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-24.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_7": { "locked": { "lastModified": 1719254875, "narHash": "sha256-ECni+IkwXjusHsm9Sexdtq8weAq/yUyt1TWIemXt3Ko=", @@ -511,7 +582,7 @@ "type": "github" } }, - "nixpkgs_7": { + "nixpkgs_8": { "locked": { "lastModified": 1719254875, "narHash": "sha256-ECni+IkwXjusHsm9Sexdtq8weAq/yUyt1TWIemXt3Ko=", @@ -530,12 +601,12 @@ "nixvim": { "inputs": { "devshell": "devshell", - "flake-compat": "flake-compat_2", + "flake-compat": "flake-compat_3", "flake-parts": "flake-parts", "git-hooks": "git-hooks", "home-manager": "home-manager_2", "nix-darwin": "nix-darwin", - "nixpkgs": "nixpkgs_7", + "nixpkgs": "nixpkgs_8", "treefmt-nix": "treefmt-nix" }, "locked": { @@ -560,7 +631,8 @@ "home-manager": "home-manager", "kmonad": "kmonad", "nicks_nextcloud_integrations": "nicks_nextcloud_integrations", - "nixpkgs": "nixpkgs_6", + "nixos-wsl": "nixos-wsl", + "nixpkgs": "nixpkgs_7", "nixpkgs-stable": "nixpkgs-stable", "nixvim": "nixvim", "utils": "utils" @@ -696,6 +768,21 @@ "type": "github" } }, + "systems_6": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, "treefmt-nix": { "inputs": { "nixpkgs": [ @@ -719,7 +806,7 @@ }, "utils": { "inputs": { - "systems": "systems_5" + "systems": "systems_6" }, "locked": { "lastModified": 1710146030, diff --git a/flake.nix b/flake.nix index 53c62a7..35a8507 100644 --- a/flake.nix +++ b/flake.nix @@ -9,6 +9,8 @@ # url = "github:NixOS/nixpkgs/b477b25191fc94ce764428520b83b6b64366e3c8"; }; + nixos-wsl.url = "github:nix-community/NixOS-WSL/main"; + nixpkgs-stable = { url = "github:NixOS/nixpkgs/release-23.11"; }; @@ -43,6 +45,7 @@ ewwtilities, kmonad, atuin, + nixos-wsl, ... }: let @@ -90,6 +93,40 @@ ]; }; + + # To change username after installing: https://nix-community.github.io/NixOS-WSL/how-to/change-username.html + NicksNixWSL = lib.nixosSystem { + inherit system; + + modules = [ + nixos-wsl.nixosModules.default + ./hosts/WSL + { + networking.hostName = "NicksNixWSL"; + system.stateVersion = "24.05"; + wsl.enable = true; + wsl.defaultUser = "nixolas"; + } + #./hosts/WSL + home-manager.nixosModules.home-manager { + home-manager = { + useGlobalPkgs = true; + useUserPackages = true; + extraSpecialArgs = { + inherit user ewwtilities atuin pkgs-stable; + }; + users.${user} = { + imports = [ + (import ./home.nix) + # Add nixvim to the homemanager + inputs.nixvim.homeManagerModules.nixvim + ]; + }; + }; + } + ]; + }; + NicksNixLaptop = lib.nixosSystem { inherit system; specialArgs = { diff --git a/home.nix b/home.nix index 4d11198..957ef31 100644 --- a/home.nix +++ b/home.nix @@ -13,6 +13,7 @@ let commandline_only_hosts = [ "Alaska" + "NicksNixWSL" ]; install_packages = with pkgs; [ @@ -85,26 +86,28 @@ let # Drawing tablet driver opentabletdriver ]; + + filterNulls = list: builtins.filter (x: x != null) list; + in { - imports = [ + imports = filterNulls [ ./modules/atuin.nix - ./modules/discord.nix - #./modules/emacs.nix - ./modules/fusuma.nix ./modules/git.nix - ./modules/hyprland - ./modules/kitty.nix ./modules/neovim.nix - ./modules/rofi.nix ./modules/tmux.nix ./modules/wezterm.nix ./modules/xdg.nix ./modules/yazi.nix ./modules/zsh.nix + (if (! builtins.elem osConfig.networking.hostName commandline_only_hosts ) then ./modules/hyprland else null) + (if (! builtins.elem osConfig.networking.hostName commandline_only_hosts ) then ../modules/discord.nix else null) + #./modules/emacs.nix + (if (! builtins.elem osConfig.networking.hostName commandline_only_hosts ) then ../modules/fusuma.nix else null) + (if (! builtins.elem osConfig.networking.hostName commandline_only_hosts ) then ../modules/rofi.nix else null) + (if (! builtins.elem osConfig.networking.hostName commandline_only_hosts ) then ../modules/kitty.nix else null) ]; - # Let Home Manager install and manage itself. programs.home-manager.enable = true; diff --git a/hosts/WSL/default.nix b/hosts/WSL/default.nix new file mode 100644 index 0000000..a6e1eb3 --- /dev/null +++ b/hosts/WSL/default.nix @@ -0,0 +1,13 @@ +{ config, pkgs, ... }: + +let +in +{ + # See https://nix-community.github.io/NixOS-WSL/how-to/change-username.html + # to reset default WSL login + environment = { + shells = [ + "/etc/profiles/per-user/nixolas/bin/zsh" + ]; + }; +}