flake: inherit explicitly from parts of lib

Instead of doing `inherit (lib) <something>``, all inherits now use
`inherit (lib.<subsystem>) <something>`, which is much nicer.
This commit is contained in:
Bloxx12 2025-04-09 15:31:18 +02:00
commit 53aaa26fa1
29 changed files with 67 additions and 45 deletions

View file

@ -1,11 +1,12 @@
inputs: let
inherit (inputs) self;
inherit (inputs.nixpkgs) lib;
inherit (lib.lists) concatLists flatten singleton;
inherit (lib) nixosSystem recursiveUpdate;
inherit (builtins) filter map toString;
inherit (inputs.nixpkgs) lib;
inherit (lib.attrsets) recursiveUpdate;
inherit (lib.filesystem) listFilesRecursive;
inherit (lib.lists) concatLists flatten singleton;
inherit (lib.strings) hasSuffix;
inherit (lib) nixosSystem;
# NOTE: This was inspired by raf, and I find this
# to be quite a sane way of managing all modules in my flake.

View file

@ -1,5 +1,5 @@
{lib, ...}: let
inherit (lib) mkOption;
inherit (lib.options) mkOption;
inherit (lib.types) submodule int ints number attrsOf ;
in {
options.modules.system.hardware.monitors = mkOption {

View file

@ -1,5 +1,5 @@
{lib, ...}: let
inherit (lib) mkEnableOption mkOption types;
inherit (lib.options) mkEnableOption;
in {
options.modules.system.networking = {
nftbles.enable = mkEnableOption "Nftables firewall";

View file

@ -1,5 +1,6 @@
{lib, ...}: let
inherit (lib) mkEnableOption mkOption types;
inherit (lib.types) str enum;
inherit (lib.options) mkEnableOption mkOption;
in {
options.modules.system.programs = {
editors = {
@ -19,30 +20,30 @@ in {
git = {
signingKey = mkOption {
type = types.str;
type = str;
default = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILPiRe9OH/VtWFWyy5QbAVcN7CLxr4zUtRCwmxD6aeN6";
description = "The default gpg key used for signing commits";
};
};
default = {
terminal = mkOption {
type = types.enum ["foot" "kitty"];
type = enum ["foot" "kitty"];
default = "foot";
};
fileManager = mkOption {
type = types.enum ["thunar" "dolphin" "nemo"];
type = enum ["thunar" "dolphin" "nemo"];
default = "thunar";
};
browser = mkOption {
type = types.enum ["firefox" "librewolf" "chromium"];
type = enum ["firefox" "librewolf" "chromium"];
default = "firefox";
};
editor = mkOption {
type = types.enum ["neovim" "helix" "emacs"];
type = enum ["neovim" "helix" "emacs"];
default = "emacs";
};
launcher = mkOption {
type = types.enum ["anyrun" "rofi" "wofi"];
type = enum ["anyrun" "rofi" "wofi"];
default = "anyrun";
};
};

View file

@ -1,10 +1,11 @@
{lib, ...}: let
inherit (lib) mkOption types;
inherit (lib.options) mkOption;
inherit (lib.types) str;
in {
options.modules.other.system = {
username = mkOption {
description = "username for this system";
type = types.str;
type = str;
};
};
}

View file

@ -5,7 +5,8 @@
}: let
cfg = config.modules.programs.nh;
inherit (config.modules.other.system) username;
inherit (lib) mkEnableOption mkIf;
inherit (lib.modules) mkIf;
inherit (lib.options) mkEnableOption;
in {
options.modules.programs.nh.enable = mkEnableOption "nh";

View file

@ -4,11 +4,11 @@
pkgs,
...
}: let
inherit (lib.modules) mkIf;
inherit (config.meta.mainUser) username;
cfg = config.modules.system.programs.terminals.foot;
colours = config.modules.style.colorScheme.colors;
inherit (config.meta.mainUser) username;
inherit (lib) mkIf;
foot-config = pkgs.writeText "foot.ini" (lib.generators.toINI {} {
main = {

View file

@ -4,9 +4,10 @@
pkgs,
...
}: let
cfg = config.modules.programs.minecraft;
inherit (lib.options) mkEnableOption;
inherit (lib.modules) mkIf;
cfg = config.modules.programs.minecraft;
in {
options.modules.programs.minecraft = {
enable = mkEnableOption "minecraft";

View file

@ -4,7 +4,9 @@
pkgs,
...
}: let
inherit (lib) mkEnableOption mkIf;
inherit (lib.options) mkEnableOption;
inherit (lib.modules) mkIf;
cfg = config.modules.programs.btop;
btop-settings = pkgs.writeTextDir "btop/btop.conf" ''

View file

@ -3,9 +3,10 @@
lib,
...
}: let
cfg = config.modules.services.kanata;
inherit (lib.modules) mkIf;
inherit (lib.options) mkEnableOption;
cfg = config.modules.services.kanata;
in {
options.modules.services.kanata.enable = mkEnableOption "kanata";
config = mkIf cfg.enable {

View file

@ -6,6 +6,7 @@
}: let
inherit (lib.meta) getExe';
inherit (lib.modules) mkIf;
cfg = config.modules.system.services.nextcloud;
in {
options.modules.system.services.nextcloud.enable = lib.mkEnableOption "nextcloud";

View file

@ -6,6 +6,7 @@
}: let
inherit (lib.modules) mkIf;
inherit (lib.options) mkEnableOption;
cfg = config.modules.system.services.database.postgresql;
in {
options.modules.system.services.database.postgresql.enable = mkEnableOption "postgresql";

View file

@ -1,5 +1,5 @@
{lib, ...}: let
inherit (lib) mkEnableOption;
inherit (lib.options) mkEnableOption;
in {
options.modules.programs.ssh.enable = mkEnableOption "ssh";
config = {

View file

@ -11,9 +11,8 @@
...
}: let
inherit (lib.options) mkOption literalExpression;
inherit (lib.types) str nullOr enum mkOptionType attrsOf coercedTo;
inherit (lib.strings) toLower replaceStrings removePrefix hasPrefix isString;
# inherit (lib) serializeTheme;
inherit (lib.types) str nullOr enum mkOptionType attrsOf coercedTo;
cfg = config.modules.style;

View file

@ -4,9 +4,10 @@
pkgs,
...
}: let
inherit (lib.modules) mkIf;
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) str package;
inherit (lib.modules) mkIf;
cfg = config.modules.theming.gtk;
in {
options.modules.theming.gtk = {

View file

@ -5,8 +5,9 @@
...
}: let
inherit (lib.modules) mkIf;
inherit (lib) mkEnableOption mkOption;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) str package;
cfg = config.modules.theming.qt;
in {
options.modules.theming.qt = {

View file

@ -4,13 +4,16 @@
pkgs,
...
}: let
inherit (builtins) toString isBool;
inherit (lib.generators) toINI;
inherit (lib.modules) mkMerge mkIf;
inherit (lib.options) mkEnableOption;
cfg = config.modules.theming;
inherit (builtins) toString isBool;
inherit (lib) boolToString escape generators;
inherit (lib.strings) escape;
inherit (lib.trivial) boolToString;
toGtk3Ini = generators.toINI {
cfg = config.modules.theming;
toGtk3Ini = toINI {
mkKeyValue = key: value: let
value' =
if isBool value

View file

@ -5,8 +5,8 @@
...
}: let
inherit (lib.modules) mkForce;
inherit (lib.modules) mkIf;
inherit (lib.options) mkEnableOption;
cfg = config.modules.system.boot;
in {
options.modules.system.boot = {

View file

@ -4,8 +4,9 @@
pkgs,
...
}: let
inherit (lib.modules) mkIf;
cfg = config.modules.system.hardware.bluetooth;
inherit (lib) mkIf;
in {
config = mkIf cfg.enable {
hardware.bluetooth = {

View file

@ -4,8 +4,7 @@
pkgs,
...
}: let
inherit (lib) mkDefault mkIf;
inherit (config.modules.system.video) nvidia amd;
inherit (lib.modules) mkDefault;
in {
hardware = {
cpu.intel.updateMicrocode = mkDefault config.hardware.enableRedistributableFirmware;

View file

@ -3,8 +3,9 @@
lib,
...
}: let
inherit (lib.modules) mkIf;
cfg = config.modules.system.sound;
inherit (lib) mkIf;
in {
config = mkIf cfg.enable {
services.pipewire = {

View file

@ -6,7 +6,8 @@
pkgs,
...
}: let
inherit (lib) mapAttrsToList mkForce;
inherit (lib.attrsets) mapAttrsToList;
inherit (lib.modules) mkForce;
in {
imports = [
./documentation.nix # nixos documentation

View file

@ -4,7 +4,7 @@
lib,
...
}: let
inherit (lib) mkIf mkForce;
inherit (lib.modules) mkIf mkForce;
inherit (builtins) map;
cfg = config.modules.system.impermanence;

View file

@ -1,5 +1,5 @@
{lib, ...}: let
inherit (lib) mkForce;
inherit (lib.modules) mkForce;
in {
networking.networkmanager = {
enable = true;

View file

@ -3,7 +3,7 @@
pkgs,
...
}: let
inherit (lib) mkForce mkDefault;
inherit (lib.modules) mkForce mkDefault;
in {
security = {
sudo-rs.enable = mkForce false;

View file

@ -3,10 +3,11 @@
lib,
...
}: let
inherit (config.modules.system.hardware) monitors;
inherit (lib) mapAttrsToList;
inherit (builtins) toString;
inherit (lib.attrsets) mapAttrsToList;
inherit (config.modules.style.colorScheme) colors;
inherit (config.modules.system.hardware) monitors;
in {
config = {
programs.hyprland = {

View file

@ -3,9 +3,11 @@
lib,
...
}: let
inherit (config.modules.system.hardware) monitors;
inherit (lib) imap0 flatten optionalString;
inherit (builtins) map genList attrNames toString;
inherit (lib.lists) imap0 flatten;
inherit (lib.strings) optionalString;
inherit (config.modules.system.hardware) monitors;
in {
programs.hyprland.settings = {
# INFO: This is a custom function to map all of my monitors to workspaces.

View file

@ -3,8 +3,10 @@
lib,
...
}: let
inherit (lib.modules) mkIf;
inherit (lib.options) mkEnableOption;
cfg = config.modules.wms.wayland;
inherit (lib) mkIf mkEnableOption;
in {
options.modules.wms.wayland.enable = mkEnableOption "wayland";
config = mkIf cfg.enable {

View file

@ -32,7 +32,8 @@
basedpyright,
...
}: let
inherit (lib) getExe;
inherit (lib.meta) getExe;
toml = formats.toml {};
helix-config = {
theme = "gruvbox";