add support for WSL

This commit is contained in:
chaos 2023-10-14 12:35:20 +01:00
parent f41ae25fa9
commit 0dc6c4cbf8
8 changed files with 120 additions and 1 deletions

View file

@ -106,6 +106,32 @@
"url": "https://forgejo.owo.monster/chaos/musicutil" "url": "https://forgejo.owo.monster/chaos/musicutil"
} }
}, },
"nixos-wsl": {
"inputs": {
"flake-compat": [
"flake-compat"
],
"flake-utils": [
"flake-utils"
],
"nixpkgs": [
"nixpkgs-unstable"
]
},
"locked": {
"lastModified": 1696883888,
"narHash": "sha256-EdQMeJxDoi26YDtkNf20mNBeCj7Y5eKg+rrxkiB86z0=",
"owner": "nix-community",
"repo": "NixOS-WSL",
"rev": "5da7c4fd0ab9693d83cae50de7d9430696f92568",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "NixOS-WSL",
"type": "github"
}
},
"nixpkgs-unstable": { "nixpkgs-unstable": {
"locked": { "locked": {
"lastModified": 1695644571, "lastModified": 1695644571,
@ -170,6 +196,7 @@
"food-site": "food-site", "food-site": "food-site",
"home-manager-unstable": "home-manager-unstable", "home-manager-unstable": "home-manager-unstable",
"musicutil": "musicutil", "musicutil": "musicutil",
"nixos-wsl": "nixos-wsl",
"nixpkgs-unstable": "nixpkgs-unstable", "nixpkgs-unstable": "nixpkgs-unstable",
"nur": "nur", "nur": "nur",
"piped-flake": "piped-flake", "piped-flake": "piped-flake",

View file

@ -16,6 +16,12 @@
home-manager-unstable.url = "github:nix-community/home-manager"; home-manager-unstable.url = "github:nix-community/home-manager";
home-manager-unstable.inputs.nixpkgs.follows = "nixpkgs-unstable"; home-manager-unstable.inputs.nixpkgs.follows = "nixpkgs-unstable";
nixos-wsl.url = "github:nix-community/NixOS-WSL";
nixos-wsl.inputs.nixpkgs.follows = "nixpkgs-unstable";
nixos-wsl.inputs.flake-utils.follows = "flake-utils";
nixos-wsl.inputs.flake-compat.follows = "flake-compat";
tree-input.url = "github:kittywitch/tree"; tree-input.url = "github:kittywitch/tree";
tree-input.inputs.nixpkgs.follows = "nixpkgs-unstable"; tree-input.inputs.nixpkgs.follows = "nixpkgs-unstable";

View file

@ -1,4 +1,7 @@
{...}: { {...}: {
home.sessionVariables = {
DONT_PROMPT_WSL_INSTALL = 1;
};
programs.vscode-mod = { programs.vscode-mod = {
enable = true; enable = true;
userSettings = { userSettings = {

View file

@ -29,6 +29,8 @@
inputs.home-manager-unstable.nixosModules.home-manager inputs.home-manager-unstable.nixosModules.home-manager
inputs.nixos-wsl.nixosModules.default
inputs.vaultui.nixosModules.default inputs.vaultui.nixosModules.default
inputs.piped-flake.nixosModules.default inputs.piped-flake.nixosModules.default
@ -70,6 +72,16 @@ in {
modules = defaultModules ++ [./lappy-t495/lappy-t495.nix ./lappy-t495/hardware.nix]; modules = defaultModules ++ [./lappy-t495/lappy-t495.nix ./lappy-t495/hardware.nix];
}; };
wsl = nixosUnstableSystem {
specialArgs =
defaultSpecialArgs
// {
hostPath = ./wsl;
};
system = "x86_64-linux";
modules = defaultModules ++ [./wsl/wsl.nix];
};
hetzner-arm = nixosUnstableSystem { hetzner-arm = nixosUnstableSystem {
specialArgs = specialArgs =
defaultSpecialArgs defaultSpecialArgs

25
hosts/wsl/wsl.nix Normal file
View file

@ -0,0 +1,25 @@
{ tree, ... }: {
imports = with tree;[
users.root
users.chaos
profiles.sshd
presets.nixos.wslBase
profiles.cross.arm64
profiles.remoteBuilders
];
home-manager.users.root = {
home.stateVersion = "23.05";
};
home-manager.users.chaos = {
home.stateVersion = "23.05";
};
networking.hostName = "wsl";
time.timeZone = "Europe/London";
system.stateVersion = "23.05";
}

43
presets/nixos/wslBase.nix Normal file
View file

@ -0,0 +1,43 @@
{tree, ...}: {
imports = with tree; [
profiles.sound.pipewire
profiles.gui.base
profiles.firewallAllow.aria2c
profiles.firewallAllow.soulseek
profiles.mullvad
];
boot.plymouth.enable = true;
home-manager.users.chaos = {
imports = with tree; [
home.base
home.dev.all
home.homeFolders
home.programming.editors.vscode
home.programming.languages.rust
home.programming.languages.nix
home.gui.base
home.apps.fileRoller
home.apps.mpv
home.apps.quassel
home.apps.toot-cli
home.apps.mullvad
home.apps.aria2
home.apps.rclone
home.apps.restic
];
};
wsl = {
enable = true;
defaultUser = "chaos";
interop.register = true;
};
}

View file

@ -15,6 +15,8 @@ in {
programs.nm-applet.enable = networkManagerEnabled; programs.nm-applet.enable = networkManagerEnabled;
programs.dconf.enable = true;
fonts = { fonts = {
packages = with pkgs; [comic-sans comic-code]; packages = with pkgs; [comic-sans comic-code];
fontconfig = { fontconfig = {

View file

@ -8,6 +8,7 @@
currentHostname = config.networking.hostName; currentHostname = config.networking.hostName;
usbSSHKeyFile = "/usb/ssh-keys/chaos.priv"; usbSSHKeyFile = "/usb/ssh-keys/chaos.priv";
normalSSHKeyFile = "/home/chaos/.ssh/id_ed25519";
sshKeyFile = sshKeyFile =
if if
@ -16,7 +17,7 @@
"tablet" "tablet"
] ]
then usbSSHKeyFile then usbSSHKeyFile
else throw "host isn't configured for remote-builders"; else if builtins.elem currentHostname ["wsl"] then normalSSHKeyFile else throw "host isn't configured for remote-builders";
builderDefaults = { builderDefaults = {
sshUser = "root"; sshUser = "root";