From 20bb0a3349398f1c6a318399dbaabc77d2d9927b Mon Sep 17 00:00:00 2001 From: Aleksandr Lebedev Date: Thu, 6 Mar 2025 10:13:34 +0000 Subject: [PATCH] wsl init --- flake.nix | 30 ++++++++++++ nixos/wsl.nix | 133 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 163 insertions(+) create mode 100644 nixos/wsl.nix diff --git a/flake.nix b/flake.nix index 0460c90..38438ad 100644 --- a/flake.nix +++ b/flake.nix @@ -27,6 +27,7 @@ url = "github:kylekrein/neovim"; inputs.nixpkgs.follows = "nixpkgs"; }; + nixos-wsl.url = "github:nix-community/NixOS-WSL/main"; stylix.url = "github:danth/stylix?ref=release-24.11"; nix-flatpak.url = "github:gmodena/nix-flatpak/?ref=latest"; apple-silicon-support.url = "github:tpwrules/nixos-apple-silicon?ref=releasep2-2024-12-25"; @@ -102,6 +103,15 @@ # rocmSupport = true; }; }; + kylekrein-wsl-pkgs = nixpkgs: import nixpkgs { + system = x86; + overlays = [ + #nativePackagesOverlay + ]; + config = { + allowUnfree = true; + }; + }; andrej-pc-pkgs = nixpkgs: import nixpkgs { system = x86; overlays = [ @@ -180,6 +190,26 @@ ./nixos/configuration.nix ]; }; + "kylekrein-wsl" = nixpkgs.lib.nixosSystem { + specialArgs = { + hwconfig = { + hostname = "kylekrein-wsl"; + isLaptop = true; + system = x86; + useImpermanence = false; + }; + inherit first-nixos-install; + inherit inputs; + unstable-pkgs = kylekrein-wsl-pkgs nixpkgs-unstable; + }; + + system = x86; + pkgs = kylekrein-wsl-pkgs nixpkgs; + modules = [ + inputs.nixos-wsl.nixosModules.default + ./nixos/wsl.nix + ]; + }; "andrej-pc" = nixpkgs.lib.nixosSystem { specialArgs = { hwconfig = { diff --git a/nixos/wsl.nix b/nixos/wsl.nix new file mode 100644 index 0000000..56a2397 --- /dev/null +++ b/nixos/wsl.nix @@ -0,0 +1,133 @@ +{ + config, + lib, + pkgs, + hwconfig, + first-nixos-install, + inputs, + unstable-pkgs, + ... +}: +{ + imports = [ + ./modules/firefox + ./modules/flatpak + ./modules/emacs + ./hosts/${hwconfig.hostname} + ] ++ lib.optional (hwconfig.useImpermanence) ./modules/impermanence; + + networking.hostName = hwconfig.hostname; + # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. + + # Configure network proxy if necessary + # networking.proxy.default = "http://user:password@proxy:port/"; + # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; + + #flatpak + #kk.services.flatpak.enable = hwconfig.system != "aarch64-linux"; + services.flatpak.packages = [ + + ]; + + environment.systemPackages = with pkgs; [ + killall + nix-output-monitor + eza + fd + (pkgs.writeShellScriptBin "root-files" '' + ${pkgs.fd}/bin/fd --one-file-system --base-directory / --type f --hidden --exclude "{tmp,etc/passwd}" + '') # https://www.reddit.com/r/NixOS/comments/1d1apm0/comment/l5tgbwz/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button + tealdeer + fzf + lazygit + fastfetch + wl-clipboard + git + git-credential-manager + egl-wayland + btop + ]; + wsl = { + enable = true; + defaultUser = "nixos"; + }; + programs.nh = { + enable = true; + clean.enable = true; + clean.extraArgs = "--keep-since 4d --keep 3"; + flake = "/home/nixos/nixos-config"; + }; + fonts.packages = with unstable-pkgs; [ #TODO change to pkgs when 25.05 comes out + nerd-fonts.jetbrains-mono + font-awesome + nerd-fonts.symbols-only + hack-font + # microsoft fonts: + #corefonts + #vistafonts + ]; + environment.sessionVariables = { + NIXOS_OZONE_WL = "1"; + }; + + hardware = { + graphics = { + enable = true; + }; + }; + + security.polkit.enable = true; + security.rtkit.enable = true; + services.pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + jack.enable = true; + }; + + programs.bash = { + shellAliases = { + ls = "${pkgs.eza}/bin/eza --icons=always"; + }; + }; + + # List services that you want to enable: + + # Enable the OpenSSH daemon. + services.openssh.enable = true; + + # Open ports in the firewall. + networking.firewall.allowedTCPPorts = [ 22 ]; + networking.firewall.allowedUDPPorts = [ 22 ]; + # Or disable the firewall altogether. + #networking.firewall.enable = false; + + # 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? + + nix = { + settings = { + experimental-features = [ + "nix-command" + "flakes" + ]; + auto-optimise-store = true; + substituters = [ + "https://hyprland.cachix.org" + "https://nix-gaming.cachix.org" + "https://nix-community.cachix.org" + ]; + trusted-public-keys = [ + "hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc=" + "nix-gaming.cachix.org-1:nbjlureqMbRAxR1gJ/f3hxemL9svXaZF/Ees8vCUUs4=" + "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" + ]; + }; + }; +}