From 92b98478a830a7f7e6f65195aa1b2257798fe423 Mon Sep 17 00:00:00 2001 From: nikstur Date: Sun, 28 Jan 2024 01:02:15 +0100 Subject: [PATCH 1/3] nixos/etc: fix type checking of build-composefs-dump.py --- nixos/modules/system/etc/build-composefs-dump.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nixos/modules/system/etc/build-composefs-dump.py b/nixos/modules/system/etc/build-composefs-dump.py index 923d40008b63f..a1b922d97369b 100644 --- a/nixos/modules/system/etc/build-composefs-dump.py +++ b/nixos/modules/system/etc/build-composefs-dump.py @@ -83,8 +83,8 @@ def write_line(self) -> str: 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 leading_directories(path: str) -> list[str]: From a9161ceb5a3669ced280ce0805ad38470b5904b2 Mon Sep 17 00:00:00 2001 From: nikstur Date: Sun, 28 Jan 2024 01:55:05 +0100 Subject: [PATCH 2/3] nixos/etc: remove leading slash from target paths in build-composefs-dump.py This is necessary so that duplicates in the composefs dump are avoided. --- nixos/modules/system/etc/build-composefs-dump.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/nixos/modules/system/etc/build-composefs-dump.py b/nixos/modules/system/etc/build-composefs-dump.py index a1b922d97369b..bf4ec791ecf7d 100644 --- a/nixos/modules/system/etc/build-composefs-dump.py +++ b/nixos/modules/system/etc/build-composefs-dump.py @@ -58,7 +58,7 @@ def __init__( ): if path is None: path = attrs["target"] - self.path = "/" + path + self.path = path self.size = size self.filetype = filetype self.mode = mode @@ -87,6 +87,10 @@ 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]: """Return the leading directories of path @@ -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"] From dff64f549e69a9fe83111628e0aae28654a1d6fc Mon Sep 17 00:00:00 2001 From: nikstur Date: Sun, 28 Jan 2024 13:38:09 +0100 Subject: [PATCH 3/3] nixos/x11: remove leading slash from environment.etc path Even if the tools that assemble /etc can handle leading slashes, this still is not correct. For example, you could have both /X11 and X11 in environment.etc which makes overriding hard. --- nixos/modules/services/x11/xserver.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nixos/modules/services/x11/xserver.nix b/nixos/modules/services/x11/xserver.nix index 36f25d5547cae..38fb1074fcdf8 100644 --- a/nixos/modules/services/x11/xserver.nix +++ b/nixos/modules/services/x11/xserver.nix @@ -710,9 +710,9 @@ in ''; } # Needed since 1.18; see https://bugs.freedesktop.org/show_bug.cgi?id=89023#c5 - // (let cfgPath = "/X11/xorg.conf.d/10-evdev.conf"; in + // (let cfgPath = "X11/xorg.conf.d/10-evdev.conf"; in { - ${cfgPath}.source = xorg.xf86inputevdev.out + "/share" + cfgPath; + ${cfgPath}.source = xorg.xf86inputevdev.out + "/share/" + cfgPath; }); environment.systemPackages = utils.removePackagesByName