feat: merge own wsl config

This commit is contained in:
2026-02-28 01:57:42 +00:00
parent 4e2264dc03
commit bf41ee6e0a
14 changed files with 272 additions and 129 deletions

38
flake.lock generated
View File

@@ -145,6 +145,22 @@
"type": "github"
}
},
"flake-compat_4": {
"flake": false,
"locked": {
"lastModified": 1767039857,
"narHash": "sha256-vNpUSpF5Nuw8xvDLj2KCwwksIbjua2LZCqhV1LNRDns=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "5edf11c44bc78a0d334f6334cdaf7d60d732daab",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-parts": {
"inputs": {
"nixpkgs-lib": [
@@ -693,6 +709,27 @@
"type": "github"
}
},
"nixos-wsl": {
"inputs": {
"flake-compat": "flake-compat_4",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1771563879,
"narHash": "sha256-vA5hocvdGhr+jfBN7A7ogeZqIz2qx01EixXwdVsQcnE=",
"owner": "nix-community",
"repo": "NixOS-WSL",
"rev": "379d20c55f552e91fb9f3f0382e4a97d3f452943",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "NixOS-WSL",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1748929857,
@@ -821,6 +858,7 @@
"nix-minecraft": "nix-minecraft",
"nixos-anywhere": "nixos-anywhere",
"nixos-hardware": "nixos-hardware",
"nixos-wsl": "nixos-wsl",
"nixpkgs": "nixpkgs_2",
"nixpkgs-fixed": "nixpkgs-fixed",
"nixvim": "nixvim",

View File

@@ -32,6 +32,10 @@
url = "github:nix-community/home-manager/release-25.11";
inputs.nixpkgs.follows = "nixpkgs-fixed";
};
nixos-wsl = {
url = "github:nix-community/NixOS-WSL";
inputs.nixpkgs.follows = "nixpkgs";
};
nixos-hardware = {
url = "github:NixOS/nixos-hardware";
};
@@ -88,6 +92,7 @@
# FIXME(yukkop): some why I cannot merge nixosConfigurations from `forAllSystemsWithPkgs` with this
"neuro|x86_64-linux" = import ./nixos/system/neuro { inherit flake self inputs; system = "x86_64-linux"; };
"games|x86_64-linux" = import ./nixos/system/games { inherit flake self inputs; system = "x86_64-linux"; };
"wsl|x86_64-linux" = import ./nixos/system/wsl { inherit flake self inputs; system = "x86_64-linux"; };
};
};
}

View File

@@ -9,7 +9,7 @@
lib,
...
}: let
system = pkgs.system;
system = pkgs.stdenv.hostPlatform.system;
cfg = config.services.postgresql;
extensionFlags = {
pg_cron = false;

View File

@@ -112,6 +112,6 @@ in {
"ata_piix"
"uhci_hcd"
"xen_blkfront"
] ++ (if pkgs.system != "aarch64-linux" then [ "vmw_pvscsi" ] else []);
] ++ (if pkgs.stdenv.hostPlatform.system != "aarch64-linux" then [ "vmw_pvscsi" ] else []);
};
}

View File

@@ -71,7 +71,7 @@ in {
"ata_piix"
"uhci_hcd"
"xen_blkfront"
] ++ (if pkgs.system != "aarch64-linux" then [ "vmw_pvscsi" ] else []);
] ++ (if pkgs.stdenv.hostPlatform.system != "aarch64-linux" then [ "vmw_pvscsi" ] else []);
networking.useDHCP = false;
networking.useNetworkd = true;
@@ -125,7 +125,7 @@ in {
};
};
}
(lib.mkIf (pkgs.system == "aarch64-linux") {
(lib.mkIf (pkgs.stdenv.hostPlatform.system == "aarch64-linux") {
boot.initrd.kernelModules = [ "virtio_gpu" ];
boot.kernelParams = [ "console=tty" ];
})

View File

@@ -35,33 +35,34 @@ in {
"ata_piix"
"uhci_hcd"
"xen_blkfront"
] ++ (if pkgs.system != "aarch64-linux" then [ "vmw_pvscsi" ] else []);
] ++ (if pkgs.stdenv.hostPlatform.system != "aarch64-linux" then [ "vmw_pvscsi" ] else []);
boot.initrd.kernelModules = ["nvme"];
disko.devices = {
disk.master = {
device = cfg.device;
content = {
type = "table";
format = "msdos";
partitions = [
{
name = "root";
part-type = "primary";
fs-type = "ext4";
bootable = true;
type = "gpt";
partitions = {
boot = {
size = "1M";
type = "EF02";
priority = 1;
};
root = {
size = "100%";
content = {
type = "filesystem";
format = "ext4";
type = "filesystem";
format = "ext4";
mountpoint = "/";
};
}
];
};
};
};
};
};
}
(lib.mkIf (pkgs.system == "aarch64-linux") {
(lib.mkIf (pkgs.stdenv.hostPlatform.system == "aarch64-linux") {
boot.initrd.kernelModules = [ "virtio_gpu" ];
boot.kernelParams = [ "console=tty" ];
})

View File

@@ -21,31 +21,35 @@ in {
programs.zsh.enable = true;
users.defaultUserShell = pkgs.zsh;
home-manager.users.root = {
home.stateVersion = lib.mkDefault "25.05";
# Share the same zsh config with all home-manager users
home-manager.sharedModules = [
{
programs.zsh = {
enable = true;
enableCompletion = true;
autosuggestion.enable = true;
syntaxHighlighting.enable = true;
programs.zsh = {
enable = true;
enableCompletion = true;
autosuggestion.enable = true;
syntaxHighlighting.enable = true;
history = {
size = 10000;
path = "$HOME/.zsh/.zsh_history";
};
history = {
size = 10000;
path = "$HOME/.zsh/.zsh_history";
oh-my-zsh = {
enable = true;
theme = "terminalparty";
};
shellAliases = self.lib.sharedShellAliases;
initContent = ''
set -ovi
'';
};
}
];
oh-my-zsh = {
enable = true;
theme = "terminalparty";
};
shellAliases = self.lib.sharedShellAliases;
initContent = ''
set -ovi
'';
};
};
# Still define root for stateVersion; config comes from sharedModules
home-manager.users.root.home.stateVersion = lib.mkDefault "25.05";
};
}

View File

@@ -9,7 +9,7 @@
config,
...
}: let
system = pkgs.system;
system = pkgs.stdenv.hostPlatform.system;
cfg = config.hectic.services."sentinèlla";
# URLS="http://..." # default: none
# VOLUMES="/ /home" # default: all from df -P

View File

@@ -1,7 +1,7 @@
{ inputs, flake, self }:
{ config, pkgs, lib, ... }: let
cfg = config.hectic.services.support-bot;
system = pkgs.system;
system = pkgs.stdenv.hostPlatform.system;
packagesAttr = lib.mapAttrs (packageName: packageConfig:
packageConfig // {

View File

@@ -1,4 +1,4 @@
{
{
self,
inputs,
...
@@ -8,90 +8,72 @@
pkgs,
lib,
...
}: let
name = builtins.baseNameOf ./.;
}: let
name = "yukkop";
#name = builtins.baseNameOf ./.;
home = "/home/${name}";
cfg = config.hectic.user.yukkop;
in {
imports = [
inputs.home-manager.nixosModules.home-manager
];
options.hectic.user.yukkop.enable = lib.mkEnableOption "Enable user.yukkop";
config = lib.mkIf cfg.enable {
#home = {
# username = name;
# homeDirectory = home;
# packages = [];
# stateVersion = "25.05";
#};
users.users.${name} = {
isNormalUser = true;
initialPassword = "kk";
extraGroups = [ "wheel" "docker" "owner" ];
};
#xdg = {
# enable = true;
# userDirs = {
# enable = true;
# pictures = "${home}/px";
# videos = "${home}/vd";
# music = "${home}/mu";
# documents = "${home}/dc";
# downloads = "${home}/dw";
# desktop = "${home}/dx";
# publicShare = "${home}/pu";
# templates = "${config.xdg.dataHome}/templates";
# };
# mimeApps = {
# enable = true;
# defaultApplications = {
home-manager.users.${name} = {
home.stateVersion = "24.05";
# # Files
# "application/x-shellscript" = [ "nvim.desktop" ];
# "text/x-shellscript" = [ "nvim.desktop" ];
# "text/plain" = [ "nvim.desktop" ];
# "inode/directory" = [ "pcmanfm.desktop" ];
home.packages = with pkgs; [
pinentry-tty
];
# # Images
# "image/png" = [ "sxiv.desktop" ];
# "image/jpeg" = [ "sxiv.desktop" ];
# "image/gif" = [ "sxiv.desktop" ];
# "image/webp" = [ "sxiv.desktop" ];
# "image/x-xcf" = [ "gimp.desktop" ];
programs.password-store = {
enable = true;
package = (pkgs.pass.override {
x11Support = false;
waylandSupport = false;
dmenuSupport = false;
}).withExtensions (exts: with exts; [
pass-otp
]);
settings.PASSWORD_STORE_DIR = "${home}/.pass";
};
# # Videos
# "video/x-matroska" = [ "mpv.desktop" ];
programs.gpg = {
enable = true;
homedir = "${home}/.gnupg";
};
# # # Application-specific
# # "application/postscript" = [ "pdf.desktop" ];
# # "application/pdf" = [ "pdf.desktop" ];
# # "application/rss+xml" = [ "rss.desktop" ];
# # "application/x-bittorrent" = [ "torrent.desktop" ];
services.gpg-agent = {
enable = true;
pinentryPackage = pkgs.pinentry-tty;
enableZshIntegration = true;
defaultCacheTtl = 60 * 60;
maxCacheTtl = 60 * 60 * 24;
};
# # Protocols
# "x-scheme-handler/http" = [ "firefox.desktop" ];
# "x-scheme-handler/https" = [ "firefox.desktop" ];
# # "x-scheme-handler/magnet" = [ "torrent.desktop" ];
# # "x-scheme-handler/mailto" = [ "mail.desktop" ];
# # "x-scheme-handler/lbry" = [ "lbry.desktop" ];
# # "x-scheme-handler/tg" = [ "telegram.desktop" ];
programs.bash.shellAliases = {
dev = "nix develop -c zsh";
# system-specific rebuild aliases can be added per-system
};
# # text/x-shellscript=text.desktop;
# # x-scheme-handler/magnet=torrent.desktop;
# # application/x-bittorrent=torrent.desktop;
# # x-scheme-handler/mailto=mail.desktop;
# # text/plain=text.desktop;
# # application/postscript=pdf.desktop;
# # application/pdf=pdf.desktop;
# # image/png=img.desktop;
# # image/jpeg=img.desktop;
# # image/gif=img.desktop;
# # image/webp=img.desktop;
# # application/rss+xml=rss.desktop;
# # video/x-matroska=video.desktop;
# # x-scheme-handler/lbry=lbry.desktop;
# # inode/directory=file.desktop;
# # text/html=chromium.desktop;
# # x-scheme-handler/http=chromium.desktop;
# # x-scheme-handler/https=chromium.desktop;
# # x-scheme-handler/about=chromium.desktop;
# # x-scheme-handler/unknown=chromium.desktop;
# };
# };
#};
programs.git = {
enable = true;
lfs.enable = true;
userName = "yukkop";
userEmail = "hectic.yukkop@gmail.com";
extraConfig = {
push.autoSetupRemote = true;
init.defaultBranch = "master";
};
};
};
};
}

View File

@@ -54,28 +54,29 @@ in {
"ata_piix"
"uhci_hcd"
"xen_blkfront"
] ++ (if pkgs.system != "aarch64-linux" then [ "vmw_pvscsi" ] else []);
] ++ (if pkgs.stdenv.hostPlatform.system != "aarch64-linux" then [ "vmw_pvscsi" ] else []);
boot.initrd.kernelModules = ["nvme"];
disko.devices = {
disk.vda = {
device = lib.mkDefault "/dev/vda";
content = {
type = "table";
format = "msdos";
partitions = [
{
name = "root";
part-type = "primary";
fs-type = "ext4";
bootable = true;
type = "gpt";
partitions = {
boot = {
size = "1M";
type = "EF02";
priority = 1;
};
root = {
size = "100%";
content = {
type = "filesystem";
format = "ext4";
type = "filesystem";
format = "ext4";
mountpoint = "/";
};
}
];
};
};
};
};
};

View File

@@ -8,7 +8,7 @@
modulesPath,
config,
...
}: let system = pkgs.system; in {
}: let system = pkgs.stdenv.hostPlatform.system; in {
imports = [
self.nixosModules.hectic
inputs.sops-nix.nixosModules.sops

View File

@@ -0,0 +1,23 @@
{
flake,
self,
inputs,
system,
...
}: let
# Use folder name as system name
name = builtins.baseNameOf ./.;
in self.lib.nixpkgs-lib.nixosSystem {
pkgs = import inputs.nixpkgs {
inherit system;
overlays = [ self.overlays.default ];
config.allowUnfree = true;
};
modules = [
{ networking.hostName = name; }
inputs.nixos-wsl.nixosModules.default
{ wsl.enable = true; }
(import ./${name}.nix { inherit flake self inputs; })
];
}

89
nixos/system/wsl/wsl.nix Normal file
View File

@@ -0,0 +1,89 @@
{
inputs,
flake,
self,
}: {
lib,
pkgs,
config,
...
}: {
imports = [
self.nixosModules.hectic
];
hectic = {
archetype.base.enable = true;
program.zsh.enable = true;
program.nixvim.enable = true;
user.yukkop.enable = true;
};
wsl.defaultUser = "yukkop";
# 16 GiB swap
swapDevices = [{
device = "/var/lib/swapfile";
size = 16 * 1024;
}];
users.groups.owner = {};
services.openssh = {
enable = true;
settings = {
PasswordAuthentication = false;
UseDns = true;
X11Forwarding = false;
PermitRootLogin = "no";
};
};
virtualisation.docker.enable = true;
hardware.opengl.enable = true;
console.keyMap = "us";
environment.systemPackages = with pkgs; [
ripgrep
man-pages
man-pages-posix
man-db
ffmpeg
];
documentation.dev.enable = true;
documentation.man.man-db.enable = false;
documentation.man.mandoc.enable = true;
services.samba = {
enable = true;
shares.sshfs = {
path = "/home/yukkop/umbriel/vproxy";
browseable = true;
"read only" = false;
"guest ok" = true;
};
};
networking.firewall.allowedTCPPorts = [ 139 445 ];
networking.firewall.allowedUDPPorts = [ 137 138 ];
fonts.packages = with pkgs; [
nerd-fonts.jetbrains-mono
];
environment.variables = {
EDITOR = "nvim";
VISUAL = "nvim";
};
# WSL-local shell aliases
programs.bash.shellAliases = {
nrs = "sudo nixos-rebuild switch --flake /home/yukkop/pj/util.nix#wsl";
};
# WSL: keep imperative stateVersion in the system module
system.stateVersion = "25.05";
}