move some nixos configuration to ./nixos/modules and ./nixos/configurations. try to find a good arch to conbine home-manager and nixos modules.

This commit is contained in:
Ulic-youthlic 2025-01-07 22:41:55 +08:00
parent 6be554822c
commit 64db779064
32 changed files with 534 additions and 635 deletions

View file

@ -0,0 +1,43 @@
{ pkgs, inputs, ... }:
{
imports =
(with inputs; [
nixos-hardware.nixosModules.asus-fx506hm
])
++ [
# Include the hardware related config
./hardware-configuration.nix
./networking.nix
];
networking.hostName = "Tytonidae";
time.timeZone = "Asia/Shanghai";
i18n = {
defaultLocale = "C.UTF-8";
extraLocaleSettings = {
LC_ADDRESS = "zh_CN.UTF-8";
LC_IDENTIFICATION = "zh_CN.UTF-8";
LC_MEASUREMENT = "zh_CN.UTF-8";
LC_MONETARY = "zh_CN.UTF-8";
LC_NAME = "zh_CN.UTF-8";
LC_NUMERIC = "zh_CN.UTF-8";
LC_PAPER = "zh_CN.UTF-8";
LC_TELEPHONE = "zh_CN.UTF-8";
LC_TIME = "zh_CN.UTF-8";
};
};
nixpkgs = {
config = {
allowUnfree = true;
};
};
boot = {
kernelPackages = pkgs.linuxPackages_zen;
loader.systemd-boot.enable = true;
loader.efi.canTouchEfiVariables = true;
};
}

View file

@ -0,0 +1,58 @@
# 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"
"thunderbolt"
"nvme"
"usbhid"
"usb_storage"
"sd_mod"
];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ];
fileSystems."/" = {
device = "/dev/disk/by-uuid/b638dbc9-8945-482d-9d10-193271d3df98";
fsType = "ext4";
};
fileSystems."/boot" = {
device = "/dev/disk/by-uuid/A779-6930";
fsType = "vfat";
options = [
"fmask=0077"
"dmask=0077"
];
};
swapDevices = [
{ device = "/dev/disk/by-uuid/7f7e95f2-8f2a-4998-bd71-01466e8ecc98"; }
];
# 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.eno2.useDHCP = lib.mkDefault true;
# networking.interfaces.enp0s13f0u1u1.useDHCP = lib.mkDefault true;
# networking.interfaces.wlo1.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

View file

@ -0,0 +1,36 @@
{ ... }:
{
systemd.network = {
enable = true;
wait-online.enable = false;
networks = {
"eno2" = {
matchConfig.Name = "eno2";
networkConfig = {
DHCP = "yes";
IPv6AcceptRA = true;
};
};
};
};
networking = {
networkmanager.enable = false;
useNetworkd = true;
useDHCP = false;
wireless.iwd = {
enable = true;
settings = {
General = {
EnableNetworkConfiguration = true;
};
Network = {
EnableIPv6 = true;
NameResolvingService = "systemd";
};
};
};
firewall.enable = false;
};
}

30
nixos/modules/default.nix Normal file
View file

@ -0,0 +1,30 @@
{
inputs,
outputs,
pkgs,
...
}:
{
imports =
(with inputs; [
niri-flake.nixosModules.niri
nixos-cosmic.nixosModules.default
home-manager.nixosModules.home-manager
dae.nixosModules.dae
])
++ [
./nix.nix
];
config = {
nixpkgs = {
overlays =
(with outputs; [
overlays.modifications
])
++ (with inputs; [
niri-flake.overlays.niri
]);
};
};
}

45
nixos/modules/nix.nix Normal file
View file

@ -0,0 +1,45 @@
{
inputs,
outputs,
pkgs,
lib,
...
}:
{
config = {
nix = {
nixPath = [ "nixpkgs=${inputs.nixpkgs}" ];
settings = {
inherit (outputs.nix.settings) substituters;
trusted-users = [
"root"
"@wheel"
];
trusted-public-keys = [
"cosmic.cachix.org-1:Dya9IyXD4xdBehWjrkPv6rtxpmMdRel02smYzA85dPE="
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
];
auto-optimise-store = lib.mkDefault true;
experimental-features = [
"nix-command"
"flakes"
];
warn-dirty = false;
system-features = [
"kvm"
"big-parallel"
];
use-xdg-base-directories = true;
builders-use-substitutes = true;
};
package = pkgs.nix;
registry.sys = lib.mkDefault {
from = {
type = "indirect";
id = "sys";
};
flake = inputs.nixpkgs;
};
};
};
}