summary refs log tree commit diff
path: root/nixos/lib/utils.nix
blob: 7b8be2050c133c8dfbd12014602e8ad86f45dbeb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
pkgs: with pkgs.lib;

rec {

  # 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);

}