All this just to get nyx to even build

This commit is contained in:
blahai 2025-01-12 18:35:44 +02:00
parent ed1aafe645
commit fdfd4e0434
Signed by: blahai
SSH key fingerprint: SHA256:ZfCryi+V64yG+vC1ZIIsqgvBCmA31tTi7RJ6M8CvpRc
24 changed files with 2272 additions and 0 deletions

1675
flake.lock Normal file

File diff suppressed because it is too large Load diff

67
flake.nix Normal file
View file

@ -0,0 +1,67 @@
{
description = "Elissa's funny little flake";
outputs = inputs: inputs.flake-parts.lib.mkFlake {inherit inputs;} {imports = [./modules/flake];};
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
nixpkgs-smol.url = "github:nixos/nixpkgs?ref=nixos-unstable-small";
chaotic.url = "github:chaotic-cx/nyx/nyxpkgs-unstable";
nur.url = "github:nix-community/NUR";
wezterm.url = "github:wez/wezterm?dir=nix";
catppuccin.url = "github:catppuccin/nix";
hyprland.url = "github:hyprwm/Hyprland";
haivim = {
url = "github:blahai/haivim";
inputs = {nixpkgs.follows = "nixpkgs";};
};
ags = {
url = "github:Aylur/ags/v1";
inputs.nixpkgs.follows = "nixpkgs";
};
spicetify-nix = {
url = "github:Gerg-L/spicetify-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
disko = {
url = "github:nix-community/disko/master";
inputs.nixpkgs.follows = "nixpkgs";
};
agenix = {
url = "github:ryantm/agenix";
inputs.nixpkgs.follows = "nixpkgs";
};
sops-nix = {
url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
systems = {
url = "github:nix-systems/default";
};
flake-parts = {
url = "github:hercules-ci/flake-parts";
inputs.nixpkgs-lib.follows = "nixpkgs";
};
flake-utils = {
url = "github:numtide/flake-utils";
};
easy-hosts = {
url = "github:isabelroses/easy-hosts";
};
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
};
}

1
home/default.nix Normal file
View file

@ -0,0 +1 @@
{}

5
modules/base/default.nix Normal file
View file

@ -0,0 +1,5 @@
{
imports = [
./nix
];
}

View file

@ -0,0 +1,5 @@
{
imports = [
./system.nix
];
}

View file

@ -0,0 +1,11 @@
{
lib,
pkgs,
...
}: let
inherit (lib.modules) mkDefault;
in {
system = {
stateVersion = mkDefault "25.05";
};
}

17
modules/flake/args.nix Normal file
View file

@ -0,0 +1,17 @@
{inputs, ...}: {
systems = import inputs.systems;
perSystem = {system, ...}: {
# this is what controls how packages in the flake are built, but this is not passed to the
# builders in lib which is important to note, since we have to do something different for
# the builders to work correctly
_module.args.pkgs = import inputs.nixpkgs {
inherit system;
config = {
allowUnfree = true;
allowUnsupportedSystem = true;
};
# overlays = [ inputs.nix-topology.overlays.default ];
};
};
}

View file

@ -0,0 +1,7 @@
{
imports = [
../../systems
./args.nix
];
}

View file

@ -0,0 +1,7 @@
{
imports = [
./loader
./generic.nix
./plymouth.nix
];
}

View file

@ -0,0 +1,160 @@
{
pkgs,
config,
lib,
...
}: let
inherit (lib.modules) mkIf mkForce mkMerge mkDefault mkOverride;
inherit (lib.lists) optionals;
inherit (lib.options) mkOption mkEnableOption literalExpression;
inherit (lib.types) str raw listOf package;
cfg = config.olympus.system.boot;
in {
options.olympus.system.boot = {
enableKernelTweaks = mkEnableOption "security and performance related kernel parameters";
recommendedLoaderConfig = mkEnableOption "tweaks for common bootloader configs per my liking";
loadRecommendedModules = mkEnableOption "kernel modules that accommodate for most use cases";
kernel = mkOption {
type = raw;
default = pkgs.linuxPackages_6_12;
description = "The kernel to use for the system";
};
initrd = {
enableTweaks = mkEnableOption "quality of life tweaks for the initrd stage";
optimizeCompressor = mkEnableOption ''
initrd compression algorithm optimizations for size.
Enabling this option will force initrd to use zstd (default) with
level 19 and -T0 (STDIN). This will reduce the initrd size greatly
at the cost of compression speed.
Not recommended for low-end hardware.
'';
};
silentBoot =
mkEnableOption ''
almost entirely silent boot process through `quiet` kernel parameter
''
// {
default = cfg.plymouth.enable;
};
};
config = {
boot = {
consoleLogLevel = 3;
kernelPackages = mkDefault cfg.kernel;
loader = {
# if set to 0, space needs to be held to get the boot menu to appear
timeout = mkForce 2;
# copy boot files to /boot so that /nix/store is not required to boot
# it takes up more space but it makes my messups a bit safer
generationsDir.copyKernels = true;
# we need to allow installation to modify EFI variables
efi.canTouchEfiVariables = true;
};
# increase the map count, this is important for applications that require a lot of memory mappings
# such as games and emulators
kernel.sysctl."vm.max_map_count" = 2147483642;
initrd = mkMerge [
(mkIf cfg.initrd.enableTweaks {
# Verbosity of the initrd
# disabling verbosity removes only the mandatory messages generated by the NixOS
verbose = false;
systemd = {
# enable systemd in initrd (experimental)
enable = true;
# strip copied binaries and libraries from inframs
# saves some nice space
strip = true;
};
kernelModules = [
"nvme"
"xhci_pci"
"ahci"
"btrfs"
"sd_mod"
"dm_mod"
];
availableKernelModules = [
"vmd"
"usbhid"
"sd_mod"
"sr_mod"
"dm_mod"
"uas"
"usb_storage"
"ata_piix"
"virtio_pci"
"virtio_scsi"
"ehci_pci"
];
})
(mkIf cfg.initrd.optimizeCompressor {
compressor = "zstd";
compressorArgs = [
"-19"
"-T0"
];
})
];
# https://www.kernel.org/doc/html/latest/admin-guide/kernel-parameters.html
kernelParams =
optionals cfg.enableKernelTweaks [
# https://en.wikipedia.org/wiki/Kernel_page-table_isolation
# auto means kernel will automatically decide the pti state
"pti=auto" # on || off
# enable IOMMU for devices used in passthrough and provide better host performance
"iommu=pt"
# disable usb autosuspend
"usbcore.autosuspend=-1"
# allow systemd to set and save the backlight state
"acpi_backlight=native"
# prevent the kernel from blanking plymouth out of the fb
"fbcon=nodefer"
# disable boot logo
"logo.nologo"
# disable the cursor in vt to get a black screen during intermissions
"vt.global_cursor_default=0"
]
++ optionals cfg.silentBoot [
# tell the kernel to not be verbose, the voices are too loud
"quiet"
# kernel log message level
"loglevel=3" # 1: system is unusable | 3: error condition | 7: very verbose
# udev log message level
"udev.log_level=3"
# lower the udev log level to show only errors or worse
"rd.udev.log_level=3"
# disable systemd status messages
# rd prefix means systemd-udev will be used instead of initrd
"systemd.show_status=auto"
"rd.systemd.show_status=auto"
];
};
};
}

View file

@ -0,0 +1,19 @@
{lib, ...}: let
inherit (lib.options) mkOption;
inherit (lib.types) enum;
in {
imports = [
./systemd-boot.nix
./grub.nix
];
options.olympus.system.boot.loader = mkOption {
type = enum [
"none"
"grub"
"systemd-boot"
];
default = "none";
description = "The bootloader";
};
}

View file

@ -0,0 +1 @@
{}

View file

@ -0,0 +1,21 @@
{
lib,
pkgs,
config,
...
}: let
inherit (lib.modules) mkIf mkDefault;
inherit (lib.attrsets) optionalAttrs;
inherit (lib.options) mkEnableOption mkPackageOption;
cfg = config.olympus.system.boot;
in {
config = mkIf (cfg.loader == "systemd-boot") {
boot.loader.systemd-boot = {
enable = mkDefault true;
configurationLimit = 5;
consoleMode = "max";
editor = false;
};
};
}

View file

@ -0,0 +1,24 @@
{
lib,
pkgs,
config,
...
}: let
inherit (lib.meta) getExe';
inherit (lib.modules) mkIf;
inherit (lib.options) mkEnableOption;
cfg = config.olympus.system.boot.plymouth;
in {
options.olympus.system.boot.plymouth.enable = mkEnableOption "plymouth boot splash";
config = mkIf cfg.enable {
boot.plymouth.enable = true;
# make plymouth work with sleep
powerManagement = {
powerDownCommands = "${getExe' pkgs.plymouth "plymouth"} --show-splash";
resumeCommands = "${getExe' pkgs.plymouth "plymouth"} --quit";
};
};
}

View file

@ -0,0 +1,7 @@
{
imports = [
./boot
./environment
./networking
];
}

View file

@ -0,0 +1,6 @@
{
imports = [
./documentation.nix
./zram.nix
];
}

View file

@ -0,0 +1,18 @@
{lib, ...}: let
inherit (lib.modules) mkForce;
inherit (lib.attrsets) mapAttrs;
in {
documentation = mapAttrs (_: mkForce) {
enable = false;
dev.enable = false;
doc.enable = false;
info.enable = false;
nixos.enable = false;
man = {
enable = false;
generateCaches = false;
man-db.enable = false;
mandoc.enable = false;
};
};
}

View file

@ -0,0 +1,24 @@
{
lib,
config,
...
}: let
inherit (lib.modules) mkIf;
in {
# compress half of the ram to use as swap
# basically, get more memory per memory
zramSwap = {
enable = true;
algorithm = "zstd";
memoryPercent = 90; # defaults to 50
};
boot.kernel.sysctl = mkIf config.zramSwap.enable {
# zram is relatively cheap, prefer swap
"vm.swappiness" = 180;
"vm.watermark_boost_factor" = 0;
"vm.watermark_scale_factor" = 125;
# zram is in memory, no need to readahead
"vm.page-cluster" = 0;
};
}

View file

@ -0,0 +1,19 @@
{
lib,
config,
...
}: let
inherit (lib.modules) mkDefault mkForce;
in {
imports = [
];
networking = {
hostId = builtins.substring 0 8 (builtins.hashString "md5" config.networking.hostName);
useDHCP = mkForce false;
useNetworkd = mkForce true;
usePredictableInterfaceNames = mkDefault true;
};
}

View file

@ -0,0 +1 @@
{}

View file

@ -0,0 +1 @@
{}

81
systems/default.nix Normal file
View file

@ -0,0 +1,81 @@
{
self,
inputs,
lib,
...
}: let
# inherit (self) lib;
inherit (lib.lists) optionals;
profilesPath = ../modules/profiles;
# Hardware profiles
desktop = profilesPath + /desktop;
server = profilesPath + /server;
laptop = profilesPath + /laptop;
# Meta profiles
graphical = profilesPath + /graphical;
headless = profilesPath + /headless;
in {
imports = [inputs.easy-hosts.flakeModule];
config.easyHosts = {
shared.specialArgs = {inherit lib;};
perClass = class: {
modules = [
# import the class module, this contains the common configurations between all systems of the same class
"${self}/modules/${class}/default.nix"
(optionals (class != "iso") [
# import the home module, which is users for configuring users via home-manager
"${self}/home/default.nix"
# import the base module, this contains the common configurations between all systems
"${self}/modules/base/default.nix"
])
];
};
# the defaults consists of the following:
# arch = "x86_64";
# class = "nixos";
# deployable = false;
# modules = [ ];
# specialArgs = { };
hosts = {
# Elissa's desktop
nyx.modules = [
desktop
graphical
];
# Elissa's laptop
helios.modules = [
laptop
graphical
];
# Other desktop (will set up later)
aphrodite.modules = [
desktop
graphical
];
# Server
theia = {
deployable = true;
modules = [
server
headless
];
};
# ISO
epimetheus = {
class = "iso";
modules = [headless];
};
};
};
}

17
systems/nyx/default.nix Normal file
View file

@ -0,0 +1,17 @@
{
imports = [
./hardware.nix
];
olympus = {
system = {
boot = {
loader = "systemd-boot";
loadRecommendedModules = true;
enableKernelTweaks = true;
initrd.enableTweaks = true;
plymouth.enable = false;
};
};
};
}

78
systems/nyx/hardware.nix Normal file
View file

@ -0,0 +1,78 @@
{
fileSystems = {
"/" = {
device = "zpool/root";
fsType = "zfs";
options = ["zfsutil"];
};
"/nix" = {
device = "zpool/nix";
fsType = "zfs";
options = ["zfsutil"];
};
"/var" = {
device = "zpool/var";
fsType = "zfs";
options = ["zfsutil"];
};
"/home" = {
device = "zpool/home";
fsType = "zfs";
options = ["zfsutil"];
};
"/var/lib/virt/images" = {
device = "zepool/virt/images";
fsType = "zfs";
options = ["zfsutil"];
};
"/var/lib/virt/disks" = {
device = "zepool/virt/disks";
fsType = "zfs";
options = ["zfsutil"];
};
"/mnt/zootfs/Storage" = {
device = "zootfs/Storage";
fsType = "zfs";
options = ["zfsutil"];
};
"/mnt/zootfs/Media" = {
device = "zootfs/Media";
fsType = "zfs";
options = ["zfsutil"];
};
# https://github.com/atuinsh/atuin/issues/952#issuecomment-1902164562
"/home/pingu/.local/share/atuin" = {
device = "/dev/zvol/zpool/nixos/atuin";
fsType = "ext4";
options = ["async" "auto" "nofail"];
};
"/boot" = {
device = "/dev/disk/by-label/BOOT";
fsType = "vfat";
options = ["fmask=0022" "dmask=0022"];
};
"/mnt/ssd" = {
device = "/dev/disk/by-uuid/e4c31e1c-6667-4582-8d6a-d142d6118ce2";
fsType = "btrfs";
options = ["async" "auto" "noatime" "rw"];
};
"/mnt/ext" = {
device = "/dev/disk/by-uuid/43280a82-cf9a-452e-9bdc-a8cc66ccd7c8";
fsType = "btrfs";
options = ["async" "auto" "nofail" "noatime"];
};
};
swapDevices = [{device = "/dev/disk/by-uuid/04281bd7-784a-4287-b4f2-ce406d2ab6ac";}];
}