Merge branch 'plymouth' into staging

This commit is contained in:
Nikolay Amiantov 2016-07-13 03:54:38 +03:00
commit 1848bfc92d
9 changed files with 207 additions and 34 deletions

View File

@ -525,6 +525,7 @@
./system/boot/luksroot.nix ./system/boot/luksroot.nix
./system/boot/modprobe.nix ./system/boot/modprobe.nix
./system/boot/networkd.nix ./system/boot/networkd.nix
./system/boot/plymouth.nix
./system/boot/resolved.nix ./system/boot/resolved.nix
./system/boot/shutdown.nix ./system/boot/shutdown.nix
./system/boot/stage-1.nix ./system/boot/stage-1.nix

View File

@ -100,9 +100,6 @@ in
''; '';
boot.initrd.network.postCommands = '' boot.initrd.network.postCommands = ''
mkdir /dev/pts
mount -t devpts devpts /dev/pts
echo '${cfg.shell}' > /etc/shells echo '${cfg.shell}' > /etc/shells
echo 'root:x:0:0:root:/root:${cfg.shell}' > /etc/passwd echo 'root:x:0:0:root:/root:${cfg.shell}' > /etc/passwd
echo 'passwd: files' > /etc/nsswitch.conf echo 'passwd: files' > /etc/nsswitch.conf

View File

@ -36,7 +36,7 @@ let
${optionalString (header != null) "--header=${header}"} \ ${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 > /.luksopen_args
cryptsetup-askpass get_password "Enter LUKS Passphrase" cryptsetup-askpass
rm /.luksopen_args rm /.luksopen_args
} }
@ -78,9 +78,7 @@ let
for try in $(seq 3); do for try in $(seq 3); do
${optionalString yubikey.twoFactor '' ${optionalString yubikey.twoFactor ''
echo -n "Enter two-factor passphrase: " k_user="$(get_password "Enter two-factor passphrase" cat)"
read -s k_user
echo
''} ''}
if [ ! -z "$k_user" ]; then if [ ! -z "$k_user" ]; then
@ -463,6 +461,26 @@ in
''} ''}
''; '';
boot.initrd.preDeviceCommands = ''
get_password() {
local ret
local reply
local tty_stat
tty_stat="$(stty -g)"
stty -echo
for i in `seq 1 3`; do
echo -n "$1: "
read reply
echo "$reply" | "$2"
if [ "$?" = "0" ]; then
break
fi
done
stty "$tty_stat"
}
'';
boot.initrd.preLVMCommands = concatStrings (mapAttrsToList openCommand preLVM); boot.initrd.preLVMCommands = concatStrings (mapAttrsToList openCommand preLVM);
boot.initrd.postDeviceCommands = concatStrings (mapAttrsToList openCommand postLVM); boot.initrd.postDeviceCommands = concatStrings (mapAttrsToList openCommand postLVM);

View File

@ -0,0 +1,129 @@
{ config, lib, pkgs, ... }:
with lib;
let
inherit (pkgs) plymouth;
cfg = config.boot.plymouth;
themesEnv = pkgs.buildEnv {
name = "plymouth-themes";
paths = [ plymouth ] ++ cfg.themePackages;
};
configFile = pkgs.writeText "plymouthd.conf" ''
[Daemon]
ShowDelay=0
Theme=${cfg.theme}
'';
in
{
options = {
boot.plymouth = {
enable = mkEnableOption "Plymouth boot splash screen";
themePackages = mkOption {
default = [];
type = types.listOf types.package;
description = ''
Extra theme packages for plymouth.
'';
};
theme = mkOption {
default = "fade-in";
type = types.str;
description = ''
Splash screen theme.
'';
};
logo = mkOption {
type = types.path;
default = pkgs.fetchurl {
url = "https://nixos.org/logo/nixos-hires.png";
sha256 = "1ivzgd7iz0i06y36p8m5w48fd8pjqwxhdaavc0pxs7w1g7mcy5si";
};
description = ''
Logo which is displayed on the splash screen.
'';
};
};
};
config = mkIf cfg.enable {
boot.kernelParams = [ "splash" ];
# To be discoverable by systemd.
environment.systemPackages = [ plymouth ];
environment.etc."plymouth/plymouthd.conf".source = configFile;
environment.etc."plymouth/plymouthd.defaults".source = "${plymouth}/share/plymouth/plymouth.defaults";
environment.etc."plymouth/logo.png".source = cfg.logo;
environment.etc."plymouth/themes".source = "${themesEnv}/share/plymouth/themes";
# XXX: Needed because we supply a different set of plugins in initrd.
environment.etc."plymouth/plugins".source = "${plymouth}/lib/plymouth";
systemd.packages = [ plymouth ];
systemd.services.plymouth-kexec.wantedBy = [ "kexec.target" ];
systemd.services.plymouth-halt.wantedBy = [ "halt.target" ];
systemd.services.plymouth-quit = {
wantedBy = [ "multi-user.target" ];
after = [ "display-manager.service" "multi-user.target" ];
};
systemd.services.plymouth-poweroff.wantedBy = [ "poweroff.target" ];
systemd.services.plymouth-reboot.wantedBy = [ "reboot.target" ];
systemd.services.plymouth-read-write.wantedBy = [ "sysinit.target" ];
boot.initrd.extraUtilsCommands = ''
copy_bin_and_libs ${pkgs.plymouth}/bin/plymouthd
copy_bin_and_libs ${pkgs.plymouth}/bin/plymouth
moduleName="$(sed -n 's,ModuleName *= *,,p' ${themesEnv}/share/plymouth/themes/${cfg.theme}/${cfg.theme}.plymouth)"
mkdir -p $out/lib/plymouth/renderers
cp ${plymouth}/lib/plymouth/{text,details,$moduleName}.so $out/lib/plymouth
cp ${plymouth}/lib/plymouth/renderers/{drm,frame-buffer}.so $out/lib/plymouth/renderers
mkdir -p $out/share/plymouth/themes
cp ${plymouth}/share/plymouth/plymouthd.defaults $out/share/plymouth
cp -r ${themesEnv}/share/plymouth/themes/{text,details,${cfg.theme}} $out/share/plymouth/themes
cp ${cfg.logo} $out/share/plymouth/logo.png
'';
boot.initrd.extraUtilsCommandsTest = ''
$out/bin/plymouthd --help >/dev/null
$out/bin/plymouth --help >/dev/null
'';
boot.initrd.extraUdevRulesCommands = ''
cp ${config.systemd.package}/lib/udev/rules.d/{70-uaccess,71-seat}.rules $out
sed -i '/loginctl/d' $out/71-seat.rules
'';
boot.initrd.preLVMCommands = mkAfter ''
mkdir -p /etc/plymouth
ln -s ${configFile} /etc/plymouth/plymouthd.conf
ln -s $extraUtils/share/plymouth/plymouthd.defaults /etc/plymouth/plymouthd.defaults
ln -s $extraUtils/share/plymouth/logo.png /etc/plymouth/logo.png
ln -s $extraUtils/share/plymouth/themes /etc/plymouth/themes
ln -s $extraUtils/lib/plymouth /etc/plymouth/plugins
plymouthd --mode=boot --pid-file=/run/plymouth/pid --attach-to-session
plymouth --show-splash
'';
};
}

View File

@ -3,6 +3,7 @@
targetRoot=/mnt-root targetRoot=/mnt-root
console=tty1 console=tty1
extraUtils="@extraUtils@"
export LD_LIBRARY_PATH=@extraUtils@/lib export LD_LIBRARY_PATH=@extraUtils@/lib
export PATH=@extraUtils@/bin export PATH=@extraUtils@/bin
ln -s @extraUtils@/bin /bin ln -s @extraUtils@/bin /bin
@ -13,6 +14,9 @@ export LVM_SUPPRESS_FD_WARNINGS=true
fail() { fail() {
if [ -n "$panicOnFail" ]; then exit 1; fi if [ -n "$panicOnFail" ]; then exit 1; fi
# If we have a splash screen started, quit it.
command -v plymouth >/dev/null 2>&1 && plymouth quit
# If starting stage 2 failed, allow the user to repair the problem # If starting stage 2 failed, allow the user to repair the problem
# in an interactive shell. # in an interactive shell.
cat <<EOF cat <<EOF
@ -70,6 +74,8 @@ mount -t sysfs sysfs /sys
mount -t devtmpfs -o "size=@devSize@" devtmpfs /dev mount -t devtmpfs -o "size=@devSize@" devtmpfs /dev
mkdir -p /run mkdir -p /run
mount -t tmpfs -o "mode=0755,size=@runSize@" tmpfs /run mount -t tmpfs -o "mode=0755,size=@runSize@" tmpfs /run
mkdir /dev/pts
mount -t devpts devpts /dev/pts
# Log the script output to /dev/kmsg or /run/log/stage-1-init.log. # Log the script output to /dev/kmsg or /run/log/stage-1-init.log.
mkdir -p /tmp mkdir -p /tmp

View File

@ -81,9 +81,9 @@ let
# Copy ld manually since it isn't detected correctly # Copy ld manually since it isn't detected correctly
cp -pv ${pkgs.glibc.out}/lib/ld*.so.? $out/lib cp -pv ${pkgs.glibc.out}/lib/ld*.so.? $out/lib
# Copy all of the needed libraries for the binaries # Copy all of the needed libraries
for BIN in $(find $out/{bin,sbin} -type f); do find $out/bin $out/lib -type f | while read BIN; do
echo "Copying libs for bin $BIN" echo "Copying libs for executable $BIN"
LDD="$(ldd $BIN)" || continue LDD="$(ldd $BIN)" || continue
LIBS="$(echo "$LDD" | awk '{print $3}' | sed '/^$/d')" LIBS="$(echo "$LDD" | awk '{print $3}' | sed '/^$/d')"
for LIB in $LIBS; do for LIB in $LIBS; do
@ -104,13 +104,17 @@ let
stripDirs "lib bin" "-s" stripDirs "lib bin" "-s"
# Run patchelf to make the programs refer to the copied libraries. # 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 -e $out $i; fi; done find $out/bin $out/lib -type f | while read i; do
if ! test -L $i; then
nuke-refs -e $out $i
fi
done
for i in $out/bin/*; do find $out/bin -type f | while read i; do
if ! test -L $i; then if ! test -L $i; then
echo "patching $i..." echo "patching $i..."
patchelf --set-interpreter $out/lib/ld*.so.? --set-rpath $out/lib $i || true patchelf --set-interpreter $out/lib/ld*.so.? --set-rpath $out/lib $i || true
fi fi
done done
# Make sure that the patchelf'ed binaries still work. # Make sure that the patchelf'ed binaries still work.
@ -138,6 +142,7 @@ let
udevRules = pkgs.stdenv.mkDerivation { udevRules = pkgs.stdenv.mkDerivation {
name = "udev-rules"; name = "udev-rules";
allowedReferences = [ extraUtils ];
buildCommand = '' buildCommand = ''
mkdir -p $out mkdir -p $out
@ -160,7 +165,8 @@ let
--replace /sbin/mdadm ${extraUtils}/bin/mdadm \ --replace /sbin/mdadm ${extraUtils}/bin/mdadm \
--replace /bin/sh ${extraUtils}/bin/sh \ --replace /bin/sh ${extraUtils}/bin/sh \
--replace /usr/bin/readlink ${extraUtils}/bin/readlink \ --replace /usr/bin/readlink ${extraUtils}/bin/readlink \
--replace /usr/bin/basename ${extraUtils}/bin/basename --replace /usr/bin/basename ${extraUtils}/bin/basename \
--replace ${udev}/bin/udevadm ${extraUtils}/bin/udevadm
done done
# Work around a bug in QEMU, which doesn't implement the "READ # Work around a bug in QEMU, which doesn't implement the "READ

View File

@ -1,6 +1,6 @@
{ stdenv, fetchurl, pkgconfig, glib, itstool, libxml2, xorg, dbus { stdenv, fetchurl, pkgconfig, glib, itstool, libxml2, xorg, dbus
, intltool, accountsservice, libX11, gnome3, systemd, gnome_session, autoreconfHook , intltool, accountsservice, libX11, gnome3, systemd, gnome_session, autoreconfHook
, gtk, libcanberra_gtk3, pam, libtool, gobjectIntrospection }: , gtk, libcanberra_gtk3, pam, libtool, gobjectIntrospection, plymouth }:
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
inherit (import ./src.nix fetchurl) name src; inherit (import ./src.nix fetchurl) name src;
@ -13,12 +13,13 @@ stdenv.mkDerivation rec {
configureFlags = [ "--sysconfdir=/etc" configureFlags = [ "--sysconfdir=/etc"
"--localstatedir=/var" "--localstatedir=/var"
"--with-systemd=yes" "--with-systemd=yes"
"--with-plymouth=yes"
"--with-systemdsystemunitdir=$(out)/etc/systemd/system" ]; "--with-systemdsystemunitdir=$(out)/etc/systemd/system" ];
buildInputs = [ pkgconfig glib itstool libxml2 intltool autoreconfHook buildInputs = [ pkgconfig glib itstool libxml2 intltool autoreconfHook
accountsservice gnome3.dconf systemd accountsservice gnome3.dconf systemd
gobjectIntrospection libX11 gtk gobjectIntrospection libX11 gtk
libcanberra_gtk3 pam libtool ]; libcanberra_gtk3 pam libtool plymouth ];
#enableParallelBuilding = true; # problems compiling #enableParallelBuilding = true; # problems compiling

View File

@ -1,6 +1,6 @@
{ stdenv, fetchurl, pkgconfig, glib, itstool, libxml2, xorg, dbus { stdenv, fetchurl, pkgconfig, glib, itstool, libxml2, xorg, dbus
, intltool, accountsservice, libX11, gnome3, systemd, gnome_session, autoreconfHook , intltool, accountsservice, libX11, gnome3, systemd, gnome_session, autoreconfHook
, gtk, libcanberra_gtk3, pam, libtool, gobjectIntrospection }: , gtk, libcanberra_gtk3, pam, libtool, gobjectIntrospection, plymouth }:
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
inherit (import ./src.nix fetchurl) name src; inherit (import ./src.nix fetchurl) name src;
@ -13,12 +13,13 @@ stdenv.mkDerivation rec {
configureFlags = [ "--sysconfdir=/etc" configureFlags = [ "--sysconfdir=/etc"
"--localstatedir=/var" "--localstatedir=/var"
"--with-systemd=yes" "--with-systemd=yes"
"--with-plymouth=yes"
"--with-systemdsystemunitdir=$(out)/etc/systemd/system" ]; "--with-systemdsystemunitdir=$(out)/etc/systemd/system" ];
buildInputs = [ pkgconfig glib itstool libxml2 intltool autoreconfHook buildInputs = [ pkgconfig glib itstool libxml2 intltool autoreconfHook
accountsservice gnome3.dconf systemd accountsservice gnome3.dconf systemd
gobjectIntrospection libX11 gtk gobjectIntrospection libX11 gtk
libcanberra_gtk3 pam libtool ]; libcanberra_gtk3 pam libtool plymouth ];
#enableParallelBuilding = true; # problems compiling #enableParallelBuilding = true; # problems compiling

View File

@ -1,27 +1,32 @@
{ stdenv, fetchurl, autoreconfHook, cairo, docbook_xsl, gtk { stdenv, fetchurl, autoreconfHook, pkgconfig, libxslt, docbook_xsl
, libdrm, libpng, libxslt, makeWrapper, pango, pkgconfig, udev , gtk3, udev, systemd
}: }:
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
name = "plymouth-${version}"; name = "plymouth-${version}";
version = "0.9.0"; version = "0.9.2";
src = fetchurl { src = fetchurl {
url = "http://www.freedesktop.org/software/plymouth/releases/${name}.tar.bz2"; url = "http://www.freedesktop.org/software/plymouth/releases/${name}.tar.bz2";
sha256 = "0kfdwv179brg390ma003pmdqfvqlbybqiyp9fxrxx0wa19sjxqnk"; sha256 = "0zympsgy5bbfl2ag5nc1jxlshpx8r1s1yyjisanpx76g88hfh31g";
}; };
buildInputs = [ nativeBuildInputs = [
autoreconfHook cairo docbook_xsl gtk libdrm libpng autoreconfHook pkgconfig libxslt docbook_xsl
libxslt makeWrapper pango pkgconfig udev
]; ];
prePatch = '' buildInputs = [
sed -e "s#\$(\$PKG_CONFIG --variable=systemdsystemunitdir systemd)#$out/etc/systemd/system#g" \ gtk3 udev systemd
-i configure.ac ];
'';
postPatch = '' postPatch = ''
sed -i \
-e "s#\$(\$PKG_CONFIG --variable=systemdsystemunitdir systemd)#$out/etc/systemd/system#g" \
-e "s#plymouthplugindir=.*#plymouthplugindir=/etc/plymouth/plugins/#" \
-e "s#plymouththemedir=.*#plymouththemedir=/etc/plymouth/themes#" \
-e "s#plymouthpolicydir=.*#plymouthpolicydir=/etc/plymouth/#" \
configure.ac
configureFlags=" configureFlags="
--prefix=$out --prefix=$out
--bindir=$out/bin --bindir=$out/bin
@ -29,15 +34,24 @@ stdenv.mkDerivation rec {
--exec-prefix=$out --exec-prefix=$out
--libdir=$out/lib --libdir=$out/lib
--libexecdir=$out/lib --libexecdir=$out/lib
--sysconfdir=$out/etc --sysconfdir=/etc
--localstatedir=/var --localstatedir=/var
--with-log-viewer --with-logo=/etc/plymouth/logo.png
--with-background-color=0x000000
--with-background-start-color-stop=0x000000
--with-background-end-color-stop=0x000000
--with-release-file=/etc/os-release
--without-system-root-install --without-system-root-install
--without-rhgb-compat-link --without-rhgb-compat-link
--enable-tracing --enable-tracing
--enable-systemd-integration --enable-systemd-integration
--enable-pango --enable-pango
--enable-gdm-transition
--enable-gtk" --enable-gtk"
installFlags="
plymouthd_defaultsdir=$out/share/plymouth
plymouthd_confdir=$out/etc/plymouth"
''; '';
meta = with stdenv.lib; { meta = with stdenv.lib; {