From b7d927cb39caf63584a354b19a33ff450852bde1 Mon Sep 17 00:00:00 2001 From: SebastianStork Date: Thu, 19 Jun 2025 12:22:59 +0200 Subject: [PATCH] Remove all uses of lib.flatten --- flake/hosts.nix | 6 +-- modules/system/services/crowdsec/default.nix | 4 +- modules/system/services/gatus.nix | 2 +- modules/system/wifi.nix | 47 +++++++++----------- 4 files changed, 27 insertions(+), 32 deletions(-) diff --git a/flake/hosts.nix b/flake/hosts.nix index 3253f74..291bc4d 100644 --- a/flake/hosts.nix +++ b/flake/hosts.nix @@ -15,11 +15,11 @@ let |> lib.filesystem.listFilesRecursive |> builtins.filter (lib.hasSuffix ".nix"); in - lib.flatten [ + [ { networking = { inherit hostName; }; } "${self}/hosts/shared.nix" - hostFiles - ]; + ] + ++ hostFiles; }; }; diff --git a/modules/system/services/crowdsec/default.nix b/modules/system/services/crowdsec/default.nix index 1195564..a6472ce 100644 --- a/modules/system/services/crowdsec/default.nix +++ b/modules/system/services/crowdsec/default.nix @@ -90,12 +90,12 @@ in ''; in [ - "crowdsecurity/linux" + (lib.singleton "crowdsecurity/linux") (lib.optional (lib.elem "sshd" cfg.sources) "crowdsecurity/sshd") (lib.optional (lib.elem "caddy" cfg.sources) "crowdsecurity/caddy") (lib.optional (lib.elem "iptables" cfg.sources) "crowdsecurity/iptables") ] - |> lib.flatten + |> lib.concatLists |> lib.map installCollection |> lib.concatLines |> (text: pkgs.writeShellScript "crowdsec-install-collections" "set -e\n${text}") diff --git a/modules/system/services/gatus.nix b/modules/system/services/gatus.nix index 00299f3..9268bc5 100644 --- a/modules/system/services/gatus.nix +++ b/modules/system/services/gatus.nix @@ -101,7 +101,7 @@ in username = ""; password = ""; }; - conditions = lib.flatten [ + conditions = lib.concatLists [ extraConditions (lib.optional (lib.hasPrefix "http" url) "[STATUS] == 200") (lib.optional (lib.hasPrefix "tcp" url) "[CONNECTED] == true") diff --git a/modules/system/wifi.nix b/modules/system/wifi.nix index c35da89..a9c9fbd 100644 --- a/modules/system/wifi.nix +++ b/modules/system/wifi.nix @@ -16,33 +16,28 @@ in { options.custom.wifi.enable = lib.mkEnableOption ""; - config = lib.mkIf config.custom.wifi.enable ( - lib.mkMerge ( - lib.flatten [ - { - networking.wireless.iwd = { - enable = true; - settings = { - General.EnableNetworkConfiguration = true; - Settings.AutoConnect = true; - Network.NameResolvingService = "resolvconf"; - }; - }; + config = lib.mkIf config.custom.wifi.enable { + networking.wireless.iwd = { + enable = true; + settings = { + General.EnableNetworkConfiguration = true; + Settings.AutoConnect = true; + Network.NameResolvingService = "resolvconf"; + }; + }; - environment.systemPackages = [ pkgs.iwgtk ]; - } + environment.systemPackages = [ pkgs.iwgtk ]; - ( - networks - |> lib.map (name: { - sops.secrets."iwd/${name}" = { }; + sops.secrets = + networks + |> lib.map (name: { + name = "iwd/${name}"; + value = { }; + }) + |> lib.listToAttrs; - systemd.tmpfiles.rules = [ - "C /var/lib/iwd/${name} - - - - ${config.sops.secrets."iwd/${name}".path}" - ]; - }) - ) - ] - ) - ); + systemd.tmpfiles.rules = + networks + |> lib.map (name: "C /var/lib/iwd/${name} - - - - ${config.sops.secrets."iwd/${name}".path}"); + }; }