This commit is contained in:
2025-04-21 11:15:37 +08:00
parent f1df0aae36
commit cba96645e5
26 changed files with 619 additions and 423 deletions

View File

@@ -0,0 +1,40 @@
{ inputs, outputs, lib, pkgs, config, self, username, useremail, hostname, sysversion, ... }:
let
inherit (inputs) home-manager hyprland;
in
{
# You can import other NixOS modules here
imports = [
# If you want to use modules your own flake exports (from modules/nixos):
# outputs.nixosModules.example
# Or modules from other flakes (such as nixos-hardware):
# inputs.hardware.nixosModules.common-cpu-amd
# inputs.hardware.nixosModules.common-ssd
# You can also split up your configuration and import pieces of it here:
# ./users.nix
# Import your generated (nixos-generate-config) hardware configuration
./hardware-configuration
./networking
"${self}/modules/nixos/core"
"${self}/modules/nixos/user"
"${self}/modules/nixos/sysatomic"
home-manager.nixosModules.home-manager
{
# home-manager.useGlobalPkgs = true;
# home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = {
inherit inputs outputs hostname username hyprland sysversion;
};
home-manager.users."${username}" = import "${self}/home/desktop";
}
];
networking.hostName = "${hostname}";
# https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion
system.stateVersion = sysversion;
}

View File

@@ -13,23 +13,23 @@ in
# inputs.hardware.nixosModules.common-ssd
# You can also split up your configuration and import pieces of it here:
# ./users.nix
# ./users
# Import your generated (nixos-generate-config) hardware configuration
./hardware-configuration.nix
./networking.nix
"${self}/modules/nixos/core.nix"
"${self}/modules/nixos/nvidia.nix"
"${self}/modules/nixos/gnome.nix"
"${self}/modules/nixos/hyprland.nix"
"${self}/modules/nixos/user-group.nix"
"${self}/modules/nixos/samba.nix"
"${self}/modules/nixos/zfs.nix"
"${self}/modules/nixos/adb.nix"
./hardware-configuration
./networking
"${self}/modules/nixos/core"
"${self}/modules/nixos/sysatomic"
"${self}/modules/nixos/nvidia"
"${self}/modules/nixos/hyprland"
"${self}/modules/nixos/user"
"${self}/modules/nixos/samba"
"${self}/modules/nixos/zfs"
"${self}/modules/nixos/adb"
"${self}/modules/nixos/virtualize/libvirtd"
"${self}/modules/nixos/virtualize/android.nix"
"${self}/modules/nixos/virtualize/docker.nix"
"${self}/modules/nixos/virtualize/android"
"${self}/modules/nixos/virtualize/docker"
"${self}/modules/nixos/fonts"
@@ -59,31 +59,9 @@ in
}
];
boot = {
loader = {
efi = {
canTouchEfiVariables = true;
efiSysMountPoint = "/boot";
};
grub = {
enable = true;
efiSupport = true;
device = "nodev";
};
};
zfs.extraPools = [ "zroot" ];
# Allow to modify store. It's dangerous!!
readOnlyNixStore = true;
};
environment.systemPackages = with pkgs;[
# audio control software
pamixer
ntfs3g
];
# set hdmi audio default device
@@ -93,42 +71,6 @@ in
extraConfig = "set-card-profile 1 output:alsa_output.pci-0000_00_1f.3.hdmi-stereo";
};
nix = {
# This will add each flake input as a registry
# To make nix3 commands consistent with your flake
registry = lib.mapAttrs (_: value: { flake = value; }) inputs;
# This will additionally add your inputs to the system's legacy channels
# Making legacy nix commands consistent as well, awesome!
nixPath = lib.mapAttrsToList (key: value: "${key}=${value.to.path}") config.nix.registry;
};
nixpkgs = {
# You can add overlays here
overlays = [
# Add overlays your own flake exports (from overlays and pkgs dir):
outputs.overlays.additions
outputs.overlays.modifications
outputs.overlays.unstable-packages
outputs.overlays.nur-packages
# You can also add overlays exported from other flakes:
# neovim-nightly-overlay.overlays.default
# Or define it inline, for example:
# (final: prev: {
# hi = final.hello.overrideAttrs (oldAttrs: {
# patches = [ ./change-hello-to-hi.patch ];
# });
# })
];
# Configure your nixpkgs instance
config = {
# Disable if you don't want unfree packages
allowUnfree = true;
};
};
# https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion
system.stateVersion = sysversion;
}

View File

@@ -1,58 +0,0 @@
# 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, username, ... }:
{
imports =
[
(modulesPath + "/installer/scan/not-detected.nix")
];
boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ];
fileSystems."/" =
{
device = "/dev/disk/by-uuid/1be5aa7e-2b12-4532-9e42-65cd48b72aa6";
fsType = "ext4";
};
fileSystems."/boot" =
{
device = "/dev/disk/by-uuid/F436-93A1";
fsType = "vfat";
};
fileSystems."/home/${username}/tmp" =
{
device = "none";
fsType = "tmpfs";
options = [ "uid=1000" "gid=100" "defaults" "size=8G" "mode=755" ];
};
fileSystems."/tmp" =
{
device = "tmpfs";
fsType = "tmpfs";
};
swapDevices = [{
device = "/var/swapfile";
size = 8 * 1024;
}];
# 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.eno1.useDHCP = lib.mkDefault true;
# networking.interfaces.wlp4s0.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

@@ -0,0 +1,25 @@
# 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, username, ... }:
{
fileSystems."/home/${username}/tmp" =
{
device = "none";
fsType = "tmpfs";
options = [ "uid=1000" "gid=100" "defaults" "size=8G" "mode=755" ];
};
fileSystems."/tmp" =
{
device = "tmpfs";
fsType = "tmpfs";
};
swapDevices = [{
device = "/var/swapfile";
size = 16 * 1024;
}];
}

View File

@@ -16,126 +16,23 @@ in
# ./users.nix
# Import your generated (nixos-generate-config) hardware configuration
./hardware-configuration.nix
"${self}/modules/nixos/core.nix"
"${self}/modules/nixos/user-group.nix"
"${self}/modules/nixos/tmpsys.nix"
./hardware-configuration
./networking
"${self}/modules/nixos/core"
"${self}/modules/nixos/user"
home-manager.nixosModules.home-manager
{
# home-manager.useGlobalPkgs = true;
# home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = {
inherit inputs outputs hostname username useremail hyprland sysversion;
inherit inputs outputs hostname username hyprland sysversion;
};
home-manager.users."${username}" = import ../../home/desktop.nix;
home-manager.users."${username}" = import "${self}/home/desktop";
}
];
boot.loader = {
efi = {
canTouchEfiVariables = true;
efiSysMountPoint = "/boot";
};
grub = {
enable = true;
efiSupport = true;
device = "nodev";
};
};
networking = {
hostName = "${hostname}";
wireless.enable = false; # Enables wireless support via wpa_supplicant.
# Configure network proxy if necessary
# proxy.default = "http://user:password@proxy:port/";
# proxy.noProxy = "127.0.0.1,localhost,internal.domain";
networkmanager.enable = true;
enableIPv6 = false; # disable ipv6
interfaces.enp0s3 = {
useDHCP = false;
ipv4.addresses = [
{
address = "10.7.45.130";
prefixLength = 32;
}
];
};
defaultGateway = "10.7.45.1";
nameservers = [
"119.29.29.29" # DNSPod
"223.5.5.5" # AliDNS
];
};
users.users."${username}".packages = with pkgs; [
vim
];
# This setups a SSH server. Very important if you're setting up a headless system.
# Feel free to remove if you don't need it.
services.openssh = {
enable = true;
# Forbid root login through SSH.
# Use keys only. Remove if you want to SSH using password (not recommended)
settings = {
# permitRootLogin = "no";
# passwordAuthentication = false;
};
};
# networking.firewall.allowedTCPPorts = [ ... ];
# networking.firewall.allowedUDPPorts = [ ... ];
# Or disable the firewall altogether.
# networking.firewall.enable = lib.mkDefault false;
nix = {
# This will add each flake input as a registry
# To make nix3 commands consistent with your flake
registry = lib.mapAttrs (_: value: { flake = value; }) inputs;
# This will additionally add your inputs to the system's legacy channels
# Making legacy nix commands consistent as well, awesome!
nixPath = lib.mapAttrsToList (key: value: "${key}=${value.to.path}") config.nix.registry;
settings = {
# Enable flakes and new 'nix' command
experimental-features = "nix-command flakes";
# Deduplicate and optimize nix store
auto-optimise-store = true;
};
};
nixpkgs = {
# You can add overlays here
overlays = [
# Add overlays your own flake exports (from overlays and pkgs dir):
outputs.overlays.additions
outputs.overlays.modifications
outputs.overlays.unstable-packages
# You can also add overlays exported from other flakes:
# neovim-nightly-overlay.overlays.default
# Or define it inline, for example:
# (final: prev: {
# hi = final.hello.overrideAttrs (oldAttrs: {
# patches = [ ./change-hello-to-hi.patch ];
# });
# })
];
# Configure your nixpkgs instance
config = {
# Disable if you don't want unfree packages
allowUnfree = true;
};
};
networking.hostName = "${hostname}";
# https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion
system.stateVersion = sysversion;

View File

@@ -1,35 +0,0 @@
# 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 = [ ];
boot.initrd.availableKernelModules = [ "ata_piix" "ohci_pci" "ehci_pci" "ahci" "sd_mod" "sr_mod" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ ];
boot.extraModulePackages = [ ];
fileSystems."/" =
{ device = "/dev/disk/by-uuid/f8c5e9ad-010f-4201-9465-7486c5ffbaaa";
fsType = "ext4";
};
fileSystems."/boot" =
{ device = "/dev/disk/by-uuid/FEB9-6991";
fsType = "vfat";
};
swapDevices = [ ];
# 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.enp0s3.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
virtualisation.virtualbox.guest.enable = true;
}

View File

@@ -0,0 +1,30 @@
# 网络配置
{ config, lib, pkgs, ... }:
{
networking = {
wireless.enable = false; # Enables wireless support via wpa_supplicant.
# Configure network proxy if necessary
# proxy.default = "http://user:password@proxy:port/";
# proxy.noProxy = "127.0.0.1,localhost,internal.domain";
networkmanager.enable = true;
enableIPv6 = false; # disable ipv6
interfaces.enp0s3 = {
useDHCP = false;
ipv4.addresses = [
{
address = "10.7.45.130";
prefixLength = 24;
}
];
};
defaultGateway = "10.7.45.1";
nameservers = [
"119.29.29.29" # DNSPod
"223.5.5.5" # AliDNS
];
};
}