feat: add new host - msi-rtx4090

This commit is contained in:
Ryan Yin
2023-05-04 23:40:50 +08:00
parent c56db98288
commit 9e549fb733
7 changed files with 137 additions and 19 deletions

View File

@@ -25,7 +25,7 @@
};
# 这是 flake.nix 的标准格式inputs 是 flake 的依赖outputs 是 flake 的输出
# inputs 中的每一项都被拉取、构建后,被作为参数传递给 outputs 函数
# inputs 中的每一项都被拉取、构建后,被作为参数传递给 outputs 函数
inputs = {
# flake inputs 有很多种引用方式,应用最广泛的是 github 的引用方式
@@ -42,12 +42,12 @@
# outputs 的参数都是 inputs 中定义的依赖项,可以通过它们的名称来引用。
# 不过 self 是个例外,这个特殊参数指向 outputs 自身(自引用),以及 flake 根目录
# 这里的 @ 语法将函数的参数 attribute set 取了个别名,方便在内部使用
outputs = inputs@{
outputs = inputs@{
self,
nixpkgs,
home-manager,
nix-vscode-extensions,
...
...
}: {
# 名为 nixosConfigurations 的 outputs 会在执行 `nixos-rebuild switch --flake .` 时被使用
# 默认情况下会使用与主机 hostname 同名的 nixosConfigurations但是也可以通过 `--flake .#<name>` 来指定
@@ -62,7 +62,7 @@
# NixOS Module 可以是一个 attribute set也可以是一个返回 attribute set 的函数
# 如果是函数,那么它的参数就是当前的 NixOS Module 的参数.
# 根据 Nix Wiki 对 NixOS modules 的描述NixOS modules 函数的参数可以有这四个(详见本仓库中的 modules 文件):
#
#
# config: The configuration of the entire system
# options: All option declarations refined with all definition and declaration references.
# pkgs: The attribute set extracted from the Nix package collection and enhanced with the nixpkgs.config option.
@@ -71,7 +71,7 @@
# nix flake 的 modules 系统可将配置模块化,提升配置的可维护性
# 默认只能传上面这四个参数,如果需要传其他参数,必须使用 specialArgs
modules = [
./hosts
./hosts/nixos-test
# home-manager 作为 nixos 的一个 module
# 这样在 nixos-rebuild switch 时home-manager 也会被自动部署,不需要额外执行 home-manager switch 命令
@@ -87,8 +87,29 @@
];
};
msi-rtx4090 = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
./hosts/msi-rtx4090
# home-manager 作为 nixos 的一个 module
# 这样在 nixos-rebuild switch 时home-manager 也会被自动部署,不需要额外执行 home-manager switch 命令
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
# 使用 home-manager.extraSpecialArgs 自定义传递给 ./home 的参数
home-manager.extraSpecialArgs = inputs;
home-manager.users.ryan = import ./home;
}
];
};
# 如果你在 x86_64-linux 平台上执行 nix build那么默认会使用这个配置或者也能通过 `.#<name>` 参数来指定非 default 的配置
# packages.x86_64-linux.default =
# packages.x86_64-linux.default =
};
};
}

View File

@@ -18,6 +18,13 @@
executable = true; # make all scripts executable
};
# set cursor size and dpi for 4k monitor
xresources.properties = {
"Xcursor.size" = 16;
"Xft.dpi" = 192;
};
# 直接以 text 的方式,在 nix 配置文件中硬编码文件内容
# home.file.".xxx".text = ''
# xxx

View File

@@ -1,10 +0,0 @@
{
...
}: {
imports =
[
./nixos-test
../modules/system.nix
../modules/i3.nix
];
}

View File

@@ -0,0 +1,55 @@
# 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).
{ config, pkgs, ... }:
{
imports =
[
../../modules/system.nix
../../modules/i3.nix
# Include the results of the hardware scan.
./hardware-configuration.nix
];
# Bootloader.
boot.loader = {
efi = {
canTouchEfiVariables = true;
efiSysMountPoint = "/boot/efi"; # ← use the same mount point here.
};
systemd-boot.enable = true;
};
networking.hostName = "msi-rtx4090"; # Define your 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";
# Enable networking
networking.networkmanager.enable = true;
networking.defaultGateway = "192.168.5.201";
# for Nvidia GPU
services.xserver.videoDrivers = ["nvidia"];
hardware.opengl.enable = true;
hardware.nvidia = {
package = config.boot.kernelPackages.nvidiaPackages.stable;
modesetting.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. Its 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 = "22.11"; # Did you read the comment?
}

View File

@@ -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" "uas" "usb_storage" "sd_mod" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ];
fileSystems."/" =
{ device = "/dev/disk/by-uuid/9730ef67-577c-4dc9-8563-f431c1cf25fb";
fsType = "ext4";
};
fileSystems."/boot/efi" =
{ device = "/dev/disk/by-uuid/8DA9-86FF";
fsType = "vfat";
};
swapDevices =
[ { device = "/dev/disk/by-uuid/5364261a-3ecc-4754-b114-ff44c529627e"; }
];
# 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.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.enp5s0.useDHCP = lib.mkDefault true;
# networking.interfaces.wlo1.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
powerManagement.cpuFreqGovernor = lib.mkDefault "powersave";
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

View File

@@ -6,7 +6,11 @@
{
imports =
[ # Include the results of the hardware scan.
[
../../modules/system.nix
../../modules/i3.nix
# Include the results of the hardware scan.
./hardware-configuration.nix
];

View File

@@ -4,14 +4,14 @@
{
# i3 related options
environment.pathsToLink = [ "/libexec" ]; # links /libexec from derivations to /run/current-system/sw
environment.pathsToLink = [ "/libexec" ]; # links /libexec from derivations to /run/current-system/sw
services.xserver = {
enable = true;
desktopManager = {
xterm.enable = false;
};
displayManager = {
defaultSession = "none+i3";
lightdm.enable = false;