nixos/utils: Don't remove first character if not a /

Changed files
+2 -1
nixos
lib
+2 -1
nixos/lib/utils.nix
···
# Escape a path according to the systemd rules, e.g. /dev/xyzzy
# becomes dev-xyzzy. FIXME: slow.
escapeSystemdPath = s:
-
replaceChars ["/" "-" " "] ["-" "\\x2d" "\\x20"] (substring 1 (stringLength s) s);
}
···
# Escape a path according to the systemd rules, e.g. /dev/xyzzy
# becomes dev-xyzzy. FIXME: slow.
escapeSystemdPath = s:
+
replaceChars ["/" "-" " "] ["-" "\\x2d" "\\x20"]
+
(if hasPrefix "/" s then substring 1 (stringLength s) s else s);
}