stuff
This commit is contained in:
@@ -21,9 +21,10 @@ let
|
||||
"sniper"
|
||||
"spy"
|
||||
];
|
||||
attrsOfClasses = f: builtins.listToAttrs (map (classname:
|
||||
lib.nameValuePair classname (f classname)
|
||||
) classes);
|
||||
mkAttrsOf = f: list: builtins.listToAttrs (map (v:
|
||||
lib.nameValuePair v (f v)
|
||||
) list);
|
||||
mkAttrsOfClasses = f: mkAttrsOf f classes;
|
||||
# key: what tf2 calls the key
|
||||
# value: other things you might want to call that key
|
||||
keyAliases = {
|
||||
@@ -167,13 +168,10 @@ let
|
||||
'')++ builtins.attrNames keyAliases;
|
||||
bindCommandType = types.strMatching ''[a-zA-Z0-9'; +_-]+'';
|
||||
bindsModule = { config, ... }: {
|
||||
options = (lib.pipe keys [
|
||||
(map (key: lib.nameValuePair key (lib.mkOption {
|
||||
type = types.nullOr bindCommandType;
|
||||
default = null;
|
||||
})))
|
||||
builtins.listToAttrs
|
||||
]) // {
|
||||
options = (mkAttrsOf (key: mkOption {
|
||||
type = types.nullOr bindCommandType;
|
||||
default = null;
|
||||
}) keys) // {
|
||||
_out = mkOption {
|
||||
internal = true;
|
||||
readOnly = true;
|
||||
@@ -211,40 +209,28 @@ in
|
||||
clear = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = "Whether to run unbindall at the beginning of autoexec";
|
||||
};
|
||||
default = mkOption {
|
||||
type = types.submodule bindsModule;
|
||||
default = {};
|
||||
};
|
||||
} // lib.pipe classes [
|
||||
(map (classname:
|
||||
lib.nameValuePair classname (mkOption {
|
||||
type = types.submodule bindsModule;
|
||||
default = cfg.binds.default;
|
||||
})
|
||||
))
|
||||
builtins.listToAttrs
|
||||
];
|
||||
} // mkAttrsOfClasses (classname: mkOption {
|
||||
type = types.submodule bindsModule;
|
||||
default = {};
|
||||
});
|
||||
autoexecLines = mkOption {
|
||||
type = types.lines;
|
||||
default = "";
|
||||
};
|
||||
classLines = lib.pipe classes [
|
||||
(map (classname:
|
||||
lib.nameValuePair classname (mkOption {
|
||||
type = types.lines;
|
||||
default = "";
|
||||
})
|
||||
))
|
||||
builtins.listToAttrs
|
||||
];
|
||||
build.autoexec = pkgs.writeFile "autoexec.cfg" cfg.cfg;
|
||||
build.classes = lib.pipe classes [
|
||||
(map (classname:
|
||||
lib.nameValuePair classname (pkgs.writeText "${classname}.cfg" cfg.classLines.${classname})
|
||||
))
|
||||
builtins.listToAttrs
|
||||
];
|
||||
classLines = mkAttrsOfClasses (classname: mkOption {
|
||||
type = types.lines;
|
||||
default = "";
|
||||
});
|
||||
build.autoexec = vaculib.mkOutOption (pkgs.writeFile "autoexec.cfg" cfg.autoexecLines);
|
||||
build.classes = vaculib.mkOutOption (mkAttrsOfClasses (classname:
|
||||
pkgs.writeText "${classname}.cfg" cfg.classLines.${classname}
|
||||
));
|
||||
};
|
||||
|
||||
config.tf2 = {
|
||||
@@ -258,15 +244,10 @@ in
|
||||
++ lib.optional cfg.binds.clear (lib.mkBefore ''unbindall'')
|
||||
)
|
||||
;
|
||||
classLines = lib.pipe classes [
|
||||
(map (classname:
|
||||
lib.nameValuePair classname ''
|
||||
// START keybinds from config.tf2.binds.${classname}
|
||||
${cfg.binds.${classname}._out}
|
||||
// END keybinds from config.tf2.binds.${classname}
|
||||
''
|
||||
))
|
||||
builtins.listToAttrs
|
||||
];
|
||||
classLines = mkAttrsOfClasses (classname: ''
|
||||
// START keybinds from config.tf2.binds.${classname}
|
||||
${cfg.binds.${classname}._out}
|
||||
// END keybinds from config.tf2.binds.${classname}
|
||||
'');
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user