major cleanup in inherits

This commit is contained in:
jacekpoz 2024-07-24 18:47:53 +02:00
parent 41fa5daeaf
commit 17d8c16196
Signed by: poz
SSH key fingerprint: SHA256:JyLeVWE4bF3tDnFeUpUaJsPsNlJyBldDGV/dIKSLyN8
50 changed files with 114 additions and 91 deletions

View file

@ -4,7 +4,7 @@
pkgs,
...
}: let
inherit (lib) getExe';
inherit (lib.meta) getExe';
systemctl = getExe' pkgs.systemd "systemctl";

View file

@ -4,7 +4,7 @@
pkgs,
...
}: let
inherit (lib) getExe';
inherit (lib.meta) getExe';
in {
age.secrets.anki-user-credentials.file = ../../../secrets/anki-user-credentials.age;

View file

@ -5,7 +5,8 @@
pkgs,
...
}: let
inherit (lib) getExe getExe';
inherit (lib.meta) getExe getExe';
inherit (lib.modules) mkForce;
inherit (config.myOptions.other.system) username;
in {
@ -105,7 +106,7 @@ in {
# https://github.com/NixOS/nixpkgs/issues/270809
systemd.services.ModemManager = {
enable = lib.mkForce true;
enable = mkForce true;
path = [ pkgs.libqmi ];
wantedBy = [ "multi-user.target" "network.target" ];
};

View file

@ -7,7 +7,7 @@
}: let
inherit (config.myOptions.other.system) username;
inherit (lib) getExe getExe';
inherit (lib.meta) getExe getExe';
iio-hyprland = getExe inputs.iio-hyprland.packages.${pkgs.system}.default;
wpctl = getExe' pkgs.wireplumber "wpctl";
@ -349,7 +349,7 @@ in {
.modules-right > widget:first-child > #workspaces {
margin-right: 0;
}
#pulseaudio {
margin-top: 3px;
margin-bottom: 3px;
@ -526,7 +526,7 @@ in {
background: @mantle;
color: @green;
}
#custom-rot {
margin-top: 3px;
margin-bottom: 3px;
@ -563,4 +563,3 @@ in {
};
};
}

View file

@ -5,7 +5,7 @@
pkgs,
...
}: let
inherit (lib) getExe;
inherit (lib.meta) getExe;
in {
nixpkgs.config = {
permittedInsecurePackages = [

View file

@ -7,7 +7,7 @@
}: let
inherit (config.myOptions.other.system) username;
inherit (lib) getExe getExe';
inherit (lib.meta) getExe getExe';
wpctl = getExe' pkgs.wireplumber "wpctl";
brightnessctl = getExe pkgs.brightnessctl;
@ -332,7 +332,7 @@ in {
.modules-right > widget:first-child > #workspaces {
margin-right: 0;
}
#pulseaudio {
margin-top: 3px;
margin-bottom: 3px;
@ -524,4 +524,3 @@ in {
};
};
}

View file

@ -9,7 +9,7 @@
inherit (config.myOptions.other.system) username;
inherit (lib) mkEnableOption mkIf;
inherit (lib.modules) mkEnableOption mkIf;
in {
options.myOptions.programs.agenix = {
enable = mkEnableOption "agenix";

View file

@ -7,7 +7,8 @@
cfg = config.myOptions.programs.git;
inherit (config.myOptions.other.system) username;
inherit (lib) getExe mkEnableOption mkIf mkOption;
inherit (lib.meta) getExe;
inherit (lib.modules) mkEnableOption mkIf mkOption;
inherit (lib.types) nullOr str;
delta = getExe pkgs.delta;

View file

@ -7,7 +7,7 @@
}: let
cfg = config.myOptions.programs.nh;
inherit (lib) mkEnableOption mkIf mkOption;
inherit (lib.modules) mkEnableOption mkIf mkOption;
inherit (lib.types) str;
in {
options.myOptions.programs.nh = {

View file

@ -6,7 +6,7 @@
cfg = config.myOptions.programs.starship;
inherit (config.myOptions.other.system) username;
inherit (lib) mkEnableOption mkIf;
inherit (lib.modules) mkEnableOption mkIf;
in {
options.myOptions.programs.starship.enable = mkEnableOption "starship";

View file

@ -6,7 +6,7 @@
cfg = config.myOptions.programs.starship;
inherit (config.myOptions.other.system) username;
inherit (lib) mkEnableOption mkIf;
inherit (lib.modules) mkEnableOption mkIf;
in {
options.myOptions.programs.zoxide.enable = mkEnableOption "zoxide";

View file

@ -7,7 +7,7 @@
cfg = config.myOptions.programs.zsh;
inherit (config.myOptions.other.system) username;
inherit (lib) mkEnableOption mkIf mkOption;
inherit (lib.modules) mkEnableOption mkIf mkOption;
inherit (lib.types) attrs bool;
in {
options.myOptions.programs.zsh = {

View file

@ -8,7 +8,7 @@
cfg = config.myOptions.programs.anyrun;
inherit (config.myOptions.other.system) username;
inherit (lib) mkEnableOption mkIf;
inherit (lib.modules) mkEnableOption mkIf;
in {
options.myOptions.programs.anyrun.enable = mkEnableOption "anyrun";

View file

@ -6,7 +6,7 @@
cfg = config.myOptions.themes.cursor;
inherit (config.myOptions.other.system) username;
inherit (lib) mkEnableOption mkIf mkOption;
inherit (lib.modules) mkEnableOption mkIf mkOption;
inherit (lib.types) int package str;
in {
options.myOptions.themes.cursor = {

View file

@ -8,7 +8,8 @@
cfg = config.myOptions.programs.firefox;
inherit (config.myOptions.other.system) username;
inherit (lib) getExe mkEnableOption mkIf mkOption;
inherit (lib.meta) getExe;
inherit (lib.modules) mkEnableOption mkIf mkOption;
inherit (lib.types) attrsOf listOf str submodule;
inherit (lib.attrsets) mapAttrs mapAttrsToList;

View file

@ -8,7 +8,8 @@
cfg = config.myOptions.programs.foot;
inherit (config.myOptions.other.system) username;
inherit (lib) getExe getExe' mkEnableOption mkIf;
inherit (lib.meta) getExe getExe';
inherit (lib.modules) mkEnableOption mkIf;
notify-send = getExe pkgs.libnotify;
xdg-open = getExe' pkgs.xdg-utils "xdg-open";

View file

@ -7,7 +7,7 @@
inherit (config.myOptions.other.system) username;
hmCfg = config.home-manager.users.${username};
inherit (lib) mkEnableOption mkIf mkOption;
inherit (lib.modules) mkEnableOption mkIf mkOption;
inherit (lib.types) package str submodule;
in {
options.myOptions.themes.gtk = {

View file

@ -7,10 +7,10 @@
cfg = config.myOptions.programs.gtklock;
inherit (config.myOptions.other.system) username;
inherit (lib) mkEnableOption mkIf;
inherit (lib.modules) mkEnableOption mkIf;
in {
options.myOptions.programs.gtklock.enable = mkEnableOption "gtklock";
config = mkIf cfg.enable {
# https://github.com/NixOS/nixpkgs/issues/158025
security.pam.services.gtklock.text = "auth include login";

View file

@ -9,7 +9,8 @@
hmCfg = config.home-manager.users.${username};
inherit (config.myOptions.other.system) username;
inherit (lib) getExe' mkEnableOption mkIf;
inherit (lib.meta) getExe getExe';
inherit (lib.modules) mkEnableOption mkIf;
loginctl = getExe' pkgs.systemd "loginctl";
in {
@ -24,7 +25,7 @@ in {
package = inputs.hypridle.packages.${pkgs.system}.hypridle;
settings = {
general = {
lock_cmd = lib.getExe hmCfg.programs.hyprlock.package;
lock_cmd = getExe hmCfg.programs.hyprlock.package;
before_sleep_cmd = "${loginctl} lock-session";
};
};

View file

@ -9,10 +9,12 @@
inherit (config.myOptions.other.system) username;
hmCfg = config.home-manager.users.${username};
inherit (lib) elem getExe getExe' mkEnableOption mkIf mkOption optionals;
inherit (lib.types) bool listOf nullOr package path str submodule;
inherit (lib.strings) removeSuffix;
inherit (lib.attrsets) mapAttrsToList;
inherit (lib.lists) elem optionals;
inherit (lib.meta) getExe getExe';
inherit (lib.modules) mkEnableOption mkIf mkOption;
inherit (lib.strings) removeSuffix;
inherit (lib.types) bool listOf nullOr package path str submodule;
isAmdGpuPresent = elem "amdgpu" config.boot.initrd.kernelModules;

View file

@ -8,7 +8,7 @@
cfg = config.myOptions.programs.hypr.lock;
inherit (config.myOptions.other.system) username;
inherit (lib) mkEnableOption mkIf mkOption;
inherit (lib.modules) mkEnableOption mkIf mkOption;
inherit (lib.types) attrs;
text_color = "rgba(eae0e4FF)";

View file

@ -7,7 +7,7 @@
cfg = config.myOptions.programs.mpv;
inherit (config.myOptions.other.system) username;
inherit (lib) mkEnableOption mkIf mkOption;
inherit (lib.modules) mkEnableOption mkIf mkOption;
inherit (lib.types) nullOr str;
in {
options.myOptions.programs.mpv = {

View file

@ -7,7 +7,7 @@
cfg = config.myOptions.themes.qt;
inherit (config.myOptions.other.system) username;
inherit (lib) mkEnableOption mkIf mkOption;
inherit (lib.modules) mkEnableOption mkIf mkOption;
inherit (lib.types) package str;
in {
options.myOptions.themes.qt = {

View file

@ -8,10 +8,11 @@
cfg = config.myOptions.programs.quickshell;
inherit (config.myOptions.other.system) username;
inherit (lib) elem mkEnableOption mkIf mkOption;
inherit (lib.types) attrsOf listOf path str;
inherit (lib.attrsets) filterAttrs mapAttrsToList;
inherit (lib.lists) elem;
inherit (lib.modules) mkEnableOption mkIf mkOption;
inherit (lib.strings) concatStrings;
inherit (lib.attrsets) mapAttrsToList;
inherit (lib.types) attrsOf listOf path str;
defaultConfigs = {
powermenu = ./powermenu;
@ -45,7 +46,7 @@ in {
xdg.configFile."quickshell/manifest.conf".text = ''
${concatStrings (mapAttrsToList (name: value: ''
${name} = ${value}
'') ((lib.filterAttrs (name: _: elem name cfg.enabledConfigs) defaultConfigs) // cfg.extraConfigs))}
'') ((filterAttrs (name: _: elem name cfg.enabledConfigs) defaultConfigs) // cfg.extraConfigs))}
'';
};
};

View file

@ -7,7 +7,7 @@
cfg = config.myOptions.programs.schizofox;
inherit (config.myOptions.other.system) username;
inherit (lib) mkEnableOption mkIf;
inherit (lib.modules) mkEnableOption mkIf;
in {
options.myOptions.programs.schizofox = {
enable = mkEnableOption "schizofox";

View file

@ -8,7 +8,7 @@
cfg = config.myOptions.programs.swaylock;
inherit (config.myOptions.other.system) username;
inherit (lib) mkEnableOption mkIf;
inherit (lib.modules) mkEnableOption mkIf;
in {
options.myOptions.programs.swaylock.enable = mkEnableOption "swaylock";

View file

@ -3,11 +3,11 @@
lib,
pkgs,
...
}: let
}: let
cfg = config.myOptions.programs.vesktop;
inherit (config.myOptions.other.system) username;
inherit (lib) mkEnableOption mkIf;
inherit (lib.modules) mkEnableOption mkIf;
inherit (lib.strings) concatStrings;
in {
options.myOptions.programs.vesktop = {
@ -22,7 +22,7 @@ in {
# thanks aleph :3
# https://github.com/AlephNought0/Faery/blob/main/Home/Programs/Vesktop/vesktop.nix#L21
postFixup = concatStrings [
old.postFixup
old.postFixup
''
wrapProgram $out/bin/vesktop \
--add-flags "--ozone-platform=wayland \

View file

@ -7,7 +7,7 @@
cfg = config.myOptions.programs.zathura;
inherit (config.myOptions.other.system) username;
inherit (lib) mkEnableOption mkIf;
inherit (lib.modules) mkEnableOption mkIf;
in {
options.myOptions.programs.zathura.enable = mkEnableOption "zathura";

View file

@ -5,10 +5,10 @@
}: let
cfg = config.myOptions.other.hardware;
inherit (lib) mkIf mkOption;
inherit (lib.attrsets) mapAttrsToList;
inherit (lib.modules) mkIf mkOption;
inherit (lib.types) attrsOf float int submodule;
inherit (lib.types.ints) positive;
inherit (lib.attrsets) mapAttrsToList;
in {
options.myOptions.other.hardware = {
monitors = mkOption {

View file

@ -8,7 +8,7 @@
cfg = config.myOptions.other.home-manager;
inherit (config.myOptions.other.system) username;
inherit (lib) mkEnableOption mkIf;
inherit (lib.modules) mkEnableOption mkIf;
in {
options.myOptions.other.home-manager = {
enable = mkEnableOption "home-manager";

View file

@ -5,7 +5,7 @@
}: let
cfg = config.myOptions.other.system;
inherit (lib) mkOption;
inherit (lib.modules) mkOption;
inherit (lib.types) str;
in {
options.myOptions.other.system = {

View file

@ -3,10 +3,11 @@
lib,
pkgs,
...
}: let
}: let
cfg = config.services.anki-sync-server;
inherit (lib) getExe' mkEnableOption mkIf mkOption;
inherit (lib.meta) getExe';
inherit (lib.modules) mkEnableOption mkIf mkOption;
inherit (lib.types) bool package port str;
in {
options.services.anki-sync-server = {

View file

@ -8,7 +8,8 @@
cfg = config.myOptions.services.dunst;
inherit (config.myOptions.other.system) username;
inherit (lib) getExe getExe' mkEnableOption mkIf;
inherit (lib.meta) getExe getExe';
inherit (lib.modules) mkEnableOption mkIf;
xdg-open = getExe' pkgs.xdg-utils "xdg-open";
in {

View file

@ -7,7 +7,7 @@
cfg = config.myOptions.services.fcitx5;
inherit (config.myOptions.other.system) username;
inherit (lib) mkEnableOption mkIf;
inherit (lib.modules) mkEnableOption mkIf;
in {
# stolen from https://git.outfoxxed.me/outfoxxed/nixnew/src/branch/master/modules/user/modules/fcitx5
options.myOptions.services.fcitx5.enable = mkEnableOption "fcitx5";

View file

@ -8,9 +8,10 @@
cfg = config.myOptions.services.greetd;
inherit (config.myOptions.other.system) username;
inherit (lib) getExe getExe' mkEnableOption mkIf mkOption;
inherit (lib.types) listOf str;
inherit (lib.meta) getExe getExe';
inherit (lib.modules) mkEnableOption mkIf mkOption;
inherit (lib.strings) concatStringsSep;
inherit (lib.types) listOf str;
inherit (inputs.hyprland.packages.${pkgs.system}) hyprland;

View file

@ -6,7 +6,7 @@
cfg = config.myOptions.services.mpd;
inherit (config.myOptions.other.system) username;
inherit (lib) mkEnableOption mkIf mkOption;
inherit (lib.modules) mkEnableOption mkIf mkOption;
inherit (lib.types) str;
in {
options.myOptions.services.mpd = {

View file

@ -5,7 +5,7 @@
}: let
cfg = config.myOptions.services.pipewire;
inherit (lib) mkEnableOption mkIf;
inherit (lib.modules) mkEnableOption mkIf;
in {
options.myOptions.services.pipewire.enable = mkEnableOption "pipewire";

View file

@ -6,7 +6,8 @@
}: let
cfg = config.myOptions.services.ssh;
inherit (lib) getExe' mkEnableOption mkIf mkMerge mkOption;
inherit (lib.meta) getExe';
inherit (lib.modules) mkEnableOption mkIf mkMerge mkOption;
inherit (lib.types) attrsOf bool nullOr number str submodule;
inherit (lib.strings) concatStrings;
inherit (lib.attrsets) mapAttrsToList;

View file

@ -8,7 +8,7 @@
hmCfg = config.home-manager.users.${username};
configDir = config.home-manager.users.${username}.xdg.configHome;
inherit (lib) mkEnableOption mkIf mkOption;
inherit (lib.modules) mkEnableOption mkIf mkOption;
inherit (lib.types) attrs;
in {
options.myOptions.services.syncthing = {

View file

@ -6,7 +6,7 @@
cfg = config.myOptions.programs.btop;
inherit (config.myOptions.other.system) username;
inherit (lib) mkEnableOption mkIf;
inherit (lib.modules) mkEnableOption mkIf;
in {
options.myOptions.programs.btop.enable = mkEnableOption "btop";

View file

@ -8,7 +8,9 @@
cfg = config.myOptions.programs.helix;
inherit (config.myOptions.other.system) username;
inherit (lib) getExe getExe' mkEnableOption mkIf;
inherit (lib.meta) getExe getExe';
inherit (lib.modules) mkEnableOption mkIf;
inherit (lib.strings) makeBinPath;
clangd = getExe' pkgs.clang-tools "clangd";
css-languageserver = getExe pkgs.vscode-langservers-extracted;
@ -27,7 +29,7 @@ in {
"--suffix"
"PATH"
":"
(lib.makeBinPath [
(makeBinPath [
rustfmt
rust-analyzer
nil
@ -69,8 +71,8 @@ in {
languages = {
language-server = {
nil = {
command = lib.getExe pkgs.nil;
config.nil.formatting.command = [ "${lib.getExe pkgs.alejandra}" "-q" ];
command = getExe pkgs.nil;
config.nil.formatting.command = [ "${getExe pkgs.alejandra}" "-q" ];
};
clangd = {
command = clangd;

View file

@ -8,7 +8,7 @@
cfg = config.myOptions.programs.neovim;
inherit (config.myOptions.other.system) username;
inherit (lib) mkEnableOption mkIf;
inherit (lib.modules) mkEnableOption mkIf;
in {
options.myOptions.programs.neovim.enable = mkEnableOption "neovim";

View file

@ -6,7 +6,7 @@
cfg = config.myOptions.programs.newsboat;
inherit (config.myOptions.other.system) username;
inherit (lib) mkEnableOption mkIf;
inherit (lib.modules) mkEnableOption mkIf;
in {
options.myOptions.programs.newsboat.enable = mkEnableOption "newsboat";

View file

@ -3,7 +3,7 @@
pkgs,
...
}: let
inherit (lib) getExe;
inherit (lib.meta) getExe;
in {
environment.binsh = getExe pkgs.dash;
}

View file

@ -5,7 +5,7 @@
}: let
inherit (config.myOptions.other.system) username;
inherit (lib) mkForce;
inherit (lib.modules) mkForce;
in {
networking = {
networkmanager = {
@ -27,8 +27,8 @@ in {
# don't wait for network to boot faster
# https://old.reddit.com/r/NixOS/comments/vdz86j/how_to_remove_boot_dependency_on_network_for_a
systemd = {
targets.network-online.wantedBy = lib.mkForce []; # default is [ "multi-user.target" ]
services.NetworkManager-wait-online.wantedBy = lib.mkForce []; # default is [ "network-online.target" ]
targets.network-online.wantedBy = mkForce []; # default is [ "multi-user.target" ]
services.NetworkManager-wait-online.wantedBy = mkForce []; # default is [ "network-online.target" ]
};
users.users.${username} = {

View file

@ -2,6 +2,8 @@
inputs,
lib,
...
}: {
nix.registry = lib.mapAttrs (_: v: { flake = v; }) inputs;
}: let
inherit (lib.attrsets) mapAttrs;
in {
nix.registry = mapAttrs (_: v: { flake = v; }) inputs;
}

View file

@ -1,10 +1,12 @@
{
config,
...
}: {
}: let
inherit (config.myOptions.other.system) username;
in {
programs.adb.enable = true;
users.users.${config.myOptions.other.system.username} = {
users.users.${username} = {
extraGroups = [ "adbusers" ];
};
}

View file

@ -3,7 +3,11 @@
lib,
pkgs,
...
}: {
}: let
inherit (config.myOptions.other.system) username;
inherit (lib.meta) getExe;
in {
environment.systemPackages = with pkgs; [
gns3-gui
gns3-server
@ -13,7 +17,7 @@
vpcs
];
users.users.${config.myOptions.other.system.username} = {
users.users.${username} = {
extraGroups = [ "ubridge" ];
};
@ -25,7 +29,7 @@
users.groups.ubridge = {};
security.wrappers.ubridge = {
source = lib.getExe pkgs.ubridge;
source = getExe pkgs.ubridge;
capabilities = "cap_net_admin,cap_net_raw=ep";
owner = "root";
group = "ubridge";

View file

@ -4,15 +4,17 @@
lib,
pkgs,
...
}: {
services.udev.extraRules = let
inherit (lib) getExe getExe';
asusctl = getExe' config.services.asusd.package "asusctl";
supergfxctl = getExe' config.services.asusd.package "supergfxctl";
cpupower = getExe config.boot.kernelPackages.cpupower;
inherit (inputs.hyprland.packages.${pkgs.system}) hyprland;
hyprctl = getExe' hyprland "hyprctl";
}: let
inherit (lib.meta) getExe getExe';
asusctl = getExe' config.services.asusd.package "asusctl";
supergfxctl = getExe' config.services.asusd.package "supergfxctl";
cpupower = getExe config.boot.kernelPackages.cpupower;
inherit (inputs.hyprland.packages.${pkgs.system}) hyprland;
hyprctl = getExe' hyprland "hyprctl";
in {
services.udev.extraRules = let
power_supply = pkgs.writeShellScript "on_power_supply" ''
${asusctl} profile -P Performance
#${supergfxctl} -m Hybrid

View file

@ -3,15 +3,16 @@
lib,
pkgs,
...
}: {
powerManagement = let
inherit (lib) getExe getExe';
mpc = getExe pkgs.mpc-cli;
sleep = getExe' pkgs.coreutils-full "sleep";
}: let
inherit (lib.meta) getExe getExe';
inherit (inputs.hyprland.packages.${pkgs.system}) hyprland;
hyprctl = getExe' hyprland "hyprctl";
in {
mpc = getExe pkgs.mpc-cli;
sleep = getExe' pkgs.coreutils-full "sleep";
inherit (inputs.hyprland.packages.${pkgs.system}) hyprland;
hyprctl = getExe' hyprland "hyprctl";
in {
powerManagement = {
enable = true;
powerDownCommands = ''
${mpc} pause