Setup WSL Host

This commit is contained in:
2025-01-21 04:32:14 +00:00
commit c7bcd25914
8 changed files with 183 additions and 0 deletions

26
nix/configuration.nix Normal file
View File

@@ -0,0 +1,26 @@
# 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`).
{ config, lib, pkgs, meta, ... }:
{
nix.settings.experimental-features = [ "nix-command" "flakes" ];
environment.systemPackages = with pkgs; [ wget busybox ];
programs.nix-ld.enable = true;
networking.hostName = meta.hostname;
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.luca = import ./users/luca/home.nix;
users.users.luca.shell = pkgs.zsh;
programs.zsh.enable = true;
# This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions
# on your system were taken. It's perfectly fine and recommended to leave
# this value at the release version of the first install of this system.
# Before changing this value read the documentation for this option
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system.stateVersion = "24.05"; # Did you read the comment?
}

37
nix/flake.nix Normal file
View File

@@ -0,0 +1,37 @@
{
description = "Top level flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
nixos-wsl.url = "github:nix-community/NixOS-WSL/main";
home-manager.url = "github:nix-community/home-manager";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = inputs@{ nixpkgs, ... }:
let
systems = [ "x86_64-linux" ];
hosts = [{
name = "wsl-kumatani";
isWSL = true;
}];
in {
nixosConfigurations = builtins.listToAttrs (map (host: {
name = host.name;
value = nixpkgs.lib.nixosSystem {
specialArgs = {
inherit inputs outputs;
meta = { hostname = host.name; };
};
system = "x86_64-linux";
modules =
[ ./configuration.nix home-manager.nixosModules.home-manager ]
++ (if host.isWSL then [
./wsl.nix
nixos-wsl.nixosModules.default
] else
[ ]);
};
}) hosts);
};
}

13
nix/users/luca/git.nix Executable file
View File

@@ -0,0 +1,13 @@
{
enable = true;
userName = "rocketcamel";
userEmail = "luca_lise@icloud.com";
extraConfig = {
init = {
defaultBranch = "main";
};
commit.gpgsign = true;
gpg.format = "ssh";
user.signingkey = "~/.ssh/commits.id_rsa.pub";
};
}

53
nix/users/luca/helix.nix Executable file
View File

@@ -0,0 +1,53 @@
{ pkgs, ... }:
{
enable = true;
languages.language = [
{
name = "nix";
auto-format = true;
formatter.command = "${pkgs.nixfmt}/bin/nixfmt";
}
{
name = "typescript";
auto-format = true;
formatter = {
command = "${pkgs.nodePackages_latest.prettier}/bin/prettier";
args = [ "--parser" "typescript" ];
};
}
{
name = "tsx";
auto-format = true;
formatter = {
command = "${pkgs.nodePackages_latest.prettier}/bin/prettier";
args = [ "--parser" "typescript" ];
};
}
];
settings = {
theme = "rose_pine";
editor = {
true-color = true;
line-number = "relative";
lsp.display-messages = true;
cursor-shape = {
insert = "block";
normal = "block";
};
};
keys.normal = {
space.q = ":q";
w = [ "move_next_word_start" "move_char_right" "collapse_selection" ];
b = [ "move_prev_word_start" "collapse_selection" ];
i = [ "insert_mode" "collapse_selection" ];
a = [ "append_mode" "collapse_selection" ];
};
};
themes = {
rose_pine = {
inherits = "rose_pine";
"ui.background" = "transparent";
};
};
}

25
nix/users/luca/home.nix Executable file
View File

@@ -0,0 +1,25 @@
{ config, pkgs, ... }:
{
home.username = "luca";
home.homeDirectory = "/home/luca";
programs = {
git = import ./git.nix;
zsh = import ./zsh.nix;
tmux = import ./tmux.nix { inherit pkgs; };
helix = import ./helix.nix { inherit pkgs; };
};
home.packages = with pkgs; [
nodePackages_latest.typescript-language-server
nodejs_22
pnpm
gh
oh-my-posh
];
home.stateVersion = "24.11";
programs.home-manager.enable = true;
}

16
nix/users/luca/tmux.nix Executable file
View File

@@ -0,0 +1,16 @@
{ pkgs, ... }:
{
enable = true;
prefix = "C-Space";
mouse = true;
baseIndex = 1;
sensibleOnTop = true;
keyMode = "vi";
plugins = with pkgs; [{ plugin = tmuxPlugins.tokyo-night-tmux; }];
extraConfig = ''
bind -n M-H previous-window
bind -n M-L next-window
'';
escapeTime = 0;
}

9
nix/users/luca/zsh.nix Normal file
View File

@@ -0,0 +1,9 @@
{
enable = true;
enableCompletion = true;
autosuggestion.enable = true;
envExtra = ''
. "$HOME/.rokit/env"
eval "$(oh-my-posh init zsh -c ~/.config/ohmyposh/zen.toml)"
'';
}

4
nix/wsl.nix Normal file
View File

@@ -0,0 +1,4 @@
{
wsl.enable = true;
wsl.defaultUser = "luca";
}