From e4abf62ec3ff7493f363512e3a09c5cca8394478 Mon Sep 17 00:00:00 2001 From: Ryan Yin Date: Fri, 22 Dec 2023 01:23:15 +0800 Subject: [PATCH] refactor: replace listToAttrs with mapAttrs' to get a cleaner definition --- constants.nix | 1 + systems/default.nix | 22 ++++++++-------------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/constants.nix b/constants.nix index 23ec3eb8..128d4b05 100644 --- a/constants.nix +++ b/constants.nix @@ -14,5 +14,6 @@ in systemAttrs // { userfullname = "Ryan Yin"; useremail = "xiaoyin_c@qq.com"; + inherit systemAttrs; allSystems = builtins.attrValues systemAttrs; } diff --git a/systems/default.nix b/systems/default.nix index 12e45ecf..d8ab65aa 100644 --- a/systems/default.nix +++ b/systems/default.nix @@ -18,20 +18,14 @@ } // inputs; - allSystemSpecialArgs = builtins.listToAttrs ( - map - (attr: { - name = attr + "_specialArgs"; - value = specialArgsForSystem constants.${attr}; - }) - [ - "x64_system" - "aarch64_system" - "riscv64_system" - "x64_darwin" - "aarch64_darwin" - ] - ); + # mapAttrs' + # (name: value: nameValuePair ("foo_" + name) ("bar-" + value)) + # { x = "a"; y = "b"; } + # => { foo_x = "bar-a"; foo_y = "bar-b"; } + allSystemSpecialArgs = with lib.attrsets; + mapAttrs' + (name: value: nameValuePair (name + "_specialArgs") (specialArgsForSystem value)) + constants.systemAttrs; args = lib.attrsets.mergeAttrsList [ inputs