refactor nixosModules with consistency with homeManagerModules

This commit is contained in:
Aly Raffauf 2024-06-11 21:16:05 -04:00
parent 65ef82d0b4
commit 0e73c7580f
25 changed files with 403 additions and 338 deletions

View file

@ -5,18 +5,6 @@
...
}: {
config = lib.mkIf config.alyraffauf.desktop.hyprland.enable {
alyraffauf = {
desktop = {
waylandComp = lib.mkDefault true;
};
};
xdg.portal = {
enable = true;
configPackages = [pkgs.xdg-desktop-portal-hyprland];
extraPortals = [pkgs.xdg-desktop-portal-hyprland];
};
programs.waybar = {
settings = {
mainBar = {

View file

@ -29,12 +29,6 @@
};
config = lib.mkIf config.alyraffauf.desktop.sway.enable {
alyraffauf = {
desktop = {
waylandComp = lib.mkDefault true;
};
};
programs.waybar = {
settings = {
mainBar = {

View file

@ -5,10 +5,6 @@
...
}: {
config = lib.mkIf config.alyraffauf.desktop.waylandComp {
home.packages = with pkgs; [
swayosd
networkmanagerapplet
];
alyraffauf = {
apps = {
fuzzel.enable = lib.mkDefault true;
@ -28,5 +24,18 @@
"org/gnome/nm-applet".disable-connected-notifications = true;
};
};
home.packages = with pkgs; [
swayosd
networkmanagerapplet
];
xdg.portal = {
enable = true;
configPackages =
lib.optionals (config.alyraffauf.desktop.hyprland.enable) [pkgs.xdg-desktop-portal-hyprland];
extraPortals =
lib.optionals (config.alyraffauf.desktop.hyprland.enable) [pkgs.xdg-desktop-portal-hyprland];
};
};
}

View file

@ -216,9 +216,12 @@
};
};
};
waylandComp =
lib.mkEnableOption "Shared configuration for wayland compositors.";
waylandComp = lib.mkOption {
description = "Shared defaults for wayland compositors.";
default =
config.alyraffauf.desktop.hyprland.enable || config.alyraffauf.desktop.sway.enable;
type = lib.types.bool;
};
};
scripts = {
pp-adjuster.enable = lib.mkEnableOption "pp-adjuster script.";

View file

@ -37,7 +37,8 @@
};
tailscale.enable = true;
};
system = {
base = {
enable = true;
plymouth.enable = true;
zramSwap = {enable = true;};
};

View file

@ -29,7 +29,8 @@
};
alyraffauf = {
system = {
base = {
enable = true;
plymouth.enable = true;
zramSwap = {enable = true;};
};

View file

@ -82,7 +82,8 @@ in {
scripts = {
hoenn.enable = true;
};
system = {
base = {
enable = true;
plymouth.enable = true;
zramSwap = {
enable = true;

View file

@ -25,7 +25,8 @@
networking.hostName = "petalburg"; # Define your hostname.
alyraffauf = {
system = {
base = {
enable = true;
plymouth.enable = true;
zramSwap = {enable = true;};
};

View file

@ -22,7 +22,8 @@
networking.hostName = "rustboro"; # Define your hostname.
alyraffauf = {
system = {
base = {
enable = true;
plymouth.enable = true;
zramSwap = {
enable = true;

View file

@ -0,0 +1,101 @@
{
config,
inputs,
lib,
pkgs,
...
}: {
imports = [
./networking
./nix
./nixpkgs
./plymouth
./power-profiles-daemon
./sound
./zramSwap
];
config = lib.mkIf config.alyraffauf.base.enable {
console = {
colors = [
"303446"
"e78284"
"a6d189"
"e5c890"
"8caaee"
"f4b8e4"
"81c8be"
"b5bfe2"
"626880"
"303446"
"e78284"
"a6d189"
"e5c890"
"8caaee"
"f4b8e4"
"81c8be"
"a5adce"
];
useXkbConfig = true;
};
environment.systemPackages = [inputs.agenix.packages.${pkgs.system}.default];
i18n = {
defaultLocale = lib.mkDefault "en_US.UTF-8";
extraLocaleSettings = {
LC_ADDRESS = config.i18n.defaultLocale;
LC_IDENTIFICATION = config.i18n.defaultLocale;
LC_MEASUREMENT = config.i18n.defaultLocale;
LC_MONETARY = config.i18n.defaultLocale;
LC_NAME = config.i18n.defaultLocale;
LC_NUMERIC = config.i18n.defaultLocale;
LC_PAPER = config.i18n.defaultLocale;
LC_TELEPHONE = config.i18n.defaultLocale;
LC_TIME = config.i18n.defaultLocale;
};
};
programs.gnupg.agent = {
enable = true;
enableSSHSupport = true;
};
hardware = {
# Add support for logitech unifying receivers.
logitech.wireless = {
enable = true;
enableGraphical = true;
};
keyboard.qmk.enable = true;
};
services = {
logind.extraConfig = ''
# Don't shutdown when power button is short-pressed
HandlePowerKey=suspend
HandlePowerKeyLongPress=poweroff
'';
};
security = {
polkit.enable = true;
rtkit.enable = true;
};
system.autoUpgrade = {
allowReboot = true;
dates = "04:00";
randomizedDelaySec = "20min";
enable = true;
flake = "github:alyraffauf/nixcfg";
operation = "boot";
rebootWindow = {
lower = "02:00";
upper = "05:00";
};
};
time.timeZone = "America/New_York";
};
}

View file

@ -0,0 +1,98 @@
{
config,
inputs,
lib,
pkgs,
...
}: {
config = lib.mkIf config.alyraffauf.base.enable {
age.secrets.wifi.file = ../../../secrets/wifi.age;
hardware = {
bluetooth.enable = true;
};
networking.networkmanager = {
enable = true;
ensureProfiles = {
environmentFiles = [
config.age.secrets.wifi.path
];
profiles = {
Stargate-Discovery = {
connection = {
id = "Stargate-Discovery";
type = "wifi";
};
wifi.ssid = "Stargate-Discovery";
wifi-security = {
auth-alg = "open";
key-mgmt = "wpa-psk";
psk = "$StargateDiscoveryPSK";
};
};
wattson = {
connection = {
id = "wattson";
type = "wifi";
};
wifi.ssid = "wattson";
wifi-security = {
auth-alg = "open";
key-mgmt = "wpa-psk";
psk = "$wattsonPSK";
};
};
"Dustins iPhone" = {
connection = {
id = "Dustins iPhone";
type = "wifi";
};
wifi.ssid = "Dustins iPhone";
wifi-security = {
auth-alg = "open";
key-mgmt = "wpa-psk";
psk = "$DustinsiPhonePSK";
};
};
WeWorkWiFi = {
"802-1x" = {
eap = "peap;";
identity = "$WeWorkWiFiIdentity";
password = "$WeWorkWiFiPassword";
phase2-auth = "mschapv2";
};
connection = {
id = "WeWorkWiFi";
type = "wifi";
};
wifi.ssid = "WeWorkWiFi";
wifi-security.key-mgmt = "wpa-eap";
};
};
};
};
services = {
avahi = {
enable = true;
nssmdns4 = true;
openFirewall = true;
publish = {
enable = true;
addresses = true;
userServices = true;
workstation = true;
};
};
openssh = {
enable = true;
openFirewall = true;
};
printing.enable = true;
};
};
}

View file

@ -0,0 +1,45 @@
{
config,
inputs,
lib,
pkgs,
...
}: {
config = lib.mkIf config.alyraffauf.base.enable {
nix = {
gc = {
automatic = true;
dates = "daily";
options = "--delete-older-than 3d";
persistent = true;
randomizedDelaySec = "60min";
};
# Run GC when there is less than 100MiB left.
extraOptions = ''
min-free = ${toString (100 * 1024 * 1024)}
max-free = ${toString (1024 * 1024 * 1024)}
'';
optimise.automatic = true;
settings = {
auto-optimise-store = false;
experimental-features = ["nix-command" "flakes"];
substituters = [
"https://nixcache.raffauflabs.com"
"https://hyprland.cachix.org"
"https://cache.nixos.org/"
];
trusted-public-keys = [
"nixcache.raffauflabs.com:yFIuJde/izA4aUDI3MZmBLzynEsqVCT1OfCUghOLlt8="
"hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc="
];
trusted-users = ["aly"];
};
};
};
}

View file

@ -0,0 +1,62 @@
{
config,
inputs,
lib,
pkgs,
...
}: {
config = lib.mkIf config.alyraffauf.base.enable {
nixpkgs = let
unstable = import inputs.nixpkgsUnstable {
system = pkgs.system;
config.allowUnfree = true; # Allow unfree packages
};
in {
config.allowUnfree = true; # Allow unfree packages
# Overlays over default packages.
overlays = [
(final: prev: {
audiobookshelf = unstable.audiobookshelf;
brave = prev.brave.override {commandLineArgs = "--gtk-version=4 --enable-wayland-ime";};
catppuccin-gtk = prev.catppuccin-gtk.override {
accents = ["mauve"];
size = "compact";
variant = "frappe";
tweaks = ["normal"];
};
catppuccin-kvantum = prev.catppuccin-kvantum.override {
accent = "Mauve";
variant = "Frappe";
};
catppuccin-papirus-folders = prev.catppuccin-papirus-folders.override {
flavor = "frappe";
accent = "mauve";
};
catppuccin-plymouth = prev.catppuccin-plymouth.override {variant = "frappe";};
nerdfonts = prev.nerdfonts.override {fonts = ["Noto"];};
google-chrome = prev.google-chrome.override {commandLineArgs = "--gtk-version=4 --enable-wayland-ime";};
hyprland = inputs.hyprland.packages.${pkgs.system}.hyprland;
hyprnome = unstable.hyprnome;
hyprshot = unstable.hyprshot;
xdg-desktop-portal-hyprland = inputs.hyprland.packages.${pkgs.system}.xdg-desktop-portal-hyprland;
obsidian = unstable.obsidian.overrideAttrs (old: {
installPhase =
builtins.replaceStrings ["--ozone-platform=wayland"]
["--ozone-platform=wayland --enable-wayland-ime"]
old.installPhase;
});
sway = unstable.sway;
swayfx = unstable.swayfx;
vscodium = prev.vscodium.override {commandLineArgs = "--gtk-version=4 --enable-wayland-ime";};
webcord = prev.webcord.overrideAttrs (old: {
installPhase =
builtins.replaceStrings ["--ozone-platform-hint=auto"]
["--ozone-platform-hint=auto --enable-wayland-ime"]
old.installPhase;
});
})
];
};
};
}

View file

@ -1,10 +1,11 @@
{
pkgs,
lib,
config,
inputs,
lib,
pkgs,
...
}: {
config = lib.mkIf config.alyraffauf.system.plymouth.enable {
config = lib.mkIf config.alyraffauf.base.plymouth.enable {
boot = {
consoleLogLevel = 0;
initrd.verbose = false;

View file

@ -1,10 +1,11 @@
{
pkgs,
lib,
config,
inputs,
lib,
pkgs,
...
}: {
config = lib.mkIf config.alyraffauf.system.power-profiles-daemon.enable {
config = lib.mkIf config.alyraffauf.base.power-profiles-daemon.enable {
services = {
power-profiles-daemon.enable = true;
upower.enable = true;

View file

@ -0,0 +1,27 @@
{
config,
inputs,
lib,
pkgs,
...
}: {
config = lib.mkIf config.alyraffauf.base.enable {
hardware.pulseaudio = {
enable = lib.mkForce false;
package = pkgs.pulseaudioFull;
};
services = {
pipewire = {
enable = true;
alsa = {
enable = true;
support32Bit = true;
};
pulse.enable = true;
};
};
sound.enable = true;
};
}

View file

@ -0,0 +1,13 @@
{
config,
lib,
pkgs,
...
}: {
config = lib.mkIf config.alyraffauf.base.zramSwap.enable {
zramSwap = {
enable = true;
memoryPercent = config.alyraffauf.base.zramSwap.size;
};
};
}

View file

@ -3,63 +3,15 @@ inputs: {
pkgs,
lib,
...
}: let
unstable = import inputs.nixpkgsUnstable {
system = pkgs.system;
config.allowUnfree = true;
};
in {
}: {
imports = [
./apps
./base
./containers
./desktop
./options.nix
./scripts
./services
./system
./users
];
nixpkgs.overlays = [
(final: prev: {
audiobookshelf = unstable.audiobookshelf;
brave = prev.brave.override {commandLineArgs = "--gtk-version=4 --enable-wayland-ime";};
catppuccin-gtk = prev.catppuccin-gtk.override {
accents = ["mauve"];
size = "compact";
variant = "frappe";
tweaks = ["normal"];
};
catppuccin-kvantum = prev.catppuccin-kvantum.override {
accent = "Mauve";
variant = "Frappe";
};
catppuccin-papirus-folders = prev.catppuccin-papirus-folders.override {
flavor = "frappe";
accent = "mauve";
};
catppuccin-plymouth = prev.catppuccin-plymouth.override {variant = "frappe";};
nerdfonts = prev.nerdfonts.override {fonts = ["Noto"];};
google-chrome = prev.google-chrome.override {commandLineArgs = "--gtk-version=4 --enable-wayland-ime";};
hyprland = inputs.hyprland.packages.${pkgs.system}.hyprland;
hyprnome = unstable.hyprnome;
hyprshot = unstable.hyprshot;
xdg-desktop-portal-hyprland = inputs.hyprland.packages.${pkgs.system}.xdg-desktop-portal-hyprland;
obsidian = unstable.obsidian.overrideAttrs (old: {
installPhase =
builtins.replaceStrings ["--ozone-platform=wayland"]
["--ozone-platform=wayland --enable-wayland-ime"]
old.installPhase;
});
sway = unstable.sway;
swayfx = unstable.swayfx;
vscodium = prev.vscodium.override {commandLineArgs = "--gtk-version=4 --enable-wayland-ime";};
webcord = prev.webcord.overrideAttrs (old: {
installPhase =
builtins.replaceStrings ["--ozone-platform-hint=auto"]
["--ozone-platform-hint=auto --enable-wayland-ime"]
old.installPhase;
});
})
];
}

View file

@ -5,8 +5,6 @@
...
}: {
config = lib.mkIf config.alyraffauf.desktop.hyprland.enable {
alyraffauf.desktop.waylandComp.enable = lib.mkDefault true;
programs = {
hyprland = {
enable = true;

View file

@ -6,8 +6,6 @@
...
}: {
config = lib.mkIf config.alyraffauf.desktop.sway.enable {
alyraffauf.desktop.waylandComp.enable = lib.mkDefault true;
programs = {
sway = {
enable = true;

View file

@ -5,7 +5,7 @@
config,
...
}: {
config = lib.mkIf config.alyraffauf.desktop.waylandComp.enable {
config = lib.mkIf config.alyraffauf.desktop.waylandComp {
programs = {
gnupg.agent.pinentryPackage = lib.mkForce pkgs.pinentry-gnome3;
};

View file

@ -18,6 +18,10 @@
virt-manager.enable =
lib.mkEnableOption "Virt-manager with TPM and EFI support.";
};
base.enable =
lib.mkEnableOption "Basic system configuration and sane defaults.";
containers = {
nixos = {
audiobookshelf = {
@ -178,8 +182,13 @@
lib.mkEnableOption "Plasma desktop session.";
sway.enable =
lib.mkEnableOption "Sway wayland session.";
waylandComp.enable =
lib.mkEnableOption "Shared defaults for wayland compositors.";
waylandComp = lib.mkOption {
description = "Shared defaults for wayland compositors.";
default =
config.alyraffauf.desktop.hyprland.enable
|| config.alyraffauf.desktop.sway.enable;
type = lib.types.bool;
};
};
scripts.hoenn.enable =
lib.mkEnableOption "Hoenn system configuration script";
@ -220,11 +229,14 @@
};
tailscale.enable = lib.mkEnableOption "Enable Tailscale";
};
system = {
base = {
plymouth.enable =
lib.mkEnableOption "Plymouth boot screen with catppuccin theme.";
power-profiles-daemon.enable =
lib.mkEnableOption "Power-profiles-daemon.";
power-profiles-daemon.enable = lib.mkOption {
description = "Power Profiles Daemon for power management.";
default = true;
type = lib.types.bool;
};
zramSwap = {
enable = lib.mkEnableOption "Zram swap.";
size = lib.mkOption {

View file

@ -1,160 +0,0 @@
{
config,
inputs,
lib,
pkgs,
...
}: {
imports = [./plymouth ./power-profiles-daemon ./zramSwap ./wifi.nix];
alyraffauf.system.power-profiles-daemon.enable = lib.mkDefault true;
environment.systemPackages = [inputs.agenix.packages.${pkgs.system}.default];
console = {
colors = [
"303446"
"e78284"
"a6d189"
"e5c890"
"8caaee"
"f4b8e4"
"81c8be"
"b5bfe2"
"626880"
"303446"
"e78284"
"a6d189"
"e5c890"
"8caaee"
"f4b8e4"
"81c8be"
"a5adce"
];
useXkbConfig = true;
};
time.timeZone = "America/New_York";
i18n = {
defaultLocale = lib.mkDefault "en_US.UTF-8";
extraLocaleSettings = {
LC_ADDRESS = config.i18n.defaultLocale;
LC_IDENTIFICATION = config.i18n.defaultLocale;
LC_MEASUREMENT = config.i18n.defaultLocale;
LC_MONETARY = config.i18n.defaultLocale;
LC_NAME = config.i18n.defaultLocale;
LC_NUMERIC = config.i18n.defaultLocale;
LC_PAPER = config.i18n.defaultLocale;
LC_TELEPHONE = config.i18n.defaultLocale;
LC_TIME = config.i18n.defaultLocale;
};
};
programs.gnupg.agent = {
enable = true;
enableSSHSupport = true;
};
hardware = {
bluetooth.enable = true;
# Add support for logitech unifying receivers.
logitech.wireless = {
enable = true;
enableGraphical = true;
};
keyboard.qmk.enable = true;
pulseaudio = {
enable = lib.mkForce false;
package = pkgs.pulseaudioFull;
};
};
sound.enable = true;
networking = {
networkmanager.enable = true;
};
services = {
logind.extraConfig = ''
# Don't shutdown when power button is short-pressed
HandlePowerKey=suspend
HandlePowerKeyLongPress=poweroff
'';
pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
};
avahi = {
enable = true;
nssmdns4 = true;
openFirewall = true;
publish = {
enable = true;
addresses = true;
userServices = true;
workstation = true;
};
};
openssh = {
enable = true;
openFirewall = true;
};
printing.enable = true;
};
security = {
polkit.enable = true;
rtkit.enable = true;
};
# Allow unfree packages
nixpkgs.config.allowUnfree = true;
system.autoUpgrade = {
allowReboot = true;
dates = "04:00";
randomizedDelaySec = "20min";
enable = true;
flake = "github:alyraffauf/nixcfg";
operation = "boot";
rebootWindow = {
lower = "02:00";
upper = "05:00";
};
};
nix = {
optimise.automatic = true;
gc = {
automatic = true;
dates = "daily";
options = "--delete-older-than 3d";
persistent = true;
randomizedDelaySec = "60min";
};
# Run GC when there is less than 100MiB left.
extraOptions = ''
min-free = ${toString (100 * 1024 * 1024)}
max-free = ${toString (1024 * 1024 * 1024)}
'';
settings = {
auto-optimise-store = false;
experimental-features = ["nix-command" "flakes"];
substituters = [
"https://nixcache.raffauflabs.com"
"https://hyprland.cachix.org"
"https://cache.nixos.org/"
];
trusted-public-keys = [
"nixcache.raffauflabs.com:yFIuJde/izA4aUDI3MZmBLzynEsqVCT1OfCUghOLlt8="
"hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc="
];
trusted-users = ["aly"];
};
};
}

View file

@ -1,69 +0,0 @@
{
config,
inputs,
lib,
pkgs,
...
}: {
age.secrets.wifi.file = ../../secrets/wifi.age;
networking.networkmanager = {
ensureProfiles = {
environmentFiles = [
config.age.secrets.wifi.path
];
profiles = {
Stargate-Discovery = {
connection = {
id = "Stargate-Discovery";
type = "wifi";
};
wifi.ssid = "Stargate-Discovery";
wifi-security = {
auth-alg = "open";
key-mgmt = "wpa-psk";
psk = "$StargateDiscoveryPSK";
};
};
wattson = {
connection = {
id = "wattson";
type = "wifi";
};
wifi.ssid = "wattson";
wifi-security = {
auth-alg = "open";
key-mgmt = "wpa-psk";
psk = "$wattsonPSK";
};
};
"Dustins iPhone" = {
connection = {
id = "Dustins iPhone";
type = "wifi";
};
wifi.ssid = "Dustins iPhone";
wifi-security = {
auth-alg = "open";
key-mgmt = "wpa-psk";
psk = "$DustinsiPhonePSK";
};
};
WeWorkWiFi = {
"802-1x" = {
eap = "peap;";
identity = "$WeWorkWiFiIdentity";
password = "$WeWorkWiFiPassword";
phase2-auth = "mschapv2";
};
connection = {
id = "WeWorkWiFi";
type = "wifi";
};
wifi.ssid = "WeWorkWiFi";
wifi-security.key-mgmt = "wpa-eap";
};
};
};
};
}

View file

@ -1,13 +0,0 @@
{
pkgs,
lib,
config,
...
}: {
config = lib.mkIf config.alyraffauf.system.zramSwap.enable {
zramSwap = {
enable = true;
memoryPercent = config.alyraffauf.system.zramSwap.size;
};
};
}