From ae8d4501b65ad6be7d83b3da60672c39e1b8ffcb Mon Sep 17 00:00:00 2001 From: Marc Weber Date: Tue, 27 Apr 2010 18:44:23 +0000 Subject: [PATCH] adding maybeEnv. This will replace from-env.nix in nixos and will be reused in copySystemConfiguration svn path=/nixpkgs/trunk/; revision=21353 --- pkgs/lib/misc.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkgs/lib/misc.nix b/pkgs/lib/misc.nix index 2cfd15735a74..0a8c61d6c85c 100644 --- a/pkgs/lib/misc.nix +++ b/pkgs/lib/misc.nix @@ -9,6 +9,11 @@ with import ./strings.nix; rec { + # returns default if env var is not set + maybeEnv = name: default: + let value = builtins.getEnv name; in + if value == "" then default else value; + defaultMergeArg = x : y: if builtins.isAttrs y then y else