diff options
Diffstat (limited to 'modules/nixos/common')
-rw-r--r-- | modules/nixos/common/ark.nix | 50 | ||||
-rw-r--r-- | modules/nixos/common/console.nix | 5 | ||||
-rw-r--r-- | modules/nixos/common/documentation.nix | 14 | ||||
-rw-r--r-- | modules/nixos/common/home-manager.nix | 5 | ||||
-rw-r--r-- | modules/nixos/common/kernel.nix | 7 | ||||
-rw-r--r-- | modules/nixos/common/locale.nix | 7 | ||||
-rw-r--r-- | modules/nixos/common/networking.nix | 59 | ||||
-rw-r--r-- | modules/nixos/common/nix.nix | 13 | ||||
-rw-r--r-- | modules/nixos/common/secrets.nix | 5 | ||||
-rw-r--r-- | modules/nixos/common/shell.nix | 4 | ||||
-rw-r--r-- | modules/nixos/common/stylix.nix | 5 | ||||
-rw-r--r-- | modules/nixos/common/systemd.nix | 33 | ||||
-rw-r--r-- | modules/nixos/common/users.nix | 14 | ||||
-rw-r--r-- | modules/nixos/common/xdg.nix | 20 |
14 files changed, 124 insertions, 117 deletions
diff --git a/modules/nixos/common/ark.nix b/modules/nixos/common/ark.nix index 3a12050..6c7148f 100644 --- a/modules/nixos/common/ark.nix +++ b/modules/nixos/common/ark.nix @@ -4,34 +4,42 @@ lib, ... }: -with lib; let +with lib; +let cfg = config.nixfiles.modules.ark; -in { +in +{ imports = [ - (mkAliasOptionModule ["ark"] ["nixfiles" "modules" "ark"]) + (mkAliasOptionModule [ "ark" ] [ + "nixfiles" + "modules" + "ark" + ]) inputs.impermanence.nixosModules.impermanence ]; - options.nixfiles.modules.ark = let - mkListOfAnythingOption = mkOption { - type = with types; listOf anything; # Assumed to be matching with the upstream type. - default = []; - }; - in { - enable = mkEnableOption "persistent storage support via impermanence"; + options.nixfiles.modules.ark = + let + mkListOfAnythingOption = mkOption { + type = with types; listOf anything; # Assumed to be matching with the upstream type. + default = [ ]; + }; + in + { + enable = mkEnableOption "persistent storage support via impermanence"; - path = mkOption { - type = types.str; - default = "/ark"; - }; + path = mkOption { + type = types.str; + default = "/ark"; + }; - directories = mkListOfAnythingOption; - files = mkListOfAnythingOption; - # hm = { - # directories = mkListOfAnythingOption; - # files = mkListOfAnythingOption; - # }; - }; + directories = mkListOfAnythingOption; + files = mkListOfAnythingOption; + # hm = { + # directories = mkListOfAnythingOption; + # files = mkListOfAnythingOption; + # }; + }; config = mkIf cfg.enable { environment.persistence.${cfg.path} = { diff --git a/modules/nixos/common/console.nix b/modules/nixos/common/console.nix index 3491e37..330310c 100644 --- a/modules/nixos/common/console.nix +++ b/modules/nixos/common/console.nix @@ -1,8 +1,5 @@ +{ config, pkgs, ... }: { - config, - pkgs, - ... -}: { stylix.targets.console.enable = false; console = { diff --git a/modules/nixos/common/documentation.nix b/modules/nixos/common/documentation.nix index cb66818..f7d1585 100644 --- a/modules/nixos/common/documentation.nix +++ b/modules/nixos/common/documentation.nix @@ -5,7 +5,8 @@ this, ... }: -with lib; { +with lib; +{ config = mkIf this.isHeadful { documentation = { dev.enable = true; @@ -14,13 +15,12 @@ with lib; { man.man-db.manualPages = (pkgs.buildEnv { name = "man-paths"; - paths = with config; - environment.systemPackages ++ hm.home.packages; - pathsToLink = ["/share/man"]; - extraOutputsToInstall = ["man"]; + paths = with config; environment.systemPackages ++ hm.home.packages; + pathsToLink = [ "/share/man" ]; + extraOutputsToInstall = [ "man" ]; ignoreCollisions = true; - }) - .overrideAttrs (_: _: {__contentAddressed = true;}); + }).overrideAttrs + (_: _: { __contentAddressed = true; }); }; environment.sessionVariables = { diff --git a/modules/nixos/common/home-manager.nix b/modules/nixos/common/home-manager.nix index 52f2fd3..c553a65 100644 --- a/modules/nixos/common/home-manager.nix +++ b/modules/nixos/common/home-manager.nix @@ -1,3 +1,4 @@ -{inputs, ...}: { - imports = [inputs.home-manager.nixosModule]; +{ inputs, ... }: +{ + imports = [ inputs.home-manager.nixosModule ]; } diff --git a/modules/nixos/common/kernel.nix b/modules/nixos/common/kernel.nix index 2fc40f9..5c45b5d 100644 --- a/modules/nixos/common/kernel.nix +++ b/modules/nixos/common/kernel.nix @@ -1,11 +1,12 @@ -{lib, ...}: -with lib; { +{ lib, ... }: +with lib; +{ boot = { # I don't use it even on laptops. It's also /required/ to disable it for # ZFS[1]. # [1]: https://github.com/openzfs/zfs/issues/260 # [1]: https://github.com/openzfs/zfs/issues/12842 - kernelParams = ["hibernate=no"]; + kernelParams = [ "hibernate=no" ]; kernel.sysctl = { "fs.file-max" = pow 2 17; diff --git a/modules/nixos/common/locale.nix b/modules/nixos/common/locale.nix index 76186bc..699f89b 100644 --- a/modules/nixos/common/locale.nix +++ b/modules/nixos/common/locale.nix @@ -1,9 +1,6 @@ +{ lib, pkgs, ... }: +with lib; { - lib, - pkgs, - ... -}: -with lib; { i18n = { defaultLocale = mkDefault "en_GB.UTF-8"; supportedLocales = [ diff --git a/modules/nixos/common/networking.nix b/modules/nixos/common/networking.nix index fb7d9b2..ecadf6e 100644 --- a/modules/nixos/common/networking.nix +++ b/modules/nixos/common/networking.nix @@ -5,14 +5,16 @@ this, ... }: -with lib; let +with lib; +let cfg = config.nixfiles.modules.common.networking; -in { - options.nixfiles.modules.common.networking.onlyDefault = - mkEnableOption "custom networking settings"; +in +{ + options.nixfiles.modules.common.networking.onlyDefault = mkEnableOption "custom networking settings"; config = mkIf (!cfg.onlyDefault) { - ark.directories = with config.networking; + ark.directories = + with config.networking; optional networkmanager.enable "/etc/NetworkManager/system-connections" ++ optional wireless.iwd.enable "/var/lib/iwd"; @@ -27,8 +29,8 @@ in { # 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" = mkForce [ ]; + "::1" = mkForce [ ]; }; nameservers = mkDefault dns.const.quad9.default; @@ -52,33 +54,35 @@ in { logReversePathDrops = false; }; } - (let - interface = "eth0"; # This assumes `usePredictableInterfaceNames` is false. - in + ( + let + interface = "eth0"; # This assumes `usePredictableInterfaceNames` is false. + in mkIf (hasAttr "ipv4" this && 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; - }; - - ipv6.addresses = with this.ipv6; - optional (isString address && isInt prefixLength) { - inherit address prefixLength; - }; + ipv4.addresses = + with this.ipv4; + optional (isString address && isInt prefixLength) { inherit address prefixLength; }; + + ipv6.addresses = + with this.ipv6; + optional (isString address && isInt prefixLength) { inherit address prefixLength; }; }; - defaultGateway = with this.ipv4; + defaultGateway = + with this.ipv4; mkIf (isString gatewayAddress) { inherit interface; address = gatewayAddress; }; - defaultGateway6 = with this.ipv6; + defaultGateway6 = + with this.ipv6; mkIf (isString gatewayAddress) { inherit interface; address = gatewayAddress; }; - }) + } + ) (mkIf this.isHeadful { interfaces = { eth0.useDHCP = mkDefault true; @@ -100,12 +104,8 @@ in { ]; environment = { - shellAliases = listToAttrs (map - ({ - name, - value, - }: - nameValuePair name "${pkgs.iproute2}/bin/${value}") [ + shellAliases = listToAttrs ( + map ({ name, value }: nameValuePair name "${pkgs.iproute2}/bin/${value}") [ { name = "bridge"; value = "bridge -color=always"; @@ -118,7 +118,8 @@ in { name = "tc"; value = "tc -color=always"; } - ]); + ] + ); systemPackages = with pkgs; [ ethtool diff --git a/modules/nixos/common/nix.nix b/modules/nixos/common/nix.nix index 2976cfc..146575d 100644 --- a/modules/nixos/common/nix.nix +++ b/modules/nixos/common/nix.nix @@ -4,13 +4,15 @@ lib, ... }: -with lib; let +with lib; +let cfg = config.nixfiles.modules.common.nix; -in { +in +{ options.nixfiles.modules.common.nix.allowedUnfreePackages = mkOption { description = "A list of allowed unfree packages."; type = with types; listOf str; - default = []; + default = [ ]; }; config = { @@ -22,13 +24,12 @@ in { nixpkgs.config.allowUnfreePredicate = p: elem (getName p) cfg.allowedUnfreePackages; - system.stateVersion = with builtins; - head (split "\n" (readFile "${inputs.nixpkgs}/.version")); + system.stateVersion = with builtins; head (split "\n" (readFile "${inputs.nixpkgs}/.version")); environment = { sessionVariables.NIX_SHELL_PRESERVE_PROMPT = "1"; localBinInPath = true; - defaultPackages = []; + defaultPackages = [ ]; }; }; } diff --git a/modules/nixos/common/secrets.nix b/modules/nixos/common/secrets.nix index 9a82c44..31787ac 100644 --- a/modules/nixos/common/secrets.nix +++ b/modules/nixos/common/secrets.nix @@ -1,3 +1,4 @@ -{inputs, ...}: { - imports = [inputs.agenix.nixosModules.default]; +{ inputs, ... }: +{ + imports = [ inputs.agenix.nixosModules.default ]; } diff --git a/modules/nixos/common/shell.nix b/modules/nixos/common/shell.nix index 5fbc441..a1a7f08 100644 --- a/modules/nixos/common/shell.nix +++ b/modules/nixos/common/shell.nix @@ -1,3 +1 @@ -_: { - programs.command-not-found.enable = false; -} +_: { programs.command-not-found.enable = false; } diff --git a/modules/nixos/common/stylix.nix b/modules/nixos/common/stylix.nix index 5ca5571..a89943a 100644 --- a/modules/nixos/common/stylix.nix +++ b/modules/nixos/common/stylix.nix @@ -5,8 +5,9 @@ pkgs, ... }: -with lib; { - imports = [inputs.stylix.nixosModules.stylix]; +with lib; +{ + imports = [ inputs.stylix.nixosModules.stylix ]; stylix.cursor = { name = "phinger-cursors"; diff --git a/modules/nixos/common/systemd.nix b/modules/nixos/common/systemd.nix index 3972670..b393d9f 100644 --- a/modules/nixos/common/systemd.nix +++ b/modules/nixos/common/systemd.nix @@ -1,14 +1,11 @@ +{ config, pkgs, ... }: { - config, - pkgs, - ... -}: { ark = { - files = ["/etc/machine-id"]; - directories = ["/var/lib/systemd/coredump"]; + files = [ "/etc/machine-id" ]; + directories = [ "/var/lib/systemd/coredump" ]; }; - my.extraGroups = ["systemd-journal"]; + my.extraGroups = [ "systemd-journal" ]; hm.systemd.user.startServices = "sd-switch"; @@ -24,15 +21,19 @@ SystemMaxUse=5G ''; - systemd = let - extraConfig = '' - DefaultTimeoutStartSec=30s - DefaultTimeoutStopSec=15s - ''; - in { - inherit extraConfig; - user = {inherit extraConfig;}; - }; + systemd = + let + extraConfig = '' + DefaultTimeoutStartSec=30s + DefaultTimeoutStopSec=15s + ''; + in + { + inherit extraConfig; + user = { + inherit extraConfig; + }; + }; environment.sessionVariables = { SYSTEMD_PAGERSECURE = "1"; diff --git a/modules/nixos/common/users.nix b/modules/nixos/common/users.nix index 367af41..eca9e1b 100644 --- a/modules/nixos/common/users.nix +++ b/modules/nixos/common/users.nix @@ -1,8 +1,10 @@ -{lib, ...}: -with lib; let +{ lib, ... }: +with lib; +let home = "/home/${my.username}"; -in { - ark.directories = [home]; +in +{ + ark.directories = [ home ]; users = { mutableUsers = false; @@ -16,8 +18,8 @@ in { description = my.fullname; inherit home; inherit (my) hashedPassword; - openssh.authorizedKeys.keys = [my.ssh.key]; - extraGroups = ["wheel"]; + openssh.authorizedKeys.keys = [ my.ssh.key ]; + extraGroups = [ "wheel" ]; }; }; }; diff --git a/modules/nixos/common/xdg.nix b/modules/nixos/common/xdg.nix index 668996f..1fe167e 100644 --- a/modules/nixos/common/xdg.nix +++ b/modules/nixos/common/xdg.nix @@ -4,19 +4,19 @@ this, ... }: -with lib; let +with lib; +let cfg = config.nixfiles.modules.common.xdg; -in { +in +{ options.nixfiles.modules.common.xdg.defaultApplications = mkOption { description = "Default applications."; type = with types; attrsOf (listOf str); - default = {}; + default = { }; }; config = { - xdg.portal = mkIf this.isHeadful { - enable = true; - }; + xdg.portal = mkIf this.isHeadful { enable = true; }; hm.xdg = mkMerge [ (with cfg; { @@ -31,11 +31,9 @@ in { (mkIf this.isHeadful { mimeApps = { enable = true; - defaultApplications = - mkMerge - (mapAttrsToList - (n: v: genAttrs v (_: ["${n}.desktop"])) - cfg.defaultApplications); + defaultApplications = mkMerge ( + mapAttrsToList (n: v: genAttrs v (_: [ "${n}.desktop" ])) cfg.defaultApplications + ); }; }) ]; |