summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2014-10-05 00:03:52 +0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2014-10-05 01:11:06 +0200
commit97220c973fdc6d3cfa02fe597c4301e87177603c (patch)
treec208a98c5a45a9700b8c56775e69542ef7fba44f /nixos
parent0e120dc68f7de02ccb22df27fd15835fc6d082a4 (diff)
downloadnixpkgs-97220c973fdc6d3cfa02fe597c4301e87177603c.tar
nixpkgs-97220c973fdc6d3cfa02fe597c4301e87177603c.tar.gz
nixpkgs-97220c973fdc6d3cfa02fe597c4301e87177603c.tar.bz2
nixpkgs-97220c973fdc6d3cfa02fe597c4301e87177603c.tar.lz
nixpkgs-97220c973fdc6d3cfa02fe597c4301e87177603c.tar.xz
nixpkgs-97220c973fdc6d3cfa02fe597c4301e87177603c.tar.zst
nixpkgs-97220c973fdc6d3cfa02fe597c4301e87177603c.zip
Replace hasAttr/getAttr calls with the ? and . operators
For NixOS evaluation, this gives a ~21% reduction in the number of
values allocated and a ~4% speedup. It's also more readable.
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/services/x11/xserver.nix4
-rw-r--r--nixos/modules/system/boot/systemd-unit-options.nix4
-rw-r--r--nixos/modules/system/boot/systemd.nix2
3 files changed, 5 insertions, 5 deletions
diff --git a/nixos/modules/services/x11/xserver.nix b/nixos/modules/services/x11/xserver.nix
index c08afe2041f..1ce8de23c16 100644
--- a/nixos/modules/services/x11/xserver.nix
+++ b/nixos/modules/services/x11/xserver.nix
@@ -399,8 +399,8 @@ in
     services.xserver.drivers = flip concatMap cfg.videoDrivers (name:
       let driver =
         attrByPath [name]
-          (if (hasAttr ("xf86video" + name) xorg)
-           then { modules = [(getAttr ("xf86video" + name) xorg) ]; }
+          (if xorg ? ${"xf86video" + name}
+           then { modules = [xorg.${"xf86video" + name}]; }
            else null)
           knownVideoDrivers;
       in optional (driver != null) ({ inherit name; driverName = name; } // driver));
diff --git a/nixos/modules/system/boot/systemd-unit-options.nix b/nixos/modules/system/boot/systemd-unit-options.nix
index 48c3564ba07..07f3cb9e952 100644
--- a/nixos/modules/system/boot/systemd-unit-options.nix
+++ b/nixos/modules/system/boot/systemd-unit-options.nix
@@ -6,8 +6,8 @@ let
 
   checkService = v:
     let assertValueOneOf = name: values: attr:
-          let val = getAttr name attr;
-          in optional ( hasAttr name attr && !elem val values) "Systemd service field `${name}' cannot have value `${val}'.";
+          let val = attr.${name};
+          in optional (attr ? ${name} && !elem val values) "Systemd service field `${name}' cannot have value `${val}'.";
         checkType = assertValueOneOf "Type" ["simple" "forking" "oneshot" "dbus" "notify" "idle"];
         checkRestart = assertValueOneOf "Restart" ["no" "on-success" "on-failure" "on-abort" "always"];
         errors = concatMap (c: c v) [checkType checkRestart];
diff --git a/nixos/modules/system/boot/systemd.nix b/nixos/modules/system/boot/systemd.nix
index f2f7989ab4d..d0fe69c15dd 100644
--- a/nixos/modules/system/boot/systemd.nix
+++ b/nixos/modules/system/boot/systemd.nix
@@ -321,7 +321,7 @@ let
           [Service]
           ${let env = cfg.globalEnvironment // def.environment;
             in concatMapStrings (n:
-              let s = "Environment=\"${n}=${getAttr n env}\"\n";
+              let s = "Environment=\"${n}=${env.${n}}\"\n";
               in if stringLength s >= 2048 then throw "The value of the environment variable ‘${n}’ in systemd service ‘${name}.service’ is too long." else s) (attrNames env)}
           ${if def.reloadIfChanged then ''
             X-ReloadIfChanged=true