Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 183919a0c072
Choose a base ref
...
head repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 0b91fa43e40c
Choose a head ref
  • 5 commits
  • 3 files changed
  • 3 contributors

Commits on Jan 31, 2019

  1. nixos/etc: Make symlinks relative instead of absolute

    so that the links can be followed if the NixOS installation is not mounted as filesystem root.
    In particular, this makes /etc/os-release adhere to the standard:
    https://www.freedesktop.org/software/systemd/man/os-release.html
    Fixes #28833.
    florianjacob authored and danbst committed Jan 31, 2019

    Verified

    This commit was signed with the committer’s verified signature.
    dywedir Vlad M.
    Copy the full SHA
    fc8e174 View commit details
  2. Copy the full SHA
    f47bfce View commit details
  3. this is not related to this PR

    danbst committed Jan 31, 2019
    Copy the full SHA
    fd807c6 View commit details
  4. 🤦

    danbst committed Jan 31, 2019
    Copy the full SHA
    3ae5420 View commit details

Commits on Feb 21, 2019

  1. Merge pull request #54980 from danbst/etc-relative

    nixos: make symlinks in `/etc` relative (except `/etc/static`)
    7c6f434c authored Feb 21, 2019
    Copy the full SHA
    0b91fa4 View commit details
Showing with 41 additions and 7 deletions.
  1. +14 −0 nixos/doc/manual/release-notes/rl-1903.xml
  2. +10 −5 nixos/modules/system/etc/make-etc.sh
  3. +17 −2 nixos/modules/system/etc/setup-etc.pl
14 changes: 14 additions & 0 deletions nixos/doc/manual/release-notes/rl-1903.xml
Original file line number Diff line number Diff line change
@@ -535,6 +535,20 @@
use <literal>nixos-rebuild boot; reboot</literal>.
</para>
</listitem>
<listitem>
<para>
Symlinks in <filename>/etc</filename> (except <filename>/etc/static</filename>)
are now relative instead of absolute. This makes possible to examine
NixOS container's <filename>/etc</filename> directory from host system
(previously it pointed to host <filename>/etc</filename> when viewed from host,
and to container <filename>/etc</filename> when viewed from container chroot).
</para>
<para>
This also makes <filename>/etc/os-release</filename> adhere to
<link xlink:href="https://www.freedesktop.org/software/systemd/man/os-release.html">the standard</link>
for NixOS containers.
</para>
</listitem>
<listitem>
<para>
Flat volumes are now disabled by default in <literal>hardware.pulseaudio</literal>.
15 changes: 10 additions & 5 deletions nixos/modules/system/etc/make-etc.sh
Original file line number Diff line number Diff line change
@@ -10,6 +10,11 @@ users_=($users)
groups_=($groups)
set +f

# Create relative symlinks, so that the links can be followed if
# the NixOS installation is not mounted as filesystem root.
# Absolute symlinks violate the os-release format
# at https://www.freedesktop.org/software/systemd/man/os-release.html
# and break e.g. systemd-nspawn and os-prober.
for ((i = 0; i < ${#targets_[@]}; i++)); do
source="${sources_[$i]}"
target="${targets_[$i]}"
@@ -19,28 +24,28 @@ for ((i = 0; i < ${#targets_[@]}; i++)); do
# If the source name contains '*', perform globbing.
mkdir -p $out/etc/$target
for fn in $source; do
ln -s "$fn" $out/etc/$target/
ln -s --relative "$fn" $out/etc/$target/
done

else

mkdir -p $out/etc/$(dirname $target)
if ! [ -e $out/etc/$target ]; then
ln -s $source $out/etc/$target
ln -s --relative $source $out/etc/$target
else
echo "duplicate entry $target -> $source"
if test "$(readlink $out/etc/$target)" != "$source"; then
echo "mismatched duplicate entry $(readlink $out/etc/$target) <-> $source"
exit 1
fi
fi

if test "${modes_[$i]}" != symlink; then
echo "${modes_[$i]}" > $out/etc/$target.mode
echo "${users_[$i]}" > $out/etc/$target.uid
echo "${groups_[$i]}" > $out/etc/$target.gid
fi

fi
done

19 changes: 17 additions & 2 deletions nixos/modules/system/etc/setup-etc.pl
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
use File::Path;
use File::Basename;
use File::Slurp;
use File::Spec;

my $etc = $ARGV[0] or die;
my $static = "/etc/static";
@@ -17,6 +18,20 @@ sub atomicSymlink {
return 1;
}

# Create relative symlinks, so that the links can be followed if
# the NixOS installation is not mounted as filesystem root.
# Absolute symlinks violate the os-release format
# at https://www.freedesktop.org/software/systemd/man/os-release.html
# and break e.g. systemd-nspawn and os-prober.
sub atomicRelativeSymlink {
my ($source, $target) = @_;
my $tmp = "$target.tmp";
unlink $tmp;
my $rel = File::Spec->abs2rel($source, dirname $target);
symlink $rel, $tmp or return 0;
rename $tmp, $target or return 0;
return 1;
}

# Atomically update /etc/static to point at the etc files of the
# current configuration.
@@ -103,7 +118,7 @@ sub link {
if (-e "$_.mode") {
my $mode = read_file("$_.mode"); chomp $mode;
if ($mode eq "direct-symlink") {
atomicSymlink readlink("$static/$fn"), $target or warn;
atomicRelativeSymlink readlink("$static/$fn"), $target or warn;
} else {
my $uid = read_file("$_.uid"); chomp $uid;
my $gid = read_file("$_.gid"); chomp $gid;
@@ -117,7 +132,7 @@ sub link {
push @copied, $fn;
print CLEAN "$fn\n";
} elsif (-l "$_") {
atomicSymlink "$static/$fn", $target or warn;
atomicRelativeSymlink "$static/$fn", $target or warn;
}
}