* More semi-purification of /etc.
svn path=/nixos/trunk/; revision=7290
This commit is contained in:
parent
f20d572814
commit
f049c35a86
@ -72,6 +72,16 @@ mkdir -m 0755 -p /var/log
|
|||||||
ln -sf /nix/var/nix/profiles /nix/var/nix/gcroots/
|
ln -sf /nix/var/nix/profiles /nix/var/nix/gcroots/
|
||||||
|
|
||||||
|
|
||||||
|
# Set up the statically computed bits of /etc.
|
||||||
|
rm -f /etc/static
|
||||||
|
ln -s @etc@/etc /etc/static
|
||||||
|
for i in $(cd /etc/static && find * -type l); do
|
||||||
|
mkdir -p /etc/$(dirname $i)
|
||||||
|
rm -f /etc/$i
|
||||||
|
ln -s /etc/static/$i /etc/$i
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
# Ensure that the module tools can find the kernel modules.
|
# Ensure that the module tools can find the kernel modules.
|
||||||
export MODULE_DIR=@kernel@/lib/modules/
|
export MODULE_DIR=@kernel@/lib/modules/
|
||||||
|
|
||||||
@ -95,15 +105,6 @@ udevtrigger
|
|||||||
udevsettle # wait for udev to finish
|
udevsettle # wait for udev to finish
|
||||||
|
|
||||||
|
|
||||||
# Necessary configuration for syslogd.
|
|
||||||
echo "*.* /dev/tty10" > /etc/syslog.conf
|
|
||||||
echo "syslog 514/udp" > /etc/services # required, even if we don't use it
|
|
||||||
|
|
||||||
|
|
||||||
# login/su absolutely need this.
|
|
||||||
test -e /etc/login.defs || touch /etc/login.defs
|
|
||||||
|
|
||||||
|
|
||||||
# Enable a password-less root login.
|
# Enable a password-less root login.
|
||||||
source @accounts@
|
source @accounts@
|
||||||
|
|
||||||
@ -122,11 +123,6 @@ if ! test -e /etc/group; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# We need "localhost" (!!! destructive hack for NIXOS-41).
|
|
||||||
echo "127.0.0.1 localhost" > /etc/hosts
|
|
||||||
echo "hosts: files dns" > /etc/nsswitch.conf
|
|
||||||
|
|
||||||
|
|
||||||
# Set up Nix accounts.
|
# Set up Nix accounts.
|
||||||
if test -z "@readOnlyRoot@"; then
|
if test -z "@readOnlyRoot@"; then
|
||||||
|
|
||||||
@ -161,15 +157,6 @@ rm -f /etc/event.d
|
|||||||
ln -sf @upstartJobs@/etc/event.d /etc/event.d
|
ln -sf @upstartJobs@/etc/event.d /etc/event.d
|
||||||
|
|
||||||
|
|
||||||
# Show a nice greeting on each terminal.
|
|
||||||
cat > /etc/issue <<EOF
|
|
||||||
|
|
||||||
<<< Welcome to NixOS (\m) - Kernel \r (\l) >>>
|
|
||||||
|
|
||||||
|
|
||||||
EOF
|
|
||||||
|
|
||||||
|
|
||||||
# Additional path for the interactive shell.
|
# Additional path for the interactive shell.
|
||||||
PATH=@wrapperDir@:@fullPath@/bin:@fullPath@/sbin
|
PATH=@wrapperDir@:@fullPath@/bin:@fullPath@/sbin
|
||||||
|
|
||||||
@ -177,6 +164,9 @@ cat > /etc/profile <<EOF
|
|||||||
export PATH=$PATH
|
export PATH=$PATH
|
||||||
export MODULE_DIR=$MODULE_DIR
|
export MODULE_DIR=$MODULE_DIR
|
||||||
export NIX_CONF_DIR=/nix/etc/nix
|
export NIX_CONF_DIR=/nix/etc/nix
|
||||||
|
if test "\$HOME" != root; then
|
||||||
|
export NIX_REMOTE=daemon
|
||||||
|
fi
|
||||||
|
|
||||||
source $(dirname $(readlink -f $(type -tp nix-env)))/../etc/profile.d/nix.sh
|
source $(dirname $(readlink -f $(type -tp nix-env)))/../etc/profile.d/nix.sh
|
||||||
|
|
||||||
|
@ -9,6 +9,10 @@
|
|||||||
, # The Upstart job configuration.
|
, # The Upstart job configuration.
|
||||||
upstartJobs
|
upstartJobs
|
||||||
|
|
||||||
|
, # Static configuration files to be placed (through symlinks) in
|
||||||
|
# /etc.
|
||||||
|
etc
|
||||||
|
|
||||||
, hostName
|
, hostName
|
||||||
}:
|
}:
|
||||||
|
|
||||||
@ -29,7 +33,7 @@ in
|
|||||||
genericSubstituter {
|
genericSubstituter {
|
||||||
src = ./boot-stage-2-init.sh;
|
src = ./boot-stage-2-init.sh;
|
||||||
isExecutable = true;
|
isExecutable = true;
|
||||||
inherit shell kernel upstart readOnlyRoot upstartJobs hostName;
|
inherit shell kernel upstart readOnlyRoot upstartJobs etc hostName;
|
||||||
inherit startPath;
|
inherit startPath;
|
||||||
|
|
||||||
# We don't want to put all of `startPath' and `path' in $PATH, since
|
# We don't want to put all of `startPath' and `path' in $PATH, since
|
||||||
|
@ -179,6 +179,56 @@ rec {
|
|||||||
++ [pkgs.upstart];
|
++ [pkgs.upstart];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
etc = import ../helpers/make-etc.nix {
|
||||||
|
inherit (pkgs) stdenv;
|
||||||
|
|
||||||
|
configFiles = [
|
||||||
|
|
||||||
|
{ # TCP/UDP port assignments.
|
||||||
|
source = pkgs.iana_etc + "/etc/services";
|
||||||
|
target = "services";
|
||||||
|
}
|
||||||
|
|
||||||
|
{ # IP protocol numbers.
|
||||||
|
source = pkgs.iana_etc + "/etc/protocols";
|
||||||
|
target = "protocols";
|
||||||
|
}
|
||||||
|
|
||||||
|
{ # Hostname-to-IP mappings.
|
||||||
|
source = ./etc/hosts;
|
||||||
|
target = "hosts";
|
||||||
|
}
|
||||||
|
|
||||||
|
{ # Name Service Switch configuration file. Required by the C library.
|
||||||
|
source = ./etc/nsswitch.conf;
|
||||||
|
target = "nsswitch.conf";
|
||||||
|
}
|
||||||
|
|
||||||
|
{ # Configuration file for the system logging daemon.
|
||||||
|
source = ./etc/syslog.conf;
|
||||||
|
target = "syslog.conf";
|
||||||
|
}
|
||||||
|
|
||||||
|
{ # Friendly greeting on the virtual consoles.
|
||||||
|
source = ./etc/issue;
|
||||||
|
target = "issue";
|
||||||
|
}
|
||||||
|
|
||||||
|
{ # Configuration for pwdutils (login, passwd, useradd, etc.).
|
||||||
|
# You cannot login without it!
|
||||||
|
source = ./etc/login.defs;
|
||||||
|
target = "login.defs";
|
||||||
|
}
|
||||||
|
|
||||||
|
{ # SSH daemon configuration.
|
||||||
|
source = ./etc/sshd_config;
|
||||||
|
target = "ssh/sshd_config";
|
||||||
|
}
|
||||||
|
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
makeJob = import ../upstart-jobs/make-job.nix {
|
makeJob = import ../upstart-jobs/make-job.nix {
|
||||||
inherit (pkgs) stdenv;
|
inherit (pkgs) stdenv;
|
||||||
@ -198,6 +248,7 @@ rec {
|
|||||||
gnugrep utillinux kernel udev upstart;
|
gnugrep utillinux kernel udev upstart;
|
||||||
inherit setuidWrapper;
|
inherit setuidWrapper;
|
||||||
inherit upstartJobs;
|
inherit upstartJobs;
|
||||||
|
inherit etc;
|
||||||
shell = pkgs.bash + "/bin/sh";
|
shell = pkgs.bash + "/bin/sh";
|
||||||
|
|
||||||
# Additional stuff; add whatever you want here.
|
# Additional stuff; add whatever you want here.
|
||||||
|
1
configuration/etc/hosts
Normal file
1
configuration/etc/hosts
Normal file
@ -0,0 +1 @@
|
|||||||
|
127.0.0.1 localhost
|
4
configuration/etc/issue
Normal file
4
configuration/etc/issue
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
<<< Welcome to NixOS (\m) - Kernel \r (\l) >>>
|
||||||
|
|
||||||
|
|
11
configuration/etc/login.defs
Normal file
11
configuration/etc/login.defs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
DEFAULT_HOME yes
|
||||||
|
|
||||||
|
SYSTEM_UID_MIN 100
|
||||||
|
SYSTEM_UID_MAX 499
|
||||||
|
UID_MIN 1000
|
||||||
|
UID_MAX 29999
|
||||||
|
|
||||||
|
SYSTEM_GID_MIN 100
|
||||||
|
SYSTEM_GID_MAX 499
|
||||||
|
GID_MIN 1000
|
||||||
|
GID_MAX 29999
|
8
configuration/etc/nsswitch.conf
Normal file
8
configuration/etc/nsswitch.conf
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
passwd: compat
|
||||||
|
group: compat
|
||||||
|
|
||||||
|
hosts: files dns
|
||||||
|
networks: files dns
|
||||||
|
|
||||||
|
services: files
|
||||||
|
protocols: files
|
1
configuration/etc/sshd_config
Normal file
1
configuration/etc/sshd_config
Normal file
@ -0,0 +1 @@
|
|||||||
|
X11Forwarding yes
|
3
configuration/etc/syslog.conf
Normal file
3
configuration/etc/syslog.conf
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
*.* /dev/tty10
|
||||||
|
|
||||||
|
*.* -/var/log/messages
|
11
helpers/make-etc.nix
Normal file
11
helpers/make-etc.nix
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{stdenv, configFiles}:
|
||||||
|
|
||||||
|
stdenv.mkDerivation {
|
||||||
|
name = "etc";
|
||||||
|
|
||||||
|
builder = ./make-etc.sh;
|
||||||
|
|
||||||
|
/* !!! Use toXML. */
|
||||||
|
sources = map (x: x.source) configFiles;
|
||||||
|
targets = map (x: x.target) configFiles;
|
||||||
|
}
|
10
helpers/make-etc.sh
Normal file
10
helpers/make-etc.sh
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
source $stdenv/setup
|
||||||
|
|
||||||
|
ensureDir $out/etc
|
||||||
|
|
||||||
|
sources_=($sources)
|
||||||
|
targets_=($targets)
|
||||||
|
for ((i = 0; i < ${#targets_[@]}; i++)); do
|
||||||
|
ensureDir $out/etc/$(dirname ${targets_[$i]})
|
||||||
|
ln -s ${sources_[$i]} $out/etc/${targets_[$i]}
|
||||||
|
done
|
@ -16,8 +16,6 @@ start script
|
|||||||
|
|
||||||
mkdir -m 0755 -p /etc/ssh
|
mkdir -m 0755 -p /etc/ssh
|
||||||
|
|
||||||
echo 'X11Forwarding yes' > /etc/ssh/sshd_config
|
|
||||||
|
|
||||||
if ! test -f /etc/ssh/ssh_host_dsa_key; then
|
if ! test -f /etc/ssh/ssh_host_dsa_key; then
|
||||||
${openssh}/bin/ssh-keygen -t dsa -b 1024 -f /etc/ssh/ssh_host_dsa_key -N ''
|
${openssh}/bin/ssh-keygen -t dsa -b 1024 -f /etc/ssh/ssh_host_dsa_key -N ''
|
||||||
fi
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user