nixos/flake.nix

280 lines
8.1 KiB
Nix
Raw Normal View History

2023-07-08 16:56:36 +08:00
{
description = "CNH's NixOS Flake";
2023-07-08 16:26:12 +08:00
2023-07-08 16:56:36 +08:00
inputs =
{
2023-07-15 13:18:27 +08:00
nixpkgs.url = "github:CHN-beta/nixpkgs/nixos-unstable";
2023-07-08 16:56:36 +08:00
nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-23.05";
flake-utils.url = "github:numtide/flake-utils";
2023-07-11 10:05:16 +08:00
flake-utils-plus =
{
url = "github:gytis-ivaskevicius/flake-utils-plus";
inputs.flake-utils.follows = "flake-utils";
};
2023-07-08 16:56:36 +08:00
flake-compat = { url = "github:edolstra/flake-compat"; flake = false; };
2023-07-15 19:12:15 +08:00
flake-parts =
{
url = "github:hercules-ci/flake-parts";
inputs.nixpkgs-lib.follows = "nixpkgs";
};
2023-07-08 16:56:36 +08:00
nvfetcher =
{
url = "github:berberman/nvfetcher";
inputs =
{
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
flake-compat.follows = "flake-compat";
};
};
home-manager = { url = "github:nix-community/home-manager/master"; inputs.nixpkgs.follows = "nixpkgs"; };
sops-nix =
{
url = "github:Mic92/sops-nix";
inputs = { nixpkgs.follows = "nixpkgs"; nixpkgs-stable.follows = "nixpkgs-stable"; };
};
touchix = { url = "github:CHN-beta/touchix"; inputs.nixpkgs.follows = "nixpkgs"; };
aagl =
{
url = "github:ezKEa/aagl-gtk-on-nix";
inputs = { nixpkgs.follows = "nixpkgs"; flake-compat.follows = "flake-compat"; };
};
nix-index-database = { url = "github:Mic92/nix-index-database"; inputs.nixpkgs.follows = "nixpkgs"; };
nur.url = "github:nix-community/NUR";
nixos-cn =
{
url = "github:nixos-cn/flakes";
inputs = { nixpkgs.follows = "nixpkgs"; flake-utils.follows = "flake-utils"; };
};
nur-xddxdd =
{
url = "github:xddxdd/nur-packages";
2023-07-11 10:05:16 +08:00
inputs =
{
flake-utils.follows = "flake-utils";
nixpkgs.follows = "nixpkgs-stable";
flake-utils-plus.follows = "flake-utils-plus";
};
2023-07-08 16:56:36 +08:00
};
nix-vscode-extensions =
{
url = "github:nix-community/nix-vscode-extensions";
inputs =
{
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
flake-compat.follows = "flake-compat";
};
};
nix-alien =
{
url = "github:thiagokokada/nix-alien";
inputs =
{
flake-compat.follows = "flake-compat";
flake-utils.follows = "flake-utils";
nix-index-database.follows = "nix-index-database";
};
};
impermanence.url = "github:nix-community/impermanence";
qchem =
{
url = "github:Nix-QChem/NixOS-QChem";
inputs.nixpkgs.follows = "nixpkgs";
};
2023-07-15 19:12:15 +08:00
nixd =
{
url = "github:nix-community/nixd";
inputs =
{
nixpkgs.follows = "nixpkgs";
flake-parts.follows = "flake-parts";
};
};
2023-07-08 16:56:36 +08:00
};
2023-07-08 16:26:12 +08:00
2023-07-08 16:56:36 +08:00
outputs = inputs:
let
2023-07-21 21:57:06 +08:00
localLib = import ./local/lib inputs.nixpkgs.lib;
localPkgs = import ./local/pkgs;
2023-07-08 16:56:36 +08:00
in
2023-06-13 13:50:37 +08:00
{
2023-07-08 16:56:36 +08:00
nixosConfigurations =
2023-06-13 13:50:37 +08:00
{
2023-07-08 16:56:36 +08:00
"chn-PC" = inputs.nixpkgs.lib.nixosSystem
{
system = "x86_64-linux";
2023-07-21 21:57:06 +08:00
specialArgs = { topInputs = inputs; inherit localLib; };
2023-07-08 16:56:36 +08:00
modules =
[
inputs.home-manager.nixosModules.home-manager
inputs.sops-nix.nixosModules.sops
inputs.touchix.nixosModules.v2ray-forwarder
inputs.aagl.nixosModules.default
inputs.nix-index-database.nixosModules.nix-index
inputs.nur.nixosModules.nur
inputs.nur-xddxdd.nixosModules.setupOverlay
inputs.impermanence.nixosModules.impermanence
(args: {
config.nixpkgs =
{
overlays =
[
(
final: prev:
{
touchix = inputs.touchix.packages."${prev.system}";
nix-vscode-extensions = inputs.nix-vscode-extensions.extensions."${prev.system}";
2023-07-21 21:57:06 +08:00
localPackages = localPkgs { inherit (args) lib; pkgs = final; };
2023-07-08 16:56:36 +08:00
}
)
inputs.qchem.overlays.default
(
final: prev: { nur-xddxdd =
(inputs.nur-xddxdd.overlays.custom args.config.boot.kernelPackages.nvidia_x11) final prev; }
)
2023-07-15 19:12:15 +08:00
inputs.nixd.overlays.default
2023-07-23 00:09:54 +08:00
inputs.nix-alien.overlays.default
2023-07-08 16:56:36 +08:00
];
config.allowUnfree = true;
};
})
(
2023-07-21 21:57:06 +08:00
localLib.mkModules
2023-07-08 16:26:12 +08:00
[
2023-07-15 22:20:30 +08:00
./modules/fileSystems
./modules/kernel
2023-07-15 22:45:35 +08:00
./modules/hardware
2023-07-18 13:55:24 +08:00
./modules/packages
2023-07-21 21:46:24 +08:00
./modules/boot
2023-07-22 00:01:56 +08:00
./modules/system
2023-07-22 15:05:18 +08:00
./modules/virtualization
2023-07-25 23:33:37 +08:00
./modules/services
2023-07-27 19:01:58 +08:00
./modules/bugs
2023-07-27 21:14:39 +08:00
./modules/users
2023-07-25 20:06:07 +08:00
(inputs: { config =
{
nixos =
2023-07-09 12:39:03 +08:00
{
fileSystems =
{
2023-07-09 12:50:30 +08:00
mount =
2023-07-09 12:39:03 +08:00
{
vfat."/dev/disk/by-uuid/3F57-0EBE" = "/boot/efi";
btrfs =
{
"/dev/disk/by-uuid/02e426ec-cfa2-4a18-b3a5-57ef04d66614"."/" = "/boot";
2023-07-14 16:57:57 +08:00
"/dev/mapper/root" = { "/nix" = "/nix"; "/nix/rootfs/current" = "/"; };
2023-07-09 12:39:03 +08:00
};
};
2023-07-09 13:27:01 +08:00
decrypt.auto =
{
"/dev/disk/by-uuid/55fdd19f-0f1d-4c37-bd4e-6df44fc31f26" = { mapper = "root"; ssd = true; };
2023-07-22 18:25:26 +08:00
"/dev/md/swap" = { mapper = "swap"; ssd = true; before = [ "root" ]; };
2023-07-09 13:27:01 +08:00
};
2023-07-09 13:33:40 +08:00
mdadm =
"ARRAY /dev/md/swap metadata=1.2 name=chn-PC:swap UUID=2b546b8d:e38007c8:02990dd1:df9e23a4";
2023-07-09 22:51:56 +08:00
swap = [ "/dev/mapper/swap" ];
2023-07-10 13:18:49 +08:00
resume = "/dev/mapper/swap";
2023-07-14 16:57:57 +08:00
rollingRootfs = { device = "/dev/mapper/root"; path = "/nix/rootfs"; };
2023-07-09 12:39:03 +08:00
};
2023-07-14 17:10:53 +08:00
kernel =
{
2023-07-27 19:01:58 +08:00
patches = [ "cjktty" "preempt" ];
2023-07-22 12:30:37 +08:00
modules.modprobeConfig = [ "options iwlmvm power_scheme=1" "options iwlwifi uapsd_disable=1" ];
2023-07-14 17:10:53 +08:00
};
2023-07-15 22:45:35 +08:00
hardware =
{
2023-07-27 11:05:14 +08:00
cpus = [ "intel" ];
gpus = [ "intel" "nvidia" ];
2023-07-15 22:45:35 +08:00
bluetooth.enable = true;
2023-07-15 22:48:24 +08:00
joystick.enable = true;
2023-07-18 18:19:00 +08:00
printer.enable = true;
2023-07-19 00:10:36 +08:00
sound.enable = true;
2023-07-27 11:05:14 +08:00
prime =
{ enable = true; mode = "offload"; busId = { intel = "PCI:0:2:0"; nvidia = "PCI:1:0:0"; };};
2023-07-15 22:45:35 +08:00
};
2023-07-18 13:55:24 +08:00
packages =
{
2023-07-25 18:04:29 +08:00
packageSet = "workstation";
extraPackages = [ inputs.pkgs.localPackages.oneapi ];
extraPythonPackages = [(pythonPackages:
[ inputs.pkgs.localPackages.upho inputs.pkgs.localPackages.spectral ])];
2023-07-18 13:55:24 +08:00
};
2023-07-21 21:46:24 +08:00
boot.grub =
{
2023-07-22 00:14:07 +08:00
entries = localLib.stripeTabs
2023-07-22 00:37:12 +08:00
''
menuentry "Windows" {
2023-07-21 21:46:24 +08:00
insmod part_gpt
insmod fat
insmod search_fs_uuid
insmod chain
search --fs-uuid --set=root 7317-1DB6
chainloader /EFI/Microsoft/Boot/bootmgfw.efi
}
2023-07-22 00:37:12 +08:00
menuentry "Windows for malware" {
2023-07-21 21:46:24 +08:00
insmod part_gpt
insmod fat
insmod search_fs_uuid
insmod chain
search --fs-uuid --set=root 7321-FA9C
chainloader /EFI/Microsoft/Boot/bootmgfw.efi
}
2023-07-22 00:37:12 +08:00
'';
2023-07-21 21:46:24 +08:00
installDevice = "efi";
};
2023-07-22 00:01:56 +08:00
system =
{
hostname = "chn-PC";
2023-07-22 12:45:26 +08:00
march = "alderlake";
2023-07-23 15:49:00 +08:00
gui.enable = true;
2023-07-22 00:01:56 +08:00
};
2023-07-22 15:05:18 +08:00
virtualization =
{
waydroid.enable = true;
docker.enable = true;
2023-07-22 18:03:09 +08:00
kvmHost = { enable = true; gui = true; autoSuspend = [ "win10" "hardconnect" ]; };
2023-07-27 00:16:17 +08:00
# kvmGuest.enable = true;
2023-07-24 12:41:38 +08:00
nspawn = [ "arch" "ubuntu-22.04" ];
2023-07-22 15:05:18 +08:00
};
2023-07-25 23:33:37 +08:00
services =
{
impermanence.enable = true;
snapper = { enable = true; configs.persistent = "/nix/persistent"; };
2023-07-26 17:03:09 +08:00
fontconfig.enable = true;
2023-07-26 17:08:32 +08:00
u2f.enable = true;
2023-07-26 21:05:46 +08:00
sops = { enable = true; keyPathPrefix = "/nix/persistent"; };
samba =
{
enable = true;
private = true;
hostsAllowed = "192.168. 127.";
shares =
{
media.path = "/run/media/chn";
home.path = "/home/chn";
mnt.path = "/mnt";
share.path = "/home/chn/share";
};
};
2023-07-27 00:07:20 +08:00
sshd.enable = true;
2023-07-27 19:01:58 +08:00
xrayClient = { enable = true; dnsAdditionalInterfaces = [ "docker0" ]; };
firewall.trustedInterfaces = [ "docker0" "virbr0" ];
2023-07-25 23:33:37 +08:00
};
2023-07-27 19:01:58 +08:00
bugs = [ "intel-hdmi" "suspend-hibernate-no-platform" "hibernate-iwlwifi" "suspend-lid-no-wakeup" ];
2023-07-27 11:05:14 +08:00
};
2023-07-25 20:06:07 +08:00
}; })
2023-07-08 16:56:36 +08:00
./modules/networking/xmunet.nix
./modules/networking/chn-PC.nix
]
)
];
};
2023-06-13 13:50:37 +08:00
};
2023-07-08 16:56:36 +08:00
};
}
2023-07-25 18:04:29 +08:00