summary refs log tree commit diff
path: root/nixos/modules/system/boot/systemd-unit-options.nix
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/modules/system/boot/systemd-unit-options.nix
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/modules/system/boot/systemd-unit-options.nix')
-rw-r--r--nixos/modules/system/boot/systemd-unit-options.nix4
1 files changed, 2 insertions, 2 deletions
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];