From 9956b97b2f35a2cf87570e230abe0c5161d3944a Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 30 Jul 2014 10:28:05 +0200 Subject: [PATCH] Check for systemd environment variables that are too long Issue #3403. For the case of $PATH being too long, we could call buildEnv automatically. --- nixos/modules/system/boot/systemd.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nixos/modules/system/boot/systemd.nix b/nixos/modules/system/boot/systemd.nix index 14caa5d360d5..777c1ea74d88 100644 --- a/nixos/modules/system/boot/systemd.nix +++ b/nixos/modules/system/boot/systemd.nix @@ -317,7 +317,9 @@ let '' [Service] ${let env = cfg.globalEnvironment // def.environment; - in concatMapStrings (n: "Environment=\"${n}=${getAttr n env}\"\n") (attrNames env)} + in concatMapStrings (n: + let s = "Environment=\"${n}=${getAttr n env}\"\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 '' else if !def.restartIfChanged then ''