From cbfd99d8a688c10c7022c80072c6dd17b73b3542 Mon Sep 17 00:00:00 2001 From: thiloho <123883702+thiloho@users.noreply.github.com> Date: Mon, 31 Jul 2023 17:39:46 +0000 Subject: [PATCH] Add WSL host --- flake.lock | 72 ++++++++++++++++++++++++++++ flake.nix | 14 ++++-- nixos-configurations/wsl/default.nix | 61 +++++++++++++++++++++++ 3 files changed, 144 insertions(+), 3 deletions(-) create mode 100644 nixos-configurations/wsl/default.nix diff --git a/flake.lock b/flake.lock index 42bfd39..b097b96 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,27 @@ { "nodes": { + "NixOS-WSL": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1690553050, + "narHash": "sha256-pK3kF30OykL3v6P8UP6ipihlS34KoGq9SryCj3tHrFw=", + "owner": "nix-community", + "repo": "NixOS-WSL", + "rev": "f7a95a37306c46b42e9ce751977c44c752fd5eca", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "NixOS-WSL", + "type": "github" + } + }, "aurora-blog-template": { "inputs": { "nixpkgs": "nixpkgs" @@ -18,6 +40,40 @@ "type": "github" } }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1689068808, + "narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -71,12 +127,28 @@ }, "root": { "inputs": { + "NixOS-WSL": "NixOS-WSL", "aurora-blog-template": "aurora-blog-template", "home-manager": "home-manager", "nixpkgs": "nixpkgs_2", "website": "website" } }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, "website": { "flake": false, "locked": { diff --git a/flake.nix b/flake.nix index 7e0b226..c8651dd 100644 --- a/flake.nix +++ b/flake.nix @@ -3,22 +3,29 @@ inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; - home-manager.url = "github:nix-community/home-manager"; - home-manager.inputs.nixpkgs.follows = "nixpkgs"; + home-manager = { + url = "github:nix-community/home-manager"; + inputs.nixpkgs.follows = "nixpkgs"; + }; website = { url = "github:thiloho/website"; flake = false; }; aurora-blog-template.url = "github:thiloho/aurora"; + NixOS-WSL = { + url = "github:nix-community/NixOS-WSL"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; - outputs = inputs@{ nixpkgs, home-manager, ... }: { + outputs = inputs@{ nixpkgs, home-manager, NixOS-WSL, ... }: { nixosConfigurations = let mkSystem = entrypoint: nixpkgs.lib.nixosSystem { system = "x86_64-linux"; specialArgs = { inherit inputs; }; modules = [ entrypoint + (if entrypoint == ./nixos-configurations/wsl then NixOS-WSL.nixosModules.wsl else "") home-manager.nixosModules.home-manager { home-manager = { @@ -32,6 +39,7 @@ pc = mkSystem ./nixos-configurations/pc; laptop = mkSystem ./nixos-configurations/laptop; server = mkSystem ./nixos-configurations/server; + wsl = mkSystem ./nixos-configurations/wsl; }; }; } diff --git a/nixos-configurations/wsl/default.nix b/nixos-configurations/wsl/default.nix new file mode 100644 index 0000000..7d09dfc --- /dev/null +++ b/nixos-configurations/wsl/default.nix @@ -0,0 +1,61 @@ +{ lib, pkgs, config, modulesPath, ... }: + +{ + wsl = { + enable = true; + wslConf.automount.root = "/mnt"; + defaultUser = "thiloho"; + startMenuLaunchers = true; + nativeSystemd = true; + + # Enable native Docker support + # docker-native.enable = true; + + # Enable integration with Docker Desktop (needs to be installed) + # docker-desktop.enable = true; + + }; + + networking.hostName = "ThilosPC"; + + users.users.thiloho.isNormalUser = true; + + programs.gnupg.agent = { + enable = true; + enableSSHSupport = true; + pinentryFlavor = "gnome3"; + }; + + home-manager.users.thiloho = { pkgs, lib, config, ... }: { + programs = { + helix = { + enable = true; + defaultEditor = true; + settings.theme = "ayu_dark"; + }; + git = { + enable = true; + userName = "thiloho"; + userEmail = "123883702+thiloho@users.noreply.github.com"; + signing = { + signByDefault = true; + key = "68E9DB8C7055C97A"; + }; + }; + }; + home = { + stateVersion = "23.05"; + packages = with pkgs; [ wget ]; + }; + }; + + nixpkgs.config.allowUnfree = true; + + # Enable nix flakes + nix.package = pkgs.nixFlakes; + nix.extraOptions = '' + experimental-features = nix-command flakes + ''; + + system.stateVersion = "23.05"; +}