From b154030d2111f7048071b50a2f6160cd9cc49955 Mon Sep 17 00:00:00 2001 From: Maciej Jur Date: Sun, 9 Jun 2024 00:36:28 +0200 Subject: [PATCH] move to nixos --- nixos/msi/configuration.nix | 185 +++++++++++++++++++++++++++ nixos/msi/hardware-configuration.nix | 41 ++++++ nixos/msi/nvidia.nix | 54 ++++++++ nvim/lua/config/plugins.lua | 18 +-- 4 files changed, 290 insertions(+), 8 deletions(-) create mode 100644 nixos/msi/configuration.nix create mode 100644 nixos/msi/hardware-configuration.nix create mode 100644 nixos/msi/nvidia.nix diff --git a/nixos/msi/configuration.nix b/nixos/msi/configuration.nix new file mode 100644 index 0000000..b518cd9 --- /dev/null +++ b/nixos/msi/configuration.nix @@ -0,0 +1,185 @@ +# 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, ... }: +let + unstable = import "/nix/var/nix/profiles/per-user/root/channels/unstable" {}; +in +{ + imports = + [ # Include the results of the hardware scan. + ./hardware-configuration.nix + ./nvidia.nix + ]; + + # Use the systemd-boot EFI boot loader. + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + networking.hostName = "nixos"; # Define your hostname. + # Pick only one of the below networking options. + # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. + networking.networkmanager.enable = true; # Easiest to use and most distros use this by default. + + # Set your time zone. + time.timeZone = "Europe/Warsaw"; + + # Configure network proxy if necessary + # networking.proxy.default = "http://user:password@proxy:port/"; + # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; + + # Select internationalisation properties. + i18n = { + defaultLocale = "en_US.UTF-8"; + inputMethod = { + enabled = "fcitx5"; + fcitx5 = { + waylandFrontend = true; + plasma6Support = true; + addons = with pkgs; [ fcitx5-mozc ]; + }; + }; + }; + + fonts.packages = with pkgs; [ + noto-fonts + noto-fonts-cjk + noto-fonts-emoji + (nerdfonts.override { fonts = [ "JetBrainsMono" ]; }) + ]; + + # console = { + # font = "Lat2-Terminus16"; + # keyMap = "us"; + # useXkbConfig = true; # use xkb.options in tty. + # }; + + services = { + xserver.enable = true; + desktopManager.plasma6.enable = true; + displayManager.sddm.enable = true; + }; + + # Configure keymap in X11 + # services.xserver.xkb.layout = "us"; + # services.xserver.xkb.options = "eurosign:e,caps:escape"; + + # Enable CUPS to print documents. + # services.printing.enable = true; + + # Enable sound. + services.pipewire = { + enable = true; + audio.enable = true; + pulse.enable = true; + jack.enable = true; + alsa.enable = true; + alsa.support32Bit = true; + wireplumber.enable = true; + }; + + # Enable touchpad support (enabled default in most desktopManager). + services.libinput.enable = true; + + # Define a user account. Don't forget to set a password with ‘passwd’. + users.users.kamov = { + isNormalUser = true; + extraGroups = [ "wheel" ]; # Enable ‘sudo’ for the user. + packages = with pkgs; [ + anki + discord + spotify + firefox-devedition + unstable.neovide + ]; + }; + + # Enable unfree packages + nixpkgs.config.allowUnfree = true; + + # List packages installed in system profile. To search, run: + # $ nix search wget + environment.systemPackages = with pkgs; [ + vim + git + curl + wget + gnumake + gcc + nodejs_22 + # Language servers + lua-language-server # Lua + nixd # Nix + # Neovim + wl-clipboard + tree-sitter + ripgrep + fd + unzip + unstable.neovim + ]; + + # 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; + }; + }; + steam = { + enable = true; + }; + git = { + enable = true; + config = { + user.name = "Maciej Jur"; + user.email = "maciej@kamoshi.org"; + user.signingkey = "191CBFF5F72ECAFD!"; + commit.gpgsign = true; + init.defaultBranch = "main"; + core.editor = "vim"; + }; + }; + }; + + # List services that you want to enable: + + # Enable the OpenSSH daemon. + services.openssh.enable = true; + + # Open ports in the firewall. + # networking.firewall.allowedTCPPorts = [ ... ]; + # networking.firewall.allowedUDPPorts = [ ... ]; + # Or disable the firewall altogether. + networking.firewall.enable = true; + + # Copy the NixOS configuration file and link it from the resulting system + # (/run/current-system/configuration.nix). This is useful in case you + # accidentally delete configuration.nix. + system.copySystemConfiguration = true; + + # This option defines the first version of NixOS you have installed on this particular machine, + # and is used to maintain compatibility with application data (e.g. databases) created on older NixOS versions. + # + # Most users should NEVER change this value after the initial install, for any reason, + # even if you've upgraded your system to a new NixOS release. + # + # This value does NOT affect the Nixpkgs version your packages and OS are pulled from, + # so changing it will NOT upgrade your system - see https://nixos.org/manual/nixos/stable/#sec-upgrading for how + # to actually do that. + # + # This value being lower than the current NixOS release does NOT mean your system is + # out of date, out of support, or vulnerable. + # + # Do NOT change this value unless you have manually inspected all the changes it would make to your configuration, + # and migrated your data accordingly. + # + # For more information, see `man configuration.nix` or https://nixos.org/manual/nixos/stable/options#opt-system.stateVersion . + system.stateVersion = "24.05"; # Did you read the comment? + +} + diff --git a/nixos/msi/hardware-configuration.nix b/nixos/msi/hardware-configuration.nix new file mode 100644 index 0000000..87a2474 --- /dev/null +++ b/nixos/msi/hardware-configuration.nix @@ -0,0 +1,41 @@ +# 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 = [ "xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod" "rtsx_usb_sdmmc" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/7d578cdd-5888-4aa6-a191-cbabc7dfc6f6"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/6524-B34D"; + fsType = "vfat"; + options = [ "fmask=0077" "dmask=0077" ]; + }; + + swapDevices = + [ { device = "/dev/disk/by-uuid/3af88bfa-e2e4-4a3d-99a4-c071f9b32846"; } + ]; + + # 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.enp3s0.useDHCP = lib.mkDefault true; + # networking.interfaces.wlp2s0.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/nixos/msi/nvidia.nix b/nixos/msi/nvidia.nix new file mode 100644 index 0000000..87d896f --- /dev/null +++ b/nixos/msi/nvidia.nix @@ -0,0 +1,54 @@ +{ pkgs, config, libs, ... }: + +{ + # Enable unfree packages + nixpkgs.config.allowUnfree = true; + + # Enable OpenGL + hardware.opengl = { + enable = true; + driSupport = true; + driSupport32Bit = true; + }; + + # Load nvidia driver for Xorg and Wayland + services.xserver.videoDrivers = [ "nvidia" ]; + + # Disable nouveau driver + boot.blacklistedKernelModules = [ "nouveau" ]; + + hardware.nvidia = { + # Modesetting is required. + modesetting.enable = true; + + # Nvidia power management. Experimental, and can cause sleep/suspend to fail. + powerManagement.enable = false; + # Fine-grained power management. Turns off GPU when not in use. + # Experimental and only works on modern Nvidia GPUs (Turing or newer). + powerManagement.finegrained = false; + + # Use the NVidia open source kernel module (not to be confused with the + # independent third-party "nouveau" open source driver). + # Support is limited to the Turing and later architectures. Full list of + # supported GPUs is at: + # https://github.com/NVIDIA/open-gpu-kernel-modules#compatible-gpus + # Only available from driver 515.43.04+ + # Currently alpha-quality/buggy, so false is currently the recommended setting. + open = false; + + # Enable the Nvidia settings menu, + # accessible via `nvidia-settings`. + nvidiaSettings = true; + + # Optionally, you may need to select the appropriate driver version for your specific GPU. + package = config.boot.kernelPackages.nvidiaPackages.stable; + + prime = { + # Without this option set to true SDDM didn't want to start. + sync.enable = true; + # Make sure to use the correct Bus ID values for your system! + intelBusId = "PCI:0:2:0"; + nvidiaBusId = "PCI:1:0:0"; + }; + }; +} diff --git a/nvim/lua/config/plugins.lua b/nvim/lua/config/plugins.lua index 0e5b6f8..4b29982 100644 --- a/nvim/lua/config/plugins.lua +++ b/nvim/lua/config/plugins.lua @@ -319,23 +319,25 @@ return { local noop = function() end + lsp.nixd.setup {} + config.setup { - automatic_installation = true, + automatic_installation = false, -- NOTE: hls is installed via GHCup ensure_installed = { - 'lua_ls', -- Lua - 'fennel_ls', -- Fennel - 'rust_analyzer', -- Rust + -- 'lua_ls', -- Lua + -- 'fennel_ls', -- Fennel + -- 'rust_analyzer', -- Rust -- 'clangd', -- C -- 'bashls', -- Bash - 'html', -- HTML - 'cssls', -- CSS / SCSS - 'tsserver', -- TypeScript + -- 'html', -- HTML + -- 'cssls', -- CSS / SCSS + -- 'tsserver', -- TypeScript -- 'svelte', -- Svelte -- 'pyright', -- Python -- 'rnix', -- Nix -- 'purescriptls', -- Purescript - 'ltex', -- Literate - LaTeX, Markdown, etc. + -- 'ltex', -- Literate - LaTeX, Markdown, etc. -- 'rescriptls', -- ReScript }, }