mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-14 06:00:33 +03:00
Merge staging into closure-size
The most complex problems were from dealing with switches reverted in the meantime (gcc5, gmp6, ncurses6). It's likely that darwin is (still) broken nontrivially.
This commit is contained in:
commit
333d69a5f0
1278 changed files with 105731 additions and 30012 deletions
149
nixos/modules/system/boot/initrd-network.nix
Normal file
149
nixos/modules/system/boot/initrd-network.nix
Normal file
|
@ -0,0 +1,149 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.boot.initrd.network;
|
||||
|
||||
in
|
||||
{
|
||||
|
||||
options = {
|
||||
|
||||
boot.initrd.network.enable = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
Add network connectivity support to initrd.
|
||||
|
||||
Network options are configured via <literal>ip</literal> kernel
|
||||
option, according to the kernel documentation.
|
||||
'';
|
||||
};
|
||||
|
||||
boot.initrd.network.ssh.enable = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
Start SSH service during initrd boot. It can be used to debug failing
|
||||
boot on a remote server, enter pasphrase for an encrypted partition etc.
|
||||
Service is killed when stage-1 boot is finished.
|
||||
'';
|
||||
};
|
||||
|
||||
boot.initrd.network.ssh.port = mkOption {
|
||||
type = types.int;
|
||||
default = 22;
|
||||
description = ''
|
||||
Port on which SSH initrd service should listen.
|
||||
'';
|
||||
};
|
||||
|
||||
boot.initrd.network.ssh.shell = mkOption {
|
||||
type = types.str;
|
||||
default = "/bin/ash";
|
||||
description = ''
|
||||
Login shell of the remote user. Can be used to limit actions user can do.
|
||||
'';
|
||||
};
|
||||
|
||||
boot.initrd.network.ssh.hostRSAKey = mkOption {
|
||||
type = types.nullOr types.path;
|
||||
default = null;
|
||||
description = ''
|
||||
RSA SSH private key file in the Dropbear format.
|
||||
|
||||
WARNING: This key is contained insecurely in the global Nix store. Do NOT
|
||||
use your regular SSH host private keys for this purpose or you'll expose
|
||||
them to regular users!
|
||||
'';
|
||||
};
|
||||
|
||||
boot.initrd.network.ssh.hostDSSKey = mkOption {
|
||||
type = types.nullOr types.path;
|
||||
default = null;
|
||||
description = ''
|
||||
DSS SSH private key file in the Dropbear format.
|
||||
|
||||
WARNING: This key is contained insecurely in the global Nix store. Do NOT
|
||||
use your regular SSH host private keys for this purpose or you'll expose
|
||||
them to regular users!
|
||||
'';
|
||||
};
|
||||
|
||||
boot.initrd.network.ssh.hostECDSAKey = mkOption {
|
||||
type = types.nullOr types.path;
|
||||
default = null;
|
||||
description = ''
|
||||
ECDSA SSH private key file in the Dropbear format.
|
||||
|
||||
WARNING: This key is contained insecurely in the global Nix store. Do NOT
|
||||
use your regular SSH host private keys for this purpose or you'll expose
|
||||
them to regular users!
|
||||
'';
|
||||
};
|
||||
|
||||
boot.initrd.network.ssh.authorizedKeys = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = config.users.extraUsers.root.openssh.authorizedKeys.keys;
|
||||
description = ''
|
||||
Authorized keys for the root user on initrd.
|
||||
'';
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
|
||||
boot.initrd.kernelModules = [ "af_packet" ];
|
||||
|
||||
boot.initrd.extraUtilsCommands = ''
|
||||
copy_bin_and_libs ${pkgs.mkinitcpio-nfs-utils}/bin/ipconfig
|
||||
'' + optionalString cfg.ssh.enable ''
|
||||
copy_bin_and_libs ${pkgs.dropbear}/bin/dropbear
|
||||
|
||||
cp -pv ${pkgs.glibc}/lib/libnss_files.so.* $out/lib
|
||||
'';
|
||||
|
||||
boot.initrd.extraUtilsCommandsTest = optionalString cfg.ssh.enable ''
|
||||
$out/bin/dropbear -V
|
||||
'';
|
||||
|
||||
boot.initrd.postEarlyDeviceCommands = ''
|
||||
# Search for interface definitions in command line
|
||||
for o in $(cat /proc/cmdline); do
|
||||
case $o in
|
||||
ip=*)
|
||||
ipconfig $o && hasNetwork=1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
'' + optionalString cfg.ssh.enable ''
|
||||
if [ -n "$hasNetwork" ]; then
|
||||
mkdir /dev/pts
|
||||
mount -t devpts devpts /dev/pts
|
||||
|
||||
mkdir -p /etc
|
||||
echo 'root:x:0:0:root:/root:${cfg.ssh.shell}' > /etc/passwd
|
||||
echo '${cfg.ssh.shell}' > /etc/shells
|
||||
echo 'passwd: files' > /etc/nsswitch.conf
|
||||
|
||||
mkdir -p /var/log
|
||||
touch /var/log/lastlog
|
||||
|
||||
mkdir -p /etc/dropbear
|
||||
${optionalString (cfg.ssh.hostRSAKey != null) "ln -s ${cfg.ssh.hostRSAKey} /etc/dropbear/dropbear_rsa_host_key"}
|
||||
${optionalString (cfg.ssh.hostDSSKey != null) "ln -s ${cfg.ssh.hostDSSKey} /etc/dropbear/dropbear_dss_host_key"}
|
||||
${optionalString (cfg.ssh.hostECDSAKey != null) "ln -s ${cfg.ssh.hostECDSAKey} /etc/dropbear/dropbear_ecdsa_host_key"}
|
||||
|
||||
mkdir -p /root/.ssh
|
||||
${concatStrings (map (key: ''
|
||||
echo -n ${escapeShellArg key} >> /root/.ssh/authorized_keys
|
||||
'') cfg.ssh.authorizedKeys)}
|
||||
|
||||
dropbear -s -j -k -E -m -p ${toString cfg.ssh.port}
|
||||
fi
|
||||
'';
|
||||
|
||||
};
|
||||
}
|
|
@ -378,6 +378,17 @@ in
|
|||
'';
|
||||
};
|
||||
|
||||
systemHasTPM = mkOption {
|
||||
default = "";
|
||||
example = "YES_TPM_is_activated";
|
||||
type = types.string;
|
||||
description = ''
|
||||
Assertion that the target system has an activated TPM. It is a safety
|
||||
check before allowing the activation of 'enableTrustedBoot'. TrustedBoot
|
||||
WILL FAIL TO BOOT YOUR SYSTEM if no TPM is available.
|
||||
'';
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
@ -453,8 +464,8 @@ in
|
|||
message = "Trusted GRUB does not have ZFS support";
|
||||
}
|
||||
{
|
||||
assertion = !cfg.enableTrustedBoot;
|
||||
message = "Trusted GRUB can break your system. Remove assertion if you want to test trustedGRUB nevertheless.";
|
||||
assertion = !cfg.enableTrustedBoot || cfg.systemHasTPM == "YES_TPM_is_activated";
|
||||
message = "Trusted GRUB can break the system! Confirm that the system has an activated TPM by setting 'systemHasTPM'.";
|
||||
}
|
||||
] ++ flip concatMap cfg.mirroredBoots (args: [
|
||||
{
|
||||
|
@ -477,4 +488,15 @@ in
|
|||
|
||||
];
|
||||
|
||||
|
||||
imports =
|
||||
[ (mkRemovedOptionModule [ "boot" "loader" "grub" "bootDevice" ])
|
||||
(mkRenamedOptionModule [ "boot" "copyKernels" ] [ "boot" "loader" "grub" "copyKernels" ])
|
||||
(mkRenamedOptionModule [ "boot" "extraGrubEntries" ] [ "boot" "loader" "grub" "extraEntries" ])
|
||||
(mkRenamedOptionModule [ "boot" "extraGrubEntriesBeforeNixos" ] [ "boot" "loader" "grub" "extraEntriesBeforeNixOS" ])
|
||||
(mkRenamedOptionModule [ "boot" "grubDevice" ] [ "boot" "loader" "grub" "device" ])
|
||||
(mkRenamedOptionModule [ "boot" "bootMount" ] [ "boot" "loader" "grub" "bootDevice" ])
|
||||
(mkRenamedOptionModule [ "boot" "grubSplashImage" ] [ "boot" "loader" "grub" "splashImage" ])
|
||||
];
|
||||
|
||||
}
|
||||
|
|
|
@ -32,9 +32,12 @@ let
|
|||
''}
|
||||
|
||||
open_normally() {
|
||||
cryptsetup luksOpen ${device} ${name} ${optionalString allowDiscards "--allow-discards"} \
|
||||
echo luksOpen ${device} ${name} ${optionalString allowDiscards "--allow-discards"} \
|
||||
${optionalString (header != null) "--header=${header}"} \
|
||||
${optionalString (keyFile != null) "--key-file=${keyFile} ${optionalString (keyFileSize != null) "--keyfile-size=${toString keyFileSize}"}"}
|
||||
${optionalString (keyFile != null) "--key-file=${keyFile} ${optionalString (keyFileSize != null) "--keyfile-size=${toString keyFileSize}"}"} \
|
||||
> /.luksopen_args
|
||||
cryptsetup-askpass
|
||||
rm /.luksopen_args
|
||||
}
|
||||
|
||||
${optionalString (luks.yubikeySupport && (yubikey != null)) ''
|
||||
|
@ -418,6 +421,18 @@ in
|
|||
boot.initrd.extraUtilsCommands = ''
|
||||
copy_bin_and_libs ${pkgs.cryptsetup}/bin/cryptsetup
|
||||
|
||||
cat > $out/bin/cryptsetup-askpass <<EOF
|
||||
#!$out/bin/sh -e
|
||||
if [ -e /.luksopen_args ]; then
|
||||
cryptsetup \$(cat /.luksopen_args)
|
||||
killall cryptsetup
|
||||
else
|
||||
echo "Passphrase is not requested now"
|
||||
exit 1
|
||||
fi
|
||||
EOF
|
||||
chmod +x $out/bin/cryptsetup-askpass
|
||||
|
||||
${optionalString luks.yubikeySupport ''
|
||||
copy_bin_and_libs ${pkgs.ykpers}/bin/ykchalresp
|
||||
copy_bin_and_libs ${pkgs.ykpers}/bin/ykinfo
|
||||
|
@ -432,6 +447,8 @@ in
|
|||
|
||||
cat > $out/bin/openssl-wrap <<EOF
|
||||
#!$out/bin/sh
|
||||
export OPENSSL_CONF=$out/etc/ssl/openssl.cnf
|
||||
$out/bin/openssl "\$@"
|
||||
EOF
|
||||
chmod +x $out/bin/openssl-wrap
|
||||
''}
|
||||
|
@ -442,11 +459,6 @@ in
|
|||
${optionalString luks.yubikeySupport ''
|
||||
$out/bin/ykchalresp -V
|
||||
$out/bin/ykinfo -V
|
||||
cat > $out/bin/openssl-wrap <<EOF
|
||||
#!$out/bin/sh
|
||||
export OPENSSL_CONF=$out/etc/ssl/openssl.cnf
|
||||
$out/bin/openssl "\$@"
|
||||
EOF
|
||||
$out/bin/openssl-wrap version
|
||||
''}
|
||||
'';
|
||||
|
|
|
@ -149,6 +149,10 @@ udevadm trigger --action=add
|
|||
udevadm settle
|
||||
|
||||
|
||||
# Additional devices initialization.
|
||||
@postEarlyDeviceCommands@
|
||||
|
||||
|
||||
# Load boot-time keymap before any LVM/LUKS initialization
|
||||
@extraUtils@/bin/busybox loadkmap < "@busyboxKeymap@"
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ let
|
|||
stripDirs "lib bin" "-s"
|
||||
|
||||
# Run patchelf to make the programs refer to the copied libraries.
|
||||
for i in $out/bin/* $out/lib/*; do if ! test -L $i; then nuke-refs $i; fi; done
|
||||
for i in $out/bin/* $out/lib/*; do if ! test -L $i; then nuke-refs -e $out $i; fi; done
|
||||
|
||||
for i in $out/bin/*; do
|
||||
if ! test -L $i; then
|
||||
|
@ -203,10 +203,10 @@ let
|
|||
inherit (config.boot) resumeDevice devSize runSize;
|
||||
|
||||
inherit (config.boot.initrd) checkJournalingFS
|
||||
preLVMCommands postDeviceCommands postMountCommands kernelModules;
|
||||
postEarlyDeviceCommands preLVMCommands postDeviceCommands postMountCommands kernelModules;
|
||||
|
||||
resumeDevices = map (sd: if sd ? device then sd.device else "/dev/disk/by-label/${sd.label}")
|
||||
(filter (sd: sd ? label || hasPrefix "/dev/" sd.device) config.swapDevices);
|
||||
(filter (sd: (sd ? label || hasPrefix "/dev/" sd.device) && !sd.randomEncryption) config.swapDevices);
|
||||
|
||||
fsInfo =
|
||||
let f = fs: [ fs.mountPoint (if fs.device != null then fs.device else "/dev/disk/by-label/${fs.label}") fs.fsType fs.options ];
|
||||
|
@ -313,6 +313,14 @@ in
|
|||
'';
|
||||
};
|
||||
|
||||
boot.initrd.postEarlyDeviceCommands = mkOption {
|
||||
default = "";
|
||||
type = types.lines;
|
||||
description = ''
|
||||
Shell commands to be executed early after creation of device nodes.
|
||||
'';
|
||||
};
|
||||
|
||||
boot.initrd.postMountCommands = mkOption {
|
||||
default = "";
|
||||
type = types.lines;
|
||||
|
|
|
@ -100,7 +100,7 @@ let
|
|||
# Maintaining state across reboots.
|
||||
"systemd-random-seed.service"
|
||||
"systemd-backlight@.service"
|
||||
"systemd-rfkill@.service"
|
||||
"systemd-rfkill.service"
|
||||
|
||||
# Hibernate / suspend.
|
||||
"hibernate.target"
|
||||
|
@ -770,4 +770,11 @@ in
|
|||
|
||||
};
|
||||
|
||||
# FIXME: Remove these eventually.
|
||||
imports =
|
||||
[ (mkRenamedOptionModule [ "boot" "systemd" "sockets" ] [ "systemd" "sockets" ])
|
||||
(mkRenamedOptionModule [ "boot" "systemd" "targets" ] [ "systemd" "targets" ])
|
||||
(mkRenamedOptionModule [ "boot" "systemd" "services" ] [ "systemd" "services" ])
|
||||
];
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue