extendedLib: attrsets.concatAttrs -> lib.mergeAttrsList

This commit is contained in:
Oystein Kristoffer Tveit 2024-09-26 10:14:36 +02:00
parent 0ea394dbf9
commit 7500197568
Signed by: oysteikt
GPG Key ID: 9F2F7D8250F35146
2 changed files with 12 additions and 14 deletions

View File

@ -1,4 +1,4 @@
{ pkgs, lib, extendedLib, ... }: { pkgs, lib, ... }:
let let
adminUser = "root"; adminUser = "root";
normalUser = "oysteikt"; normalUser = "oysteikt";
@ -88,10 +88,10 @@ let
machines: pipe machines pipeline; machines: pipe machines pipeline;
in in
{ {
programs.ssh.matchBlocks = (extendedLib.attrsets.concatAttrs [ programs.ssh.matchBlocks = lib.mergeAttrsList [
(convertMachinesWith convertNormalMachine normalMachines) (convertMachinesWith convertNormalMachine normalMachines)
(convertMachinesWith convertAdminMachine rootMachines) (convertMachinesWith convertAdminMachine rootMachines)
]) // { {
"pvv-git git.pvv.ntnu.no" = { "pvv-git git.pvv.ntnu.no" = {
hostname = "git.pvv.ntnu.no"; hostname = "git.pvv.ntnu.no";
user = "gitea"; user = "gitea";
@ -99,5 +99,6 @@ in
port = 2222; port = 2222;
proxyJump = "pvv"; proxyJump = "pvv";
}; };
}; }
];
} }

View File

@ -7,9 +7,6 @@ in rec {
mapToAttrsWithConst = constant: items: mapToAttrsWithConst = constant: items:
listToAttrs (map (name: nameValuePair name constant) items); listToAttrs (map (name: nameValuePair name constant) items);
# [AttrSet] -> AttrSet
concatAttrs = foldr (a: b: a // b) {};
# (Int -> String -> a -> a) -> AttrSet -> AttrSet # (Int -> String -> a -> a) -> AttrSet -> AttrSet
imap0Attrs = f: set: imap0Attrs = f: set:
listToAttrs (imap0 (i: attr: nameValuePair attr (f i attr set.${attr})) (attrNames set)); listToAttrs (imap0 (i: attr: nameValuePair attr (f i attr set.${attr})) (attrNames set));