mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 21:50:33 +03:00
Containers: Use /etc/resolv.conf supplied by the host
This used to work with systemd-nspawn 203, because it bind-mounted /etc/resolv.conf (so openresolv couldn't overwrite it). Now it's just copied, so we need some special handling.
This commit is contained in:
parent
5c62d3d26b
commit
21573af9fb
4 changed files with 19 additions and 2 deletions
|
@ -96,8 +96,6 @@ mkdir -m 0755 -p /etc/nixos
|
||||||
|
|
||||||
# Miscellaneous boot time cleanup.
|
# Miscellaneous boot time cleanup.
|
||||||
rm -rf /var/run /var/lock
|
rm -rf /var/run /var/lock
|
||||||
rm -f /etc/resolv.conf
|
|
||||||
touch /etc/resolv.conf
|
|
||||||
rm -f /etc/{group,passwd,shadow}.lock
|
rm -f /etc/{group,passwd,shadow}.lock
|
||||||
|
|
||||||
if test -n "@cleanTmpDir@"; then
|
if test -n "@cleanTmpDir@"; then
|
||||||
|
@ -149,6 +147,12 @@ if test -n "$resumeDevice"; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Use /etc/resolv.conf supplied by systemd-nspawn, if applicable.
|
||||||
|
if [ -n "@useHostResolvConf@" -a -e /etc/resolv.conf ]; then
|
||||||
|
cat /etc/resolv.conf | resolvconf -m 1000 -a host
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Run the script that performs all configuration activation that does
|
# Run the script that performs all configuration activation that does
|
||||||
# not have to be done at boot time.
|
# not have to be done at boot time.
|
||||||
echo "running activation script..."
|
echo "running activation script..."
|
||||||
|
|
|
@ -19,11 +19,13 @@ let
|
||||||
isExecutable = true;
|
isExecutable = true;
|
||||||
inherit (config.boot) devShmSize runSize cleanTmpDir;
|
inherit (config.boot) devShmSize runSize cleanTmpDir;
|
||||||
inherit (config.nix) readOnlyStore;
|
inherit (config.nix) readOnlyStore;
|
||||||
|
inherit (config.networking) useHostResolvConf;
|
||||||
ttyGid = config.ids.gids.tty;
|
ttyGid = config.ids.gids.tty;
|
||||||
path =
|
path =
|
||||||
[ pkgs.coreutils
|
[ pkgs.coreutils
|
||||||
pkgs.utillinux
|
pkgs.utillinux
|
||||||
pkgs.sysvtools
|
pkgs.sysvtools
|
||||||
|
pkgs.openresolv
|
||||||
] ++ (optional config.boot.cleanTmpDir pkgs.findutils)
|
] ++ (optional config.boot.cleanTmpDir pkgs.findutils)
|
||||||
++ optional config.nix.readOnlyStore readonlyMountpoint;
|
++ optional config.nix.readOnlyStore readonlyMountpoint;
|
||||||
postBootCommands = pkgs.writeText "local-cmds"
|
postBootCommands = pkgs.writeText "local-cmds"
|
||||||
|
|
|
@ -191,6 +191,15 @@ in
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
networking.useHostResolvConf = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
description = ''
|
||||||
|
In containers, whether to use the
|
||||||
|
<filename>resolv.conf</filename> supplied by the host.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
networking.localCommands = mkOption {
|
networking.localCommands = mkOption {
|
||||||
default = "";
|
default = "";
|
||||||
example = "text=anything; echo You can put $text here.";
|
example = "text=anything; echo You can put $text here.";
|
||||||
|
|
|
@ -8,6 +8,8 @@ with lib;
|
||||||
|
|
||||||
sound.enable = mkDefault false;
|
sound.enable = mkDefault false;
|
||||||
|
|
||||||
|
networking.useHostResolvConf = true;
|
||||||
|
|
||||||
# Provide a login prompt on /var/lib/login.socket. On the host,
|
# Provide a login prompt on /var/lib/login.socket. On the host,
|
||||||
# you can connect to it by running ‘socat
|
# you can connect to it by running ‘socat
|
||||||
# unix:<path-to-container>/var/lib/login.socket -,echo=0,raw’.
|
# unix:<path-to-container>/var/lib/login.socket -,echo=0,raw’.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue