nixos-configuration/machines/morpheus.nix

187 lines
5.3 KiB
Nix

inputs:
let
system = "x86_64-linux";
hostname = "morpheus";
swapUUID = "93bdadfc-961a-4ea6-aef0-d3cd50847f0b";
overlay-unstable = final: prev: {
unstable = inputs.nixpkgs-unstable.legacyPackages.${prev.system};
};
in
inputs.nixpkgs.lib.nixosSystem {
inherit system;
modules = [
({ config, pkgs, ... } : {
system.stateVersion = "22.05";
nixpkgs.overlays = [ overlay-unstable ];
})
(import ./common.nix inputs)
(import ./sway.nix inputs)
(import ./morpheus/btrbk.nix inputs)
(import ./dev.nix inputs)
(import ./entertainment.nix inputs)
(import ./office.nix inputs)
({ pkgs, lib, ... }: {
system.autoUpgrade = {
enable = true;
allowReboot = false;
};
environment.systemPackages = with pkgs; [
# automatic btrfs snapshots
snapper
snapper-gui
];
networking = {
hostName = hostname;
interfaces.enp1s0.useDHCP = true;
interfaces.wlp2s0.useDHCP = true;
};
services = {
# enable touchpad support
libinput.enable = true;
blueman.enable = true;
snapper.configs = {
home = {
SUBVOLUME = "/home";
ALLOW_USERS = [ "me" ];
TIMELINE_CREATE = true;
TIMELINE_CLEANUP = true;
};
};
};
users.users.me = {
isNormalUser = true;
createHome = true;
extraGroups = [
"adbusers"
"audio"
"davfs2"
"disk"
"docker"
"libvirtd" # virt-manager
"networkmanager"
"plugdev"
"podman"
"users"
"uucp"
"vboxusers"
"video"
"wheel"
];
shell = pkgs.zsh;
};
boot = {
initrd = {
#availableKernelModules = [ "xhci_pci" "ehci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod" ];
availableKernelModules = [ "nvme" "xhci_pci" "usb_storage" "sd_mod" ];
kernelModules = [ ];
luks.devices."system" = {
device = "/dev/disk/by-uuid/06549d22-b96c-44f2-bb27-45200d5feda5";
# better SSD performance
# https://wiki.archlinux.org/title/Dm-crypt/Specialties#Disable_workqueue_for_increased_solid_state_drive_(SSD)_performance
bypassWorkqueues = true;
};
};
kernelModules = [ "kvm-amd" ];
# use latest kernel
kernelPackages = pkgs.linuxPackages_latest;
kernelParams = [
/* enable hibernation with swapfile */
/* https://wiki.archlinux.org/title/Power_management/Suspend_and_hibernate#Hibernation_into_swap_file */
("resume=UUID=" + swapUUID)
/* sudo filefrag -v /swap/swapfile | awk '$1=="0:" {print substr($4, 1, length($4)-2)}' */
"resume_offset=269568"
];
kernel.sysctl = {
# function keys on keychron keyboard won't work otherwise
"module.hid_apple.parameters.fnmode" = "2";
};
# Use the systemd-boot EFI boot loader.
loader = {
systemd-boot.enable = true;
efi = {
canTouchEfiVariables = true;
efiSysMountPoint = "/boot/efi";
};
};
# mount tmp as tmpfs
tmp.useTmpfs = true;
# Enable NTFS support
supportedFilesystems = [ "ntfs" ];
};
# btrf autoscrub
services.btrfs.autoScrub = {
enable = true;
# multiple subvolumes of the same fs are mounted. only scrub '/' to prevent multiple runs
fileSystems = [ "/" ];
};
fileSystems."/" =
{ device = "/dev/disk/by-uuid/93bdadfc-961a-4ea6-aef0-d3cd50847f0b";
fsType = "btrfs";
options = [ "subvol=root" "compress=zstd" ];
};
fileSystems."/boot/efi" =
{ device = "/dev/disk/by-uuid/4CD4-D5AB";
fsType = "vfat";
};
fileSystems."/nix" =
{ device = "/dev/disk/by-uuid/93bdadfc-961a-4ea6-aef0-d3cd50847f0b";
fsType = "btrfs";
options = [ "subvol=nix" "compress=zstd" "noatime" ];
};
fileSystems."/home" =
{ device = "/dev/disk/by-uuid/93bdadfc-961a-4ea6-aef0-d3cd50847f0b";
fsType = "btrfs";
options = [ "subvol=home" "compress=zstd" ];
};
fileSystems."/home/me/media" =
{ device = "/dev/disk/by-uuid/93bdadfc-961a-4ea6-aef0-d3cd50847f0b";
fsType = "btrfs";
options = [ "subvol=home/me/media" "compress=zstd" ];
};
fileSystems."/swap" =
{ device = "/dev/disk/by-uuid/" + swapUUID;
fsType = "btrfs";
options = [ "subvol=swap" "noatime" ];
};
swapDevices = [
{ device = "/swap/swapfile"; }
];
powerManagement.cpuFreqGovernor = lib.mkDefault "powersave";
hardware = {
bluetooth.enable = true;
#opengl = {
#extraPackages = with pkgs; [
#rocm-opencl-icd
#rocm-opencl-runtime
#];
#};
};
})
inputs.home-manager.nixosModules.home-manager
{
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
extraSpecialArgs = {
inherit inputs;
inherit system;
hostname = hostname;
};
users.me = import ../users/me.nix;
};
}
];
}