From cd4e3ab2c18300013b533da74d5feb6f98fef59f Mon Sep 17 00:00:00 2001 From: SebastianStork Date: Sun, 6 Apr 2025 22:14:20 +0200 Subject: [PATCH] Use the pipe operator when applicable --- flake/hosts.nix | 27 ++++++++++++++++----------- flake/modules.nix | 2 +- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/flake/hosts.nix b/flake/hosts.nix index f606551..00538f2 100644 --- a/flake/hosts.nix +++ b/flake/hosts.nix @@ -5,19 +5,24 @@ ... }: let - mkHost = hostname: { - ${hostname} = inputs.nixpkgs.lib.nixosSystem { + mkHost = hostName: { + ${hostName} = inputs.nixpkgs.lib.nixosSystem { specialArgs = { inherit inputs self; }; modules = - [ - { networking.hostName = hostname; } - "${self}/hosts/${hostname}" - ] - ++ builtins.filter (path: builtins.pathExists path) ( - map (user: "${self}/users/${user}/@${hostname}") ( - builtins.attrNames (lib.filterAttrs (_: v: v == "directory") (builtins.readDir "${self}/users")) - ) - ); + let + userFiles = + "${self}/users" + |> builtins.readDir + |> lib.filterAttrs (_: type: type == "directory") + |> builtins.attrNames + |> map (user: "${self}/users/${user}/@${hostName}") + |> builtins.filter (path: builtins.pathExists path); + in + lib.flatten [ + { networking = { inherit hostName; }; } + "${self}/hosts/${hostName}" + userFiles + ]; }; }; in diff --git a/flake/modules.nix b/flake/modules.nix index f826f4a..7570bf4 100644 --- a/flake/modules.nix +++ b/flake/modules.nix @@ -1,6 +1,6 @@ { self, lib, ... }: let - modulesOf = dir: builtins.filter (lib.hasSuffix ".nix") (lib.filesystem.listFilesRecursive dir); + modulesOf = dir: dir |> lib.filesystem.listFilesRecursive |> builtins.filter (lib.hasSuffix ".nix"); in { flake = {