lib.getAttr -> lib.attrByPath

svn path=/nixos/trunk/; revision=15695
This commit is contained in:
Marc Weber 2009-05-24 10:58:24 +00:00
parent 0792719b90
commit 6b2f1a0ce9
5 changed files with 14 additions and 14 deletions

View File

@ -13,7 +13,7 @@ let
getPort = cfg: if cfg.port != 0 then cfg.port else if cfg.enableSSL then 443 else 80; getPort = cfg: if cfg.port != 0 then cfg.port else if cfg.enableSSL then 443 else 80;
extraModules = pkgs.lib.getAttr ["extraModules"] [] mainCfg; extraModules = pkgs.lib.attrByPath ["extraModules"] [] mainCfg;
extraForeignModules = pkgs.lib.filter builtins.isAttrs extraModules; extraForeignModules = pkgs.lib.filter builtins.isAttrs extraModules;
extraApachaModules = pkgs.lib.filter (x :! (builtins.isAttrs x)) extraModules; # I'd prefer using builtins.isString here, but doesn't exist yet extraApachaModules = pkgs.lib.filter (x :! (builtins.isAttrs x)) extraModules; # I'd prefer using builtins.isString here, but doesn't exist yet

View File

@ -23,14 +23,14 @@ let
newProposalJobs = newProposalJobs =
( (
let let
inherit (pkgs.lib) getAttr; inherit (pkgs.lib) attrByPath;
inherit (builtins) attrNames pathExists map; inherit (builtins) attrNames pathExists map;
services = getAttr [ "servicesProposal" ] {} config; services = attrByPath [ "servicesProposal" ] {} config;
nameToJobs = name : ( nameToJobs = name : (
( (
let p = ./new-proposal + "/${name}.nix"; let p = ./new-proposal + "/${name}.nix";
p2 = ./new-proposal + "/${name}/default.nix"; p2 = ./new-proposal + "/${name}/default.nix";
thisConfig = getAttr [ name ] {} services; thisConfig = attrByPath [ name ] {} services;
path = [name]; path = [name];
args = confgiV : { args = confgiV : {
inherit config pkgs thisConfig path; inherit config pkgs thisConfig path;
@ -60,7 +60,7 @@ let
then let v = (__getAttr name thisConfig); in if opt ? apply then opt.apply v else v then let v = (__getAttr name thisConfig); in if opt ? apply then opt.apply v else v
else if opt ? default then opt.default else abort "you need to specify the configuration option ${errorWhere name}" else if opt ? default then opt.default else abort "you need to specify the configuration option ${errorWhere name}"
else abort "unkown option ${errorWhere name}"; else abort "unkown option ${errorWhere name}";
checkConfig = (pkgs.lib.getAttr ["environment" "checkConfigurationOptions"] checkConfig = (attrByPath ["environment" "checkConfigurationOptions"]
optionDeclarations.environment.checkConfigurationOptions.default optionDeclarations.environment.checkConfigurationOptions.default
config); config);
in # TODO: pass path to checker so it can show full path in the abort case in # TODO: pass path to checker so it can show full path in the abort case

View File

@ -5,7 +5,7 @@ let
cfg = config.services.xserver; cfg = config.services.xserver;
xorg = cfg.package; xorg = cfg.package;
inherit (pkgs.lib) optional isInList getAttr; inherit (pkgs.lib) optional isInList attrByPath;
stdenv = pkgs.stdenv; stdenv = pkgs.stdenv;
knownVideoDrivers = { knownVideoDrivers = {
@ -26,17 +26,17 @@ let
resolutions = map (res: ''"${toString res.x}x${toString res.y}"'') (cfg.resolutions); resolutions = map (res: ''"${toString res.x}x${toString res.y}"'') (cfg.resolutions);
sessionType = cfg.sessionType; sessionType = cfg.sessionType;
videoDriverModules = getAttr [ videoDriver ] (throw "unknown video driver: `${videoDriver}'") knownVideoDrivers; videoDriverModules = attrByPath [ videoDriver ] (throw "unknown video driver: `${videoDriver}'") knownVideoDrivers;
modules = modules =
getAttr ["modulesFirst"] [] videoDriverModules attrByPath ["modulesFirst"] [] videoDriverModules
++ [ ++ [
xorg.xorgserver xorg.xorgserver
xorg.xf86inputkeyboard xorg.xf86inputkeyboard
xorg.xf86inputmouse xorg.xf86inputmouse
] ]
++ getAttr ["modules"] [] videoDriverModules ++ attrByPath ["modules"] [] videoDriverModules
++ (optional cfg.synaptics.enable ["${pkgs.synaptics}/${xorg.xorgserver}" /*xorg.xf86inputevdev*/]); ++ (optional cfg.synaptics.enable ["${pkgs.synaptics}/${xorg.xorgserver}" /*xorg.xf86inputevdev*/]);

View File

@ -70,7 +70,7 @@
}; };
}; };
jobs = if (lib.getAttr ["services" "xfs" "enable"] false config) != true jobs = if (lib.attrByPath ["services" "xfs" "enable"] false config) != true
then abort "you need to enable xfs services = { xfs = { enable = true; }; } within your nixos/configuration.nix file" then abort "you need to enable xfs services = { xfs = { enable = true; }; } within your nixos/configuration.nix file"
else else
[ ( rec { [ ( rec {

View File

@ -6,7 +6,7 @@
let let
inherit (pkgs.lib) optional isInList getAttr; inherit (pkgs.lib) optional isInList attrByPath;
# Abbreviations. # Abbreviations.
cfg = config.services.xserver; cfg = config.services.xserver;
@ -32,7 +32,7 @@ let
resolutions = map (res: ''"${toString res.x}x${toString res.y}"'') (cfg.resolutions); resolutions = map (res: ''"${toString res.x}x${toString res.y}"'') (cfg.resolutions);
sessionType = cfg.sessionType; sessionType = cfg.sessionType;
videoDriverModules = getAttr [ videoDriver ] (throw "unknown video driver: `${videoDriver}'") knownVideoDrivers; videoDriverModules = attrByPath [ videoDriver ] (throw "unknown video driver: `${videoDriver}'") knownVideoDrivers;
sessionCmd = sessionCmd =
@ -52,12 +52,12 @@ let
modules = modules =
getAttr ["modulesFirst"] [] videoDriverModules attrByPath ["modulesFirst"] [] videoDriverModules
++ [ ++ [
xorg.xorgserver xorg.xorgserver
xorg.xf86inputevdev xorg.xf86inputevdev
] ]
++ getAttr ["modules"] [] videoDriverModules ++ attrByPath ["modules"] [] videoDriverModules
++ (optional cfg.synaptics.enable ["${xorg.xf86inputsynaptics}"]); ++ (optional cfg.synaptics.enable ["${xorg.xf86inputsynaptics}"]);