nixpkgs/nixos/lib
Ilan Joselevich 919ca6fd5a nixos/lib/utils: fix escapeSystemdPath for paths with "." segments
escapeSystemdPath relied on lib.strings.normalizePath, which only
collapses duplicate slashes and does not drop "." path components the
way systemd's path_simplify() does. A path like /mnt/./foo was thus
escaped to mnt-.-foo instead of mnt-foo, and systemd refused the
generated unit ("Where= setting doesn't match unit name").

Reimplement the simplification to match `systemd-escape --path` exactly:
drop "." and empty components, collapse a leading ".." run in an
absolute path to the root, and throw on any input systemd-escape
rejects (a non-leading "..", or a relative path that reduces to
nothing). Parity is checked against the systemd-escape binary over a
battery of edge cases and fuzzed inputs. While here, hoist the constant
escape table and partial applications out of the per-call lambda so
they are built once rather than on every call, making the function
~2.5x faster.

Resolves: https://github.com/NixOS/nixpkgs/issues/515270
Assisted-by: Claude:claude-opus-4-8
(cherry picked from commit 8f68c76d48)
2026-06-24 16:38:34 +00:00
..
make-options-doc nixosOptionsDoc: fix discarded context warning 2026-02-01 04:03:41 -08:00
test-driver nixos/test-driver: remove redundant self.pid state from NspawnMachine 2026-05-22 01:53:43 -07:00
testing nixos/test-driver: change run name to distinguish between different kinds of tests 2026-05-22 19:24:35 +10:00
binfmt-magics.nix nixos/binfmt: move magics to separate file 2025-09-10 11:56:49 +00:00
default.nix
eval-cacheable-options.nix nixos/documentation: Allow the inclusion of a nixpkgs/modules directory 2025-08-06 14:58:50 +02:00
eval-config-minimal.nix nixos: remove optional builtins prefixes from prelude functions 2026-01-15 16:07:55 +01:00
eval-config.nix treewide: remove redundant parentheses 2025-10-05 10:52:03 +02:00
from-env.nix
make-btrfs-fs.nix nixos: remove optional builtins prefixes from prelude functions 2026-01-15 16:07:55 +01:00
make-channel.nix
make-disk-image.nix
make-ext4-fs.nix nixos: remove optional builtins prefixes from prelude functions 2026-01-15 16:07:55 +01:00
make-iso9660-image.nix make-{iso9660-image,squashfs,system-tarball}: drop references to build closure (#425700) 2025-08-21 12:14:26 +02:00
make-iso9660-image.sh
make-multi-disk-zfs-image.nix nixos/lib/make-multi-disk-zfs-image: use structuredAttrs instead of passAsFile 2026-05-02 14:22:47 +02:00
make-single-disk-zfs-image.nix nixos/lib/make-single-disk-zfs-image: use structuredAttrs instead of passAsFile 2026-05-02 14:23:04 +02:00
make-squashfs.nix make-{iso9660-image,squashfs,system-tarball}: drop references to build closure (#425700) 2025-08-21 12:14:26 +02:00
make-system-tarball.nix make-system-tarball: drop references to build closure 2025-07-16 15:31:33 +10:00
make-system-tarball.sh
qemu-common.nix nixos/test-driver: add option to force kvm use 2026-04-15 12:15:00 +01:00
systemd-lib.nix nixos/lib/systemd-lib: make unitNameType work with e.g. Rust regex 2026-05-01 18:09:28 +02:00
systemd-network-units.nix nixos/systemd-networkd: add new options for v260 2026-04-26 00:06:57 +01:00
systemd-types.nix treewide: Fix links in module documentation 2025-08-25 12:55:11 -04:00
systemd-unit-options.nix nixos/radicle: Update radicle to support systemd creds more completely via ImportCredential 2026-03-19 22:09:23 +00:00
test-script-prepend.py nixos/lib/nixos-test-script-prepend: fix log definition 2026-05-03 15:57:18 +02:00
testing-python.nix nixos/test-driver: add support for nspawn containers 2026-01-28 11:28:32 +01:00
utils.nix nixos/lib/utils: fix escapeSystemdPath for paths with "." segments 2026-06-24 16:38:34 +00:00