diff options
author | azahi <azat@bahawi.net> | 2024-11-10 01:08:38 +0300 |
---|---|---|
committer | azahi <azat@bahawi.net> | 2024-11-10 01:08:38 +0300 |
commit | 693768ee37098dbebb38c86e27044f2faa38348d (patch) | |
tree | 37c92a1c83cf22fa5e5a570baa8598ba6063c795 /modules/common | |
parent | 2024-10-29 (diff) |
2024-11-10
Diffstat (limited to 'modules/common')
-rw-r--r-- | modules/common/ark.nix | 15 | ||||
-rw-r--r-- | modules/common/default.nix | 5 | ||||
-rw-r--r-- | modules/common/documentation.nix | 3 | ||||
-rw-r--r-- | modules/common/home-manager.nix | 5 | ||||
-rw-r--r-- | modules/common/kernel.nix | 27 | ||||
-rw-r--r-- | modules/common/locale.nix | 1 | ||||
-rw-r--r-- | modules/common/networking.nix | 51 | ||||
-rw-r--r-- | modules/common/nix.nix | 2 | ||||
-rw-r--r-- | modules/common/shell/default.nix | 30 | ||||
-rw-r--r-- | modules/common/systemd.nix | 9 | ||||
-rw-r--r-- | modules/common/xdg.nix | 43 |
11 files changed, 100 insertions, 91 deletions
diff --git a/modules/common/ark.nix b/modules/common/ark.nix index 1e43ef8..ba3056b 100644 --- a/modules/common/ark.nix +++ b/modules/common/ark.nix @@ -4,14 +4,13 @@ lib, ... }: -with lib; let cfg = config.nixfiles.modules.ark; in { imports = [ inputs.impermanence.nixosModules.impermanence - (mkAliasOptionModule [ "ark" ] [ + (lib.mkAliasOptionModule [ "ark" ] [ "nixfiles" "modules" "ark" @@ -20,16 +19,16 @@ in options.nixfiles.modules.ark = let - mkListOfAnythingOption = mkOption { - type = with types; listOf anything; # Assumed to be matching with the upstream type. + mkListOfAnythingOption = lib.mkOption { + type = with lib.types; listOf anything; # Assumed to be matching with the upstream type. default = [ ]; }; in { - enable = mkEnableOption "persistent storage support via impermanence"; + enable = lib.mkEnableOption "persistent storage support via impermanence"; - path = mkOption { - type = types.str; + path = lib.mkOption { + type = lib.types.str; default = "/ark"; }; @@ -41,7 +40,7 @@ in # }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { environment.persistence.${cfg.path} = { hideMounts = true; enableDebugging = false; diff --git a/modules/common/default.nix b/modules/common/default.nix index ef9fb18..38094e7 100644 --- a/modules/common/default.nix +++ b/modules/common/default.nix @@ -1 +1,4 @@ -{ lib, ... }: with lib; { imports = attrValues (modulesIn ./.); } +{ lib, ... }: +{ + imports = lib.attrValues (lib.modulesIn ./.); +} diff --git a/modules/common/documentation.nix b/modules/common/documentation.nix index 33e767c..f9e0fcb 100644 --- a/modules/common/documentation.nix +++ b/modules/common/documentation.nix @@ -5,7 +5,6 @@ this, ... }: -with lib; { config = { hm.manual = { @@ -34,7 +33,7 @@ with lib; environment.variables = { MANOPT = "--no-hyphenation"; - MANPAGER = "${getExe pkgs.less} -+F"; + MANPAGER = "${lib.getExe pkgs.less} -+F"; }; }; } diff --git a/modules/common/home-manager.nix b/modules/common/home-manager.nix index f2fc8a8..f3e8143 100644 --- a/modules/common/home-manager.nix +++ b/modules/common/home-manager.nix @@ -4,14 +4,13 @@ lib, ... }: -with lib; { imports = [ inputs.home-manager.nixosModule - (mkAliasOptionModule [ "hm" ] [ + (lib.mkAliasOptionModule [ "hm" ] [ "home-manager" "users" - my.username + lib.my.username ]) ]; diff --git a/modules/common/kernel.nix b/modules/common/kernel.nix index ddc4f62..f7e520a 100644 --- a/modules/common/kernel.nix +++ b/modules/common/kernel.nix @@ -1,29 +1,28 @@ { lib, ... }: -with lib; { boot.kernel.sysctl = { - "fs.file-max" = pow 2 17; - "fs.inotify.max_user_watches" = pow 2 19; + "fs.file-max" = lib.pow 2 17; + "fs.inotify.max_user_watches" = lib.pow 2 19; "fs.suid_dumpable" = 0; "kernel.core_uses_pid" = 1; "kernel.exec-shield" = 1; "kernel.kptr_restrict" = 1; "kernel.maps_protect" = 1; - "kernel.msgmax" = pow 2 16; - "kernel.msgmnb" = pow 2 16; - "kernel.pid_max" = pow 2 16; + "kernel.msgmax" = lib.pow 2 16; + "kernel.msgmnb" = lib.pow 2 16; + "kernel.pid_max" = lib.pow 2 16; "kernel.randomize_va_space" = 2; - "kernel.shmall" = pow 2 28; - "kernel.shmmax" = pow 2 28; + "kernel.shmall" = lib.pow 2 28; + "kernel.shmmax" = lib.pow 2 28; "kernel.sysrq" = 0; - "vm.dirty_background_bytes" = pow 2 22; + "vm.dirty_background_bytes" = lib.pow 2 22; "vm.dirty_background_ratio" = 5; - "vm.dirty_bytes" = pow 2 22; + "vm.dirty_bytes" = lib.pow 2 22; "vm.dirty_ratio" = 30; - "vm.min_free_kbytes" = pow 2 16; - "vm.mmap_min_addr" = pow 2 12; - "vm.overcommit_memory" = mkDefault 0; - "vm.overcommit_ratio" = mkDefault 50; + "vm.min_free_kbytes" = lib.pow 2 16; + "vm.mmap_min_addr" = lib.pow 2 12; + "vm.overcommit_memory" = lib.mkDefault 0; + "vm.overcommit_ratio" = lib.mkDefault 50; "vm.vfs_cache_pressure" = 50; }; diff --git a/modules/common/locale.nix b/modules/common/locale.nix index 372b69b..acd1ecd 100644 --- a/modules/common/locale.nix +++ b/modules/common/locale.nix @@ -51,7 +51,6 @@ with lib; "caps:escape" "compose:menu" "grp:win_space_toggle" - "terminate:ctrl_alt_bksp" ]; }; } diff --git a/modules/common/networking.nix b/modules/common/networking.nix index f681deb..71df24a 100644 --- a/modules/common/networking.nix +++ b/modules/common/networking.nix @@ -5,31 +5,30 @@ this, ... }: -with lib; let cfg = config.nixfiles.modules.common.networking; in { - options.nixfiles.modules.common.networking.onlyDefault = mkEnableOption "custom networking settings"; + options.nixfiles.modules.common.networking.onlyDefault = lib.mkEnableOption "custom networking settings"; - config = mkIf (!cfg.onlyDefault) { + config = lib.mkIf (!cfg.onlyDefault) { ark.directories = with config.networking; - optional networkmanager.enable "/etc/NetworkManager/system-connections" - ++ optional wireless.iwd.enable "/var/lib/iwd"; + lib.optional networkmanager.enable "/etc/NetworkManager/system-connections" + ++ lib.optional wireless.iwd.enable "/var/lib/iwd"; - networking = mkMerge [ + networking = lib.mkMerge [ { - domain = my.domain.shire; + domain = lib.my.domain.shire; hostName = this.hostname; - hostId = substring 0 8 (builtins.hashString "md5" this.hostname); + hostId = lib.substring 0 8 (builtins.hashString "md5" this.hostname); # Remove default hostname mappings. This is required at least by the # current implementation of the monitoring module. hosts = { - "127.0.0.2" = mkForce [ ]; - "::1" = mkForce [ ]; + "127.0.0.2" = lib.mkForce [ ]; + "::1" = lib.mkForce [ ]; }; # There's no way[1] to configure DNS server priority in @@ -41,7 +40,7 @@ in # # [1]: https://askubuntu.com/questions/1116732/how-do-i-list-dns-server-order-in-systemd-resolve # [2]: https://github.com/systemd/systemd/issues/6076 - nameservers = with my.configurations.manwe.wireguard; [ + nameservers = with lib.my.configurations.manwe.wireguard; [ ipv6.address ipv4.address ]; @@ -68,49 +67,53 @@ in let interface = "eth0"; # This assumes `usePredictableInterfaceNames` is false. in - mkIf (hasAttr "ipv4" this && hasAttr "ipv6" this) { + lib.mkIf (lib.hasAttr "ipv4" this && lib.hasAttr "ipv6" this) { usePredictableInterfaceNames = false; # NOTE This can break something! interfaces.${interface} = { ipv4.addresses = with this.ipv4; - optional (isString address && isInt prefixLength) { inherit address prefixLength; }; + lib.optional (lib.isString address && lib.isInt prefixLength) { + inherit address prefixLength; + }; ipv6.addresses = with this.ipv6; - optional (isString address && isInt prefixLength) { inherit address prefixLength; }; + lib.optional (lib.isString address && lib.isInt prefixLength) { + inherit address prefixLength; + }; }; defaultGateway = with this.ipv4; - mkIf (isString gatewayAddress) { + lib.mkIf (lib.isString gatewayAddress) { inherit interface; address = gatewayAddress; }; defaultGateway6 = with this.ipv6; - mkIf (isString gatewayAddress) { + lib.mkIf (lib.isString gatewayAddress) { inherit interface; address = gatewayAddress; }; } ) - (mkIf this.isHeadful { - interfaces.eth0.useDHCP = mkDefault true; + (lib.mkIf this.isHeadful { + interfaces.eth0.useDHCP = lib.mkDefault true; networkmanager = { - enable = mkDefault true; + enable = lib.mkDefault true; unmanaged = [ "bridge" "ethernet" "loopback" "wireguard" ]; - plugins = mkForce [ ]; + plugins = lib.mkForce [ ]; wifi.backend = "iwd"; }; wireless = { enable = false; - iwd.enable = mkDefault true; + iwd.enable = lib.mkDefault true; userControlled.enable = true; allowAuxiliaryImperativeNetworks = true; }; @@ -121,12 +124,12 @@ in llmnr = "false"; dnsovertls = "opportunistic"; dnssec = "allow-downgrade"; - fallbackDns = dns.mkDoT dns.const.quad9.ecs; + fallbackDns = lib.dns.mkDoT lib.dns.const.quad9.ecs; }; environment = { - shellAliases = listToAttrs ( - map ({ name, value }: nameValuePair name "${pkgs.iproute2}/bin/${value}") [ + shellAliases = lib.listToAttrs ( + map ({ name, value }: lib.nameValuePair name "${pkgs.iproute2}/bin/${value}") [ { name = "bridge"; value = "bridge -color=always"; diff --git a/modules/common/nix.nix b/modules/common/nix.nix index 58d572f..6a75e85 100644 --- a/modules/common/nix.nix +++ b/modules/common/nix.nix @@ -95,6 +95,8 @@ in overlays = [ inputs.self.overlays.default ]; }; + programs.nh.enable = this.isHeadful; + environment = { defaultPackages = [ ]; systemPackages = diff --git a/modules/common/shell/default.nix b/modules/common/shell/default.nix index 4ae41d8..cacb411 100644 --- a/modules/common/shell/default.nix +++ b/modules/common/shell/default.nix @@ -5,14 +5,13 @@ this, ... }: -with lib; let cfg = config.nixfiles.modules.common.shell; in { - options.nixfiles.modules.common.shell.aliases = mkOption { + options.nixfiles.modules.common.shell.aliases = lib.mkOption { description = "An attribute set of shell aliases."; - type = with types; attrsOf str; + type = with lib.types; attrsOf str; default = { }; }; @@ -24,8 +23,8 @@ in initExtra = let - aliasCompletions = concatStringsSep "\n" ( - mapAttrsToList (name: _: "complete -F _complete_alias ${name}") cfg.aliases + aliasCompletions = lib.concatStringsSep "\n" ( + lib.mapAttrsToList (name: _: "complete -F _complete_alias ${name}") cfg.aliases ); in '' @@ -45,7 +44,7 @@ in source "${./functions.bash}" - source "${getExe' pkgs.complete-alias "complete_alias"}" + source "${lib.getExe' pkgs.complete-alias "complete_alias"}" ${aliasCompletions} # https://github.com/garabik/grc?tab=readme-ov-file#bash @@ -73,19 +72,18 @@ in ]; shellAliases = - listToAttrs ( + lib.listToAttrs ( map ( { name, value }: - nameValuePair name ( - with pkgs; + lib.nameValuePair name ( let pkg = if this.isHeadful then (pkgs.coreutils.overrideAttrs ( _: super: { patches = (super.patches or [ ]) ++ [ - (fetchpatch { + (pkgs.fetchpatch { url = "https://raw.githubusercontent.com/jarun/advcpmv/1e2b1c6b74fa0974896bf94604279a3f74b37a63/advcpmv-0.9-9.5.patch"; hash = "sha256-LRfb4heZlAUKiXl/hC/HgoqeGMxCt8ruBYZUrbzSH+Y="; }) @@ -93,24 +91,24 @@ in } )) else - coreutils; + pkgs.coreutils; in - "${getExe' pkg "coreutils"} --coreutils-prog=${value}" + "${lib.getExe' pkg "coreutils"} --coreutils-prog=${value}" ) ) ( let mkAlias = { - name ? head command, + name ? lib.head command, command, }: { inherit name; - value = concatStringsSep " " command; + value = lib.concatStringsSep " " command; }; - progressBar = optionalString this.isHeadful "--progress-bar"; + progressBar = lib.optionalString this.isHeadful "--progress-bar"; in [ (mkAlias { @@ -171,7 +169,7 @@ in ] ) ) - // (genAttrs [ + // (lib.genAttrs [ "grep" "egrep" "fgrep" diff --git a/modules/common/systemd.nix b/modules/common/systemd.nix index f832518..996096e 100644 --- a/modules/common/systemd.nix +++ b/modules/common/systemd.nix @@ -1,5 +1,6 @@ { config, + lib, ... }: { @@ -35,8 +36,16 @@ user = { inherit extraConfig; }; + + suppressedSystemUnits = lib.optionals config.nixfiles.modules.ark.enable [ + "systemd-machine-id-commit.service" + ]; }; + boot.initrd.systemd.suppressedUnits = lib.optionals config.nixfiles.modules.ark.enable [ + "systemd-machine-id-commit.service" + ]; + environment.variables = { SYSTEMD_PAGERSECURE = "1"; SYSTEMD_PAGER = "less"; diff --git a/modules/common/xdg.nix b/modules/common/xdg.nix index 0b807b7..df7d624 100644 --- a/modules/common/xdg.nix +++ b/modules/common/xdg.nix @@ -4,7 +4,6 @@ this, ... }: -with lib; let cfg = config.nixfiles.modules.common.xdg; in @@ -20,44 +19,44 @@ in ]; in [ - (mkAliasOptionModule [ + (lib.mkAliasOptionModule [ "dirs" "cache" ] (withBase "cacheHome")) - (mkAliasOptionModule [ + (lib.mkAliasOptionModule [ "dirs" "config" ] (withBase "configHome")) - (mkAliasOptionModule [ + (lib.mkAliasOptionModule [ "dirs" "data" ] (withBase "dataHome")) - (mkAliasOptionModule [ + (lib.mkAliasOptionModule [ "dirs" "state" ] (withBase "stateHome")) - (mkAliasOptionModule [ "userDirs" ] (withBase "userDirs")) + (lib.mkAliasOptionModule [ "userDirs" ] (withBase "userDirs")) ]; options.nixfiles.modules.common.xdg = { - cacheHome = mkOption { - type = types.str; + cacheHome = lib.mkOption { + type = lib.types.str; default = "${config.hm.home.homeDirectory}/.cache"; }; - configHome = mkOption { - type = types.str; + configHome = lib.mkOption { + type = lib.types.str; default = "${config.hm.home.homeDirectory}/.config"; }; - dataHome = mkOption { - type = types.str; + dataHome = lib.mkOption { + type = lib.types.str; default = "${config.hm.home.homeDirectory}/.local/share"; }; - stateHome = mkOption { - type = types.str; + stateHome = lib.mkOption { + type = lib.types.str; default = "${config.hm.home.homeDirectory}/.local/state"; }; - userDirs = mkOption { - type = types.attrs; + userDirs = lib.mkOption { + type = lib.types.attrs; default = let inherit (config.my) home; @@ -76,9 +75,9 @@ in videos = tmp; }; }; - defaultApplications = mkOption { + defaultApplications = lib.mkOption { description = "Default applications."; - type = with types; attrsOf (listOf str); + type = with lib.types; attrsOf (listOf str); default = { }; }; }; @@ -89,7 +88,7 @@ in sounds.enable = this.isHeadful; }; - hm.xdg = mkMerge [ + hm.xdg = lib.mkMerge [ (with cfg; { enable = true; @@ -99,11 +98,11 @@ in inherit stateHome; inherit userDirs; }) - (mkIf this.isHeadful { + (lib.mkIf this.isHeadful { mimeApps = { enable = true; - defaultApplications = mkMerge ( - mapAttrsToList (n: v: genAttrs v (_: [ "${n}.desktop" ])) cfg.defaultApplications + defaultApplications = lib.mkMerge ( + lib.mapAttrsToList (n: v: lib.genAttrs v (_: [ "${n}.desktop" ])) cfg.defaultApplications ); }; }) |