From 7e458f7207e1f6b6f7a1c5dddae5c13dcbd90931 Mon Sep 17 00:00:00 2001 From: Youwen Wu Date: Tue, 26 Nov 2024 17:15:31 -0800 Subject: [PATCH] feat: add wsl configurations --- flake.lock | 45 +++++++++- flake.nix | 10 +++ hosts/cassini/configuration.nix | 90 +++++++++++++++++++ hosts/cassini/default.nix | 38 ++++++++ hosts/cassini/hardware-configuration.nix | 53 +++++++++++ hosts/cassini/home-manager-extras/default.nix | 3 + modules/linux/wsl/default.nix | 12 +++ 7 files changed, 249 insertions(+), 2 deletions(-) create mode 100755 hosts/cassini/configuration.nix create mode 100644 hosts/cassini/default.nix create mode 100644 hosts/cassini/hardware-configuration.nix create mode 100644 hosts/cassini/home-manager-extras/default.nix create mode 100644 modules/linux/wsl/default.nix diff --git a/flake.lock b/flake.lock index 2f80346..3c38038 100644 --- a/flake.lock +++ b/flake.lock @@ -190,6 +190,22 @@ } }, "flake-compat_4": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_5": { "flake": false, "locked": { "lastModified": 1673956053, @@ -571,6 +587,30 @@ "type": "github" } }, + "nixos-wsl": { + "inputs": { + "flake-compat": "flake-compat_3", + "flake-utils": [ + "flake-utils" + ], + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1731682434, + "narHash": "sha256-HnZFPB7akVIy0KuPq/tEkiB+Brt1qi0DUIDzR8z25qI=", + "owner": "nix-community", + "repo": "NixOS-WSL", + "rev": "a6b9cf0b7805e2c50829020a73e7bde683fd36dd", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "NixOS-WSL", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1687274257, @@ -732,6 +772,7 @@ "nix-darwin": "nix-darwin", "nix-homebrew": "nix-homebrew", "nix-index-database": "nix-index-database", + "nixos-wsl": "nixos-wsl", "nixpkgs": "nixpkgs_2", "spicetify": "spicetify", "stylix": "stylix", @@ -785,7 +826,7 @@ }, "spicetify": { "inputs": { - "flake-compat": "flake-compat_3", + "flake-compat": "flake-compat_4", "nixpkgs": [ "nixpkgs" ] @@ -810,7 +851,7 @@ "base16-fish": "base16-fish", "base16-helix": "base16-helix", "base16-vim": "base16-vim", - "flake-compat": "flake-compat_4", + "flake-compat": "flake-compat_5", "flake-utils": "flake-utils_4", "gnome-shell": "gnome-shell", "home-manager": "home-manager_2", diff --git a/flake.nix b/flake.nix index 07f1bdc..9ee16f9 100755 --- a/flake.nix +++ b/flake.nix @@ -89,6 +89,12 @@ zen-browser = { url = "github:youwen5/zen-browser-flake"; }; + + nixos-wsl = { + url = "github:nix-community/NixOS-WSL"; + inputs.nixpkgs.follows = "nixpkgs"; + inputs.flake-utils.follows = "flake-utils"; + }; }; outputs = @@ -121,6 +127,10 @@ inherit inputs nixpkgs; systemModule = ./hosts/adrastea; }; + cassini = buildLiminalOS { + inherit inputs nixpkgs; + systemModule = ./hosts/cassini; + }; }; darwinConfigurations.phobos = nix-darwin.lib.darwinSystem { specialArgs = { diff --git a/hosts/cassini/configuration.nix b/hosts/cassini/configuration.nix new file mode 100755 index 0000000..32952d2 --- /dev/null +++ b/hosts/cassini/configuration.nix @@ -0,0 +1,90 @@ +# Edit this configuration file to define what should be installed on +# your system. Help is available in the configuration.nix(5) man page +# and in the NixOS manual (accessible by running ‘nixos-help’). +{ + pkgs, + lib, + ... +}: +{ + networking.hostName = "adrastea"; # Define your hostname. + # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. + + # Set your time zone. + time.timeZone = "America/Los_Angeles"; + + # Select internationalisation properties. + i18n.defaultLocale = "en_US.UTF-8"; + + i18n.extraLocaleSettings = { + LC_ADDRESS = "en_US.UTF-8"; + LC_IDENTIFICATION = "en_US.UTF-8"; + LC_MEASUREMENT = "en_US.UTF-8"; + LC_MONETARY = "en_US.UTF-8"; + LC_NAME = "en_US.UTF-8"; + LC_NUMERIC = "en_US.UTF-8"; + LC_PAPER = "en_US.UTF-8"; + LC_TELEPHONE = "en_US.UTF-8"; + LC_TIME = "en_US.UTF-8"; + }; + + # Configure keymap in X11 + services.xserver = { + xkb.layout = "us"; + xkb.variant = ""; + }; + + # Define a user account. Don't forget to set a password with ‘passwd’. + users.users.youwen = { + isNormalUser = true; + description = "Youwen Wu"; + }; + + nix.settings = { + trusted-users = [ + "root" + "youwen" + ]; + }; + + # Allow unfree packages + nixpkgs.config.allowUnfree = true; + + # List packages installed in system profile. To search, run: + # $ nix search wget + environment.systemPackages = with pkgs; [ + wget + git + curl + ]; + + environment.variables = { + EDITOR = "nvim"; + }; + + # tells electron apps to use Wayland + environment.sessionVariables.NIXOS_OZONE_WL = "1"; + + # Some programs need SUID wrappers, can be configured further or are + # started in user sessions. + # programs.mtr.enable = true; + programs.gnupg.agent = { + enable = true; + enableSSHSupport = true; + }; + + programs.dconf.enable = true; + + programs.fish.enable = true; + users.users.youwen.shell = pkgs.fish; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + + # 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? +} diff --git a/hosts/cassini/default.nix b/hosts/cassini/default.nix new file mode 100644 index 0000000..7630b1f --- /dev/null +++ b/hosts/cassini/default.nix @@ -0,0 +1,38 @@ +{ + inputs, + ... +}: +{ + imports = + [ + ./configuration.nix + ../../modules/linux/core + ../../modules/linux/stylix + ../../overlays + ../../modules/linux/wsl + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.backupFileExtension = "backup"; + home-manager.extraSpecialArgs = { + inherit inputs; + }; + home-manager.users.youwen = { + imports = + [ + ./home-manager-extras + ../../users/youwen/common + ../../users/youwen/linux/theming + ../../users/youwen/linux/home.nix + ../../users/youwen/common/fastfetch + ] + ++ (with inputs; [ + nix-index-database.hmModules.nix-index + ]); + }; + } + ] + ++ (with inputs; [ + home-manager.nixosModules.home-manager + ]); +} diff --git a/hosts/cassini/hardware-configuration.nix b/hosts/cassini/hardware-configuration.nix new file mode 100644 index 0000000..9fffae6 --- /dev/null +++ b/hosts/cassini/hardware-configuration.nix @@ -0,0 +1,53 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ + config, + lib, + pkgs, + modulesPath, + ... +}: +{ + imports = [ (modulesPath + "/installer/scan/not-detected.nix") ]; + + boot.initrd.availableKernelModules = [ + "nvme" + "xhci_pci" + "usbhid" + "usb_storage" + "sd_mod" + ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-amd" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = { + device = "/dev/disk/by-uuid/01983a52-5693-4cda-ad2e-5a406776bfb9"; + fsType = "ext4"; + }; + + boot.initrd.luks.devices."luks-f169a679-d70b-4dff-a344-7131f3303813".device = "/dev/disk/by-uuid/f169a679-d70b-4dff-a344-7131f3303813"; + + fileSystems."/boot" = { + device = "/dev/disk/by-uuid/3FCB-9D60"; + fsType = "vfat"; + options = [ + "fmask=0022" + "dmask=0022" + ]; + }; + + swapDevices = [ { device = "/dev/disk/by-uuid/f28d0752-feab-4591-899e-e5deac3712d0"; } ]; + + # Enables DHCP on each ethernet and wireless interface. In case of scripted networking + # (the default) this is the recommended approach. When using systemd-networkd it's + # still possible to use this option, but it's recommended to use it in conjunction + # with explicit per-interface declarations with `networking.interfaces..useDHCP`. + networking.useDHCP = lib.mkDefault true; + # networking.interfaces.enp4s0f3u2.useDHCP = lib.mkDefault true; + # networking.interfaces.wlp2s0.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/hosts/cassini/home-manager-extras/default.nix b/hosts/cassini/home-manager-extras/default.nix new file mode 100644 index 0000000..6e5b8c3 --- /dev/null +++ b/hosts/cassini/home-manager-extras/default.nix @@ -0,0 +1,3 @@ +{ pkgs, ... }: +{ +} diff --git a/modules/linux/wsl/default.nix b/modules/linux/wsl/default.nix new file mode 100644 index 0000000..da6d488 --- /dev/null +++ b/modules/linux/wsl/default.nix @@ -0,0 +1,12 @@ +{ inputs, ... }: +{ + imports = [ + inputs.nixos-wsl.nixosModules.default + ]; + + wsl = { + enable = true; + defaultUser = "youwen"; + useWindowsDriver = true; + }; +}