mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 21:50:33 +03:00
Merge pull request #314579 from ivan770/etc-direct-symlinks
nixos/etc: support direct symlinks with etc overlay
This commit is contained in:
commit
2d15501141
3 changed files with 22 additions and 19 deletions
|
@ -175,7 +175,7 @@ def main() -> None:
|
||||||
paths[glob_target] = composefs_path
|
paths[glob_target] = composefs_path
|
||||||
add_leading_directories(glob_target, attrs, paths)
|
add_leading_directories(glob_target, attrs, paths)
|
||||||
else: # Without globbing
|
else: # Without globbing
|
||||||
if mode == "symlink":
|
if mode == "symlink" or mode == "direct-symlink":
|
||||||
composefs_path = ComposefsPath(
|
composefs_path = ComposefsPath(
|
||||||
attrs,
|
attrs,
|
||||||
# A high approximation of the size of a symlink
|
# A high approximation of the size of a symlink
|
||||||
|
@ -184,24 +184,23 @@ def main() -> None:
|
||||||
mode="0777",
|
mode="0777",
|
||||||
payload=source,
|
payload=source,
|
||||||
)
|
)
|
||||||
|
elif os.path.isdir(source):
|
||||||
|
composefs_path = ComposefsPath(
|
||||||
|
attrs,
|
||||||
|
size=4096,
|
||||||
|
filetype=FileType.directory,
|
||||||
|
mode=mode,
|
||||||
|
payload=source,
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
if os.path.isdir(source):
|
composefs_path = ComposefsPath(
|
||||||
composefs_path = ComposefsPath(
|
attrs,
|
||||||
attrs,
|
size=os.stat(source).st_size,
|
||||||
size=4096,
|
filetype=FileType.file,
|
||||||
filetype=FileType.directory,
|
mode=mode,
|
||||||
mode=mode,
|
# payload needs to be relative path in this case
|
||||||
payload=source,
|
payload=target.lstrip("/"),
|
||||||
)
|
)
|
||||||
else:
|
|
||||||
composefs_path = ComposefsPath(
|
|
||||||
attrs,
|
|
||||||
size=os.stat(source).st_size,
|
|
||||||
filetype=FileType.file,
|
|
||||||
mode=mode,
|
|
||||||
# payload needs to be relative path in this case
|
|
||||||
payload=target.lstrip("/"),
|
|
||||||
)
|
|
||||||
paths[target] = composefs_path
|
paths[target] = composefs_path
|
||||||
add_leading_directories(target, attrs, paths)
|
add_leading_directories(target, attrs, paths)
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ let
|
||||||
]) etc'}
|
]) etc'}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
etcHardlinks = filter (f: f.mode != "symlink") etc';
|
etcHardlinks = filter (f: f.mode != "symlink" && f.mode != "direct-symlink") etc';
|
||||||
|
|
||||||
build-composefs-dump = pkgs.runCommand "build-composefs-dump.py"
|
build-composefs-dump = pkgs.runCommand "build-composefs-dump.py"
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
users.mutableUsers = false;
|
users.mutableUsers = false;
|
||||||
boot.initrd.systemd.enable = true;
|
boot.initrd.systemd.enable = true;
|
||||||
boot.kernelPackages = pkgs.linuxPackages_latest;
|
boot.kernelPackages = pkgs.linuxPackages_latest;
|
||||||
|
time.timeZone = "Utc";
|
||||||
|
|
||||||
specialisation.new-generation.configuration = {
|
specialisation.new-generation.configuration = {
|
||||||
environment.etc."newgen".text = "newgen";
|
environment.etc."newgen".text = "newgen";
|
||||||
|
@ -23,6 +24,9 @@
|
||||||
with subtest("/etc is mounted as an overlay"):
|
with subtest("/etc is mounted as an overlay"):
|
||||||
machine.succeed("findmnt --kernel --type overlay /etc")
|
machine.succeed("findmnt --kernel --type overlay /etc")
|
||||||
|
|
||||||
|
with subtest("direct symlinks point to the target without indirection"):
|
||||||
|
assert machine.succeed("readlink -n /etc/localtime") == "/etc/zoneinfo/Utc"
|
||||||
|
|
||||||
with subtest("switching to the same generation"):
|
with subtest("switching to the same generation"):
|
||||||
machine.succeed("/run/current-system/bin/switch-to-configuration test")
|
machine.succeed("/run/current-system/bin/switch-to-configuration test")
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue