Add lib.mkDefault for non configurable defaults (#15)

This commit is contained in:
Dashie 2025-05-09 23:27:37 +02:00 committed by GitHub
parent 207b5165a3
commit ccc6962897
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 82 additions and 70 deletions

View file

@ -1,4 +1,5 @@
{ {
mkDashDefault,
pkgs, pkgs,
config, config,
lib, lib,
@ -10,19 +11,18 @@
in { in {
imports = [ imports = [
(modulesPath + "/installer/scan/not-detected.nix") (modulesPath + "/installer/scan/not-detected.nix")
#(modulesPath + "/misc/nixpkgs/read-only.nix")
]; ];
wsl.enable = config.conf.wsl; wsl.enable = mkDashDefault config.conf.wsl;
# Bootloader. # Bootloader.
boot = lib.mkIf (!config.conf.wsl) { boot = lib.mkIf (!config.conf.wsl) {
consoleLogLevel = 0; consoleLogLevel = mkDashDefault 0;
lanzaboote = lib.mkIf config.conf.secureBoot { lanzaboote = lib.mkIf config.conf.secureBoot {
enable = true; enable = mkDashDefault true;
pkiBundle = "/var/lib/sbctl"; pkiBundle = mkDashDefault "/var/lib/sbctl";
settings.reboot-for-bitlocker = true; settings.reboot-for-bitlocker = mkDashDefault true;
}; };
loader = { loader = {
@ -32,15 +32,15 @@ in {
then lib.mkForce false then lib.mkForce false
else if config.conf.useSystemdBootloader else if config.conf.useSystemdBootloader
then true then true
else false; else mkDashDefault false;
configurationLimit = 5; configurationLimit = 5;
}; };
efi.canTouchEfiVariables = true; efi.canTouchEfiVariables = mkDashDefault true;
}; };
kernelPackages = lib.mkDefault pkgs.linuxPackages_latest; kernelPackages = mkDashDefault pkgs.linuxPackages_latest;
initrd = { initrd = {
verbose = false; verbose = mkDashDefault false;
availableKernelModules = [ availableKernelModules = [
"nvme" "nvme"
"xhci_pci" "xhci_pci"
@ -60,46 +60,46 @@ in {
}; };
networking = { networking = {
useDHCP = lib.mkDefault true; useDHCP = mkDashDefault true;
networkmanager.enable = true; networkmanager.enable = mkDashDefault true;
hostName = hostName; hostName = mkDashDefault hostName;
}; };
time = { time = {
timeZone = config.conf.timezone; timeZone = mkDashDefault config.conf.timezone;
hardwareClockInLocalTime = config.conf.systemLocalTime; hardwareClockInLocalTime = mkDashDefault config.conf.systemLocalTime;
}; };
i18n.defaultLocale = config.conf.locale; i18n.defaultLocale = mkDashDefault config.conf.locale;
services = { services = {
lorri.enable = true; lorri.enable = mkDashDefault true;
xserver.enable = true; xserver.enable = mkDashDefault true;
fstrim.enable = lib.mkDefault true; fstrim.enable = mkDashDefault true;
pulseaudio.enable = false; pulseaudio.enable = mkDashDefault false;
pipewire = { pipewire = {
enable = true; enable = mkDashDefault true;
alsa = { alsa = {
enable = true; enable = mkDashDefault true;
support32Bit = true; support32Bit = mkDashDefault true;
}; };
jack.enable = true; jack.enable = mkDashDefault true;
pulse.enable = true; pulse.enable = mkDashDefault true;
}; };
}; };
nixpkgs.hostPlatform = lib.mkDefault config.conf.system; nixpkgs.hostPlatform = mkDashDefault config.conf.system;
nix = { nix = {
gc = { gc = {
automatic = true; automatic = mkDashDefault true;
dates = "weekly"; dates = mkDashDefault "weekly";
options = "--delete-older-than 7d --delete-generations +5"; options = mkDashDefault "--delete-older-than 7d --delete-generations +5";
}; };
settings = { settings = {
trusted-users = [username]; trusted-users = [username];
auto-optimise-store = true; auto-optimise-store = mkDashDefault true;
builders-use-substitutes = true; builders-use-substitutes = mkDashDefault true;
substituters = [ substituters = [
"https://hyprland.cachix.org" "https://hyprland.cachix.org"
@ -129,29 +129,30 @@ in {
"chaotic-nyx.cachix.org-1:HfnXSw4pj95iI/n17rIDy40agHj12WfF+Gqk6SonIT8=" "chaotic-nyx.cachix.org-1:HfnXSw4pj95iI/n17rIDy40agHj12WfF+Gqk6SonIT8="
]; ];
experimental-features = "nix-command flakes pipe-operators"; experimental-features = mkDashDefault "nix-command flakes pipe-operators";
}; };
}; };
hardware = { hardware = {
cpu.${config.conf.cpu}.updateMicrocode = cpu.${config.conf.cpu}.updateMicrocode =
lib.mkDefault config.hardware.enableRedistributableFirmware; mkDashDefault
config.hardware.enableRedistributableFirmware;
}; };
security.rtkit.enable = true; security.rtkit.enable = mkDashDefault true;
environment.variables = { environment.variables = {
XDG_CACHE_HOME = "$HOME/.cache"; XDG_CACHE_HOME = mkDashDefault "$HOME/.cache";
DIRENV_LOG_FORMAT = ""; DIRENV_LOG_FORMAT = mkDashDefault "";
QT_QPA_PLATFORMTHEME = "qt5ct"; QT_QPA_PLATFORMTHEME = mkDashDefault "qt5ct";
}; };
# allows user change later on # allows user change later on
users = { users = {
mutableUsers = true; mutableUsers = mkDashDefault true;
users.${username} = { users.${username} = {
isNormalUser = true; isNormalUser = mkDashDefault true;
description = username; description = mkDashDefault username;
extraGroups = [ extraGroups = [
"networkmanager" "networkmanager"
"wheel" "wheel"
@ -167,7 +168,7 @@ in {
]; ];
# this password will only last for the first login # this password will only last for the first login
# e.g. login, then change to whatever else, this also ensures no public hash is available # e.g. login, then change to whatever else, this also ensures no public hash is available
password = "firstlogin"; password = mkDashDefault "firstlogin";
}; };
}; };
} }

View file

@ -1,22 +1,23 @@
{ {
mkDashDefault,
pkgs, pkgs,
config, config,
... ...
}: { }: {
environment = { environment = {
variables = { variables = {
GSETTINGS_SCHEMA_DIR = "${pkgs.glib.getSchemaPath pkgs.gsettings-desktop-schemas}"; GSETTINGS_SCHEMA_DIR = mkDashDefault "${pkgs.glib.getSchemaPath pkgs.gsettings-desktop-schemas}";
NEOVIDE_MAXIMIZED = "0"; NEOVIDE_MAXIMIZED = mkDashDefault "0";
GPG_TTY = "$(tty)"; GPG_TTY = mkDashDefault "$(tty)";
EDITOR = "neovide --no-fork"; EDITOR = mkDashDefault "neovide --no-fork";
SUDO_EDITOR = "neovide --no-fork"; SUDO_EDITOR = mkDashDefault "neovide --no-fork";
SCRIPTS = "$HOME/.config/scripts"; SCRIPTS = mkDashDefault "$HOME/.config/scripts";
}; };
sessionVariables = { sessionVariables = {
NIXOS_OZONE_WL = "1"; NIXOS_OZONE_WL = mkDashDefault "1";
GOPATH = "$HOME/.go"; GOPATH = mkDashDefault "$HOME/.go";
FLAKE = config.conf.nixosConfigPath; FLAKE = mkDashDefault config.conf.nixosConfigPath;
NH_FLAKE = config.conf.nixosConfigPath; NH_FLAKE = mkDashDefault config.conf.nixosConfigPath;
}; };
}; };
} }

View file

@ -1,4 +1,8 @@
{pkgs, ...}: let {
mkDashDefault,
pkgs,
...
}: let
layout = pkgs.writeText "dashie" '' layout = pkgs.writeText "dashie" ''
xkb_symbols "dashie" xkb_symbols "dashie"
{ {
@ -10,7 +14,7 @@
}; };
''; '';
in { in {
environment.systemPackages = [pkgs.xorg.xkbcomp]; environment.systemPackages = mkDashDefault [pkgs.xorg.xkbcomp];
services.xserver.xkb.extraLayouts.dashie = { services.xserver.xkb.extraLayouts.dashie = {
description = "US layout with 'umlaut'"; description = "US layout with 'umlaut'";
languages = ["eng"]; languages = ["eng"];

View file

@ -1,4 +1,5 @@
{ {
mkDashDefault,
config, config,
lib, lib,
... ...
@ -6,30 +7,30 @@
username = config.conf.username; username = config.conf.username;
in { in {
manual = { manual = {
html.enable = false; html.enable = mkDashDefault false;
json.enable = false; json.enable = mkDashDefault false;
manpages.enable = false; manpages.enable = mkDashDefault false;
}; };
fonts.fontconfig.enable = true; fonts.fontconfig.enable = mkDashDefault true;
home = { home = {
username = username; username = mkDashDefault username;
homeDirectory = "/home/${username}"; homeDirectory = mkDashDefault "/home/${username}";
sessionPath = ["$HOME/.cargo/bin"]; sessionPath = ["$HOME/.cargo/bin"];
enableNixpkgsReleaseCheck = false; enableNixpkgsReleaseCheck = mkDashDefault false;
sessionVariables = { sessionVariables = {
GOROOT = "$HOME/.go"; GOROOT = mkDashDefault "$HOME/.go";
QT_QPA_PLATFORMTHEME = "qt5ct"; QT_QPA_PLATFORMTHEME = mkDashDefault "qt5ct";
}; };
keyboard = null; keyboard = mkDashDefault null;
}; };
programs.nix-index = { programs.nix-index = {
enable = true; enable = mkDashDefault true;
enableFishIntegration = true; enableFishIntegration = mkDashDefault true;
}; };
nix = { nix = {

View file

@ -1,4 +1,5 @@
{ {
mkDashDefault,
additionalHomeConfig, additionalHomeConfig,
additionalHomeMods, additionalHomeMods,
additionalInputs, additionalInputs,
@ -16,17 +17,18 @@
... ...
}: { }: {
xdg = { xdg = {
portal.config.common.default = "*"; portal.config.common.default = mkDashDefault "*";
portal = { portal = {
enable = true; enable = mkDashDefault true;
extraPortals = [pkgs.xdg-desktop-portal-gtk]; extraPortals = [pkgs.xdg-desktop-portal-gtk];
}; };
}; };
home-manager = { home-manager = {
useGlobalPkgs = true; useGlobalPkgs = mkDashDefault true;
useUserPackages = true; useUserPackages = mkDashDefault true;
extraSpecialArgs = { extraSpecialArgs = {
inherit inputs root additionalInputs alternativePkgs system stable unstable; inherit inputs root additionalInputs alternativePkgs system stable unstable;
mkDashDefault = import ../lib/override.nix {inherit lib;};
}; };
users.${config.conf.username} = { users.${config.conf.username} = {

View file

@ -105,6 +105,7 @@
homeMods = mods.home; homeMods = mods.home;
additionalHomeMods = additionalMods.home; additionalHomeMods = additionalMods.home;
additionalInputs = additionalInputs; additionalInputs = additionalInputs;
mkDashDefault = import ./override.nix {inherit lib;};
}; };
in in
inputs.unstable.lib.nixosSystem { inputs.unstable.lib.nixosSystem {

1
lib/override.nix Normal file
View file

@ -0,0 +1 @@
{lib, ...}: value: lib.mkOverride 999 value

View file

@ -1,4 +1,5 @@
{ {
mkDashDefault,
lib, lib,
config, config,
options, options,
@ -100,7 +101,7 @@
]; ];
in { in {
enable = true; enable = true;
enable32Bit = lib.mkDefault true; enable32Bit = mkDashDefault true;
extraPackages = extraPackages =
amdPackages amdPackages
++ (lib.lists.optionals (config.mods.gpu.vapi.rocm.enable && config.mods.gpu.amdgpu.enable) rocmPackages); ++ (lib.lists.optionals (config.mods.gpu.vapi.rocm.enable && config.mods.gpu.amdgpu.enable) rocmPackages);