mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-03-23 01:49:56 +01:00
refactor: replace mapAttrs' with mapAttrs
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
let
|
||||
systemAttrs = {
|
||||
rec {
|
||||
# user information
|
||||
username = "ryan";
|
||||
userfullname = "Ryan Yin";
|
||||
useremail = "xiaoyin_c@qq.com";
|
||||
|
||||
allSystemAttrs = {
|
||||
# linux systems
|
||||
x64_system = "x86_64-linux";
|
||||
riscv64_system = "riscv64-linux";
|
||||
@@ -8,12 +13,5 @@ let
|
||||
x64_darwin = "x86_64-darwin";
|
||||
aarch64_darwin = "aarch64-darwin";
|
||||
};
|
||||
in systemAttrs // {
|
||||
# user information
|
||||
username = "ryan";
|
||||
userfullname = "Ryan Yin";
|
||||
useremail = "xiaoyin_c@qq.com";
|
||||
|
||||
inherit systemAttrs;
|
||||
allSystems = builtins.attrValues systemAttrs;
|
||||
allSystems = builtins.attrValues allSystemAttrs;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
args:
|
||||
with args; let
|
||||
with args;
|
||||
with allSystemAttrs; let
|
||||
lib = nixpkgs.lib;
|
||||
colmenaSystem = import ../lib/colmenaSystem.nix;
|
||||
# x86_64 related
|
||||
x64_base_args = {
|
||||
inherit home-manager;
|
||||
inherit nixpkgs; # or nixpkgs-unstable
|
||||
specialArgs = x64_system_specialArgs;
|
||||
specialArgs = allSystemSpecialArgs.x64_system;
|
||||
};
|
||||
|
||||
# riscv64 related
|
||||
@@ -44,7 +45,8 @@ in {
|
||||
colmena = {
|
||||
meta = {
|
||||
nixpkgs = import nixpkgs {system = x64_system;};
|
||||
specialArgs = x64_system_specialArgs;
|
||||
specialArgs = allSystemSpecialArgs.x64_system;
|
||||
|
||||
|
||||
nodeSpecialArgs = {
|
||||
# riscv64 SBCs
|
||||
|
||||
@@ -3,8 +3,8 @@ with args; let
|
||||
macosSystem = import ../lib/macosSystem.nix;
|
||||
x64_args = {
|
||||
inherit nix-darwin home-manager;
|
||||
system = x64_darwin;
|
||||
specialArgs = x64_darwin_specialArgs;
|
||||
system = allSystemAttrs.x64_darwin;
|
||||
specialArgs = allSystemSpecialArgs.x64_darwin;
|
||||
nixpkgs = nixpkgs-darwin;
|
||||
};
|
||||
aarch64_args = {
|
||||
@@ -13,7 +13,6 @@ with args; let
|
||||
specialArgs = aarch64_darwin_specialArgs;
|
||||
nixpkgs = nixpkgs-darwin;
|
||||
};
|
||||
|
||||
in {
|
||||
# macOS's configuration
|
||||
darwinConfigurations = {
|
||||
|
||||
@@ -18,21 +18,16 @@
|
||||
}
|
||||
// inputs;
|
||||
|
||||
# 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;
|
||||
allSystemSpecialArgs =
|
||||
lib.attrsets.mapAttrs
|
||||
(name: value: specialArgsForSystem value)
|
||||
constants.allSystemAttrs;
|
||||
|
||||
args = lib.attrsets.mergeAttrsList [
|
||||
inputs
|
||||
constants
|
||||
vars
|
||||
allSystemSpecialArgs
|
||||
{inherit self;}
|
||||
{inherit self allSystemSpecialArgs;}
|
||||
];
|
||||
in
|
||||
lib.attrsets.mergeAttrsList [
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
args:
|
||||
with args; let
|
||||
with args;
|
||||
with allSystemAttrs; let
|
||||
lib = nixpkgs.lib;
|
||||
nixosSystem = import ../lib/nixosSystem.nix;
|
||||
|
||||
@@ -7,7 +8,7 @@ with args; let
|
||||
inherit home-manager nixos-generators;
|
||||
inherit nixpkgs; # or nixpkgs-unstable
|
||||
system = x64_system;
|
||||
specialArgs = x64_system_specialArgs;
|
||||
specialArgs = allSystemSpecialArgs.x64_system;
|
||||
};
|
||||
in {
|
||||
nixosConfigurations = {
|
||||
|
||||
Reference in New Issue
Block a user