From c9636b0bfade24a7dccc5a6a3a4153ad37c74ebb Mon Sep 17 00:00:00 2001 From: Mohammad Rafiq Date: Sun, 6 Jul 2025 07:31:48 +0800 Subject: [PATCH] feat(nixos): pass flakeConfig to nixosSystem specialArgs --- modules/configurations/nixos.nix | 15 ++++++++++++--- modules/lib/default.nix | 5 ++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/modules/configurations/nixos.nix b/modules/configurations/nixos.nix index 4a2ccca..a251852 100644 --- a/modules/configurations/nixos.nix +++ b/modules/configurations/nixos.nix @@ -8,20 +8,29 @@ let inherit (lib.trivial) pipe; inherit (lib.attrsets) filterAttrs mapAttrs'; inherit (lib.strings) removePrefix hasPrefix; + cfg = config.flake; prefix = "nixos/"; - hosts = config.flake.hostSpec.hosts or { }; + hosts = cfg.hostSpec.hosts or { }; mkSystem = name: value: let hostName = removePrefix prefix name; hostConfig = value; + flakeConfig = config; in { name = hostName; value = lib.nixosSystem { - specialArgs = { inherit inputs hostName hostConfig; }; + specialArgs = { + inherit + inputs + hostName + hostConfig + flakeConfig + ; + }; modules = [ - config.flake.profiles.nixos.common + cfg.profiles.nixos.common (value.extraCfg or { }) ] ++ (value.profiles or [ ]); }; diff --git a/modules/lib/default.nix b/modules/lib/default.nix index 186a956..710a658 100644 --- a/modules/lib/default.nix +++ b/modules/lib/default.nix @@ -1,10 +1,9 @@ { lib, ... }: let - inherit (lib.modules) mkMerge; - inherit (lib.attrsets) mapAttrsToList; + inherit (lib.attrsets) concatMapAttrs; in { flake.lib = { - flattenAttrs = attrset: mkMerge (mapAttrsToList (_: v: v) attrset); + flattenAttrs = attrset: concatMapAttrs (_: v: v) attrset; }; }