about summary refs log tree commit diff
path: root/nixos/modules/system
diff options
context:
space:
mode:
authorLinus Heckemann <git@sphalerite.org>2024-02-03 18:01:01 +0100
committerGitHub <noreply@github.com>2024-02-03 18:01:01 +0100
commit9f571cb4ef67ddfaa5e46be7cc404a347dd955b7 (patch)
treeb97b2075cc08394c14f1221626e4f7a226e78a24 /nixos/modules/system
parent8a935176b5c43aae0675230500d7cb6df42a3b9a (diff)
parentdff64f549e69a9fe83111628e0aae28654a1d6fc (diff)
downloadnixlib-9f571cb4ef67ddfaa5e46be7cc404a347dd955b7.tar
nixlib-9f571cb4ef67ddfaa5e46be7cc404a347dd955b7.tar.gz
nixlib-9f571cb4ef67ddfaa5e46be7cc404a347dd955b7.tar.bz2
nixlib-9f571cb4ef67ddfaa5e46be7cc404a347dd955b7.tar.lz
nixlib-9f571cb4ef67ddfaa5e46be7cc404a347dd955b7.tar.xz
nixlib-9f571cb4ef67ddfaa5e46be7cc404a347dd955b7.tar.zst
nixlib-9f571cb4ef67ddfaa5e46be7cc404a347dd955b7.zip
Merge pull request #284508 from nikstur/etc-overlay-leading-slash
nixos/etc: remove leading slash from paths
Diffstat (limited to 'nixos/modules/system')
-rw-r--r--nixos/modules/system/etc/build-composefs-dump.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/nixos/modules/system/etc/build-composefs-dump.py b/nixos/modules/system/etc/build-composefs-dump.py
index 923d40008b63..bf4ec791ecf7 100644
--- a/nixos/modules/system/etc/build-composefs-dump.py
+++ b/nixos/modules/system/etc/build-composefs-dump.py
@@ -58,7 +58,7 @@ class ComposefsPath:
     ):
         if path is None:
             path = attrs["target"]
-        self.path = "/" + path
+        self.path = path
         self.size = size
         self.filetype = filetype
         self.mode = mode
@@ -83,8 +83,12 @@ class ComposefsPath:
         return " ".join(line_list)
 
 
-def eprint(*args, **kwargs) -> None:
-    print(args, **kwargs, file=sys.stderr)
+def eprint(*args: Any, **kwargs: Any) -> None:
+    print(*args, **kwargs, file=sys.stderr)
+
+
+def normalize_path(path: str) -> str:
+    return str("/" + os.path.normpath(path).lstrip("/"))
 
 
 def leading_directories(path: str) -> list[str]:
@@ -145,6 +149,10 @@ def main() -> None:
 
     paths: dict[str, ComposefsPath] = {}
     for attrs in config:
+        # Normalize the target path to work around issues in how targets are
+        # declared in `environment.etc`.
+        attrs["target"] = normalize_path(attrs["target"])
+
         target = attrs["target"]
         source = attrs["source"]
         mode = attrs["mode"]