Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

systemd: build with cryptsetup support #62638

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion nixos/modules/system/boot/systemd.nix
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ in
systemd.generator-packages = mkOption {
default = [];
type = types.listOf types.package;
example = literalExample "[ pkgs.systemd-cryptsetup-generator ]";
example = literalExample "[ pkgs.lvm2 ]";
description = "Packages providing systemd generators.";
};

Expand Down Expand Up @@ -821,6 +821,7 @@ in
[Sleep]
'';

"tmpfiles.d/lvm2.conf".source = "${pkgs.lvm2}/lib/tmpfiles.d/lvm2.conf";
"tmpfiles.d/systemd.conf".source = "${systemd}/example/tmpfiles.d/systemd.conf";
"tmpfiles.d/x11.conf".source = "${systemd}/example/tmpfiles.d/x11.conf";

Expand Down
58 changes: 27 additions & 31 deletions pkgs/os-specific/linux/lvm2/default.nix
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{ stdenv, fetchgit, fetchpatch, pkgconfig, systemd, udev, utillinux, libuuid
{ stdenv, fetchgit, fetchpatch, pkgconfig, udev, utillinux, libuuid
, thin-provisioning-tools, libaio
, enable_dmeventd ? false }:

let
pname = "lvm2";
version = "2.03.01";
in

stdenv.mkDerivation {
name = "lvm2-${version}";
inherit pname version;

src = fetchgit {
url = "git://sourceware.org/git/lvm2.git";
Expand All @@ -17,33 +18,32 @@ stdenv.mkDerivation {

configureFlags = [
"--disable-readline"
"--enable-udev_rules"
"--enable-udev_sync"
"--enable-pkgconfig"
"--enable-applib"
"--enable-cmdlib"
] ++ stdenv.lib.optional enable_dmeventd " --enable-dmeventd"
++ stdenv.lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
"ac_cv_func_malloc_0_nonnull=yes"
"ac_cv_func_realloc_0_nonnull=yes"
] ++
stdenv.lib.optionals (udev != null) [
"--enable-udev_rules"
"--enable-udev_sync"
];

nativeBuildInputs = [ pkgconfig ];
buildInputs = [ udev libuuid thin-provisioning-tools libaio ];

preConfigure =
''
substituteInPlace scripts/lvm2_activation_generator_systemd_red_hat.c \
--replace /usr/bin/udevadm ${systemd}/bin/udevadm

sed -i /DEFAULT_SYS_DIR/d Makefile.in
sed -i /DEFAULT_PROFILE_DIR/d conf/Makefile.in
'';
preConfigure = ''
substituteInPlace scripts/lvm2_activation_generator_systemd_red_hat.c \
--replace /usr/bin/udevadm /run/current-system/systemd/bin/udevadm

# gcc: error: ../../device_mapper/libdevice-mapper.a: No such file or directory
enableParallelBuilding = false;
sed -i /DEFAULT_SYS_DIR/d Makefile.in
sed -i /DEFAULT_PROFILE_DIR/d conf/Makefile.in
substituteInPlace make.tmpl.in --replace "@systemdsystemunitdir@" "${placeholder "out"}/lib/systemd/system"
substituteInPlace libdm/make.tmpl.in --replace "@systemdsystemunitdir@" "${placeholder "out"}/lib/systemd/system"
'';

#patches = [ ./purity.patch ];
patches = stdenv.lib.optionals stdenv.hostPlatform.isMusl [
(fetchpatch {
name = "fix-stdio-usage.patch";
Expand All @@ -64,30 +64,26 @@ stdenv.mkDerivation {

doCheck = false; # requires root

makeFlags = stdenv.lib.optionals (udev != null) [
"SYSTEMD_GENERATOR_DIR=$(out)/lib/systemd/system-generators"
];

# To prevent make install from failing.
preInstall = "installFlags=\"OWNER= GROUP= confdir=$out/etc\"";
installFlags = [
"OWNER="
"GROUP="
"confdir=$(out)/etc"
];

# Install systemd stuff.
#installTargets = "install install_systemd_generators install_systemd_units install_tmpfiles_configuration";

postInstall =
''
substituteInPlace $out/lib/udev/rules.d/13-dm-disk.rules \
--replace $out/sbin/blkid ${utillinux}/sbin/blkid

# Systemd stuff
mkdir -p $out/etc/systemd/system $out/lib/systemd/system-generators
cp scripts/blk_availability_systemd_red_hat.service $out/etc/systemd/system
cp scripts/lvm2_activation_generator_systemd_red_hat $out/lib/systemd/system-generators
'';
installTargets = [ "install" ]
++ stdenv.lib.optionals (udev != null) [ "install_systemd_generators" "install_systemd_units" "install_tmpfiles_configuration"];

meta = with stdenv.lib; {
homepage = http://sourceware.org/lvm2/;
description = "Tools to support Logical Volume Management (LVM) on Linux";
platforms = platforms.linux;
license = with licenses; [ gpl2 bsd2 lgpl21 ];
maintainers = with maintainers; [raskin];
inherit version;
downloadPage = "ftp://sources.redhat.com/pub/lvm2/";
maintainers = with maintainers; [ raskin ];
};
}
44 changes: 0 additions & 44 deletions pkgs/os-specific/linux/lvm2/purity.patch

This file was deleted.

34 changes: 0 additions & 34 deletions pkgs/os-specific/linux/systemd/cryptsetup-generator.nix

This file was deleted.

15 changes: 11 additions & 4 deletions pkgs/os-specific/linux/systemd/default.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{ stdenv, lib, fetchFromGitHub, fetchpatch, fetchurl, pkgconfig, intltool, gperf, libcap, kmod
, xz, pam, acl, libuuid, m4, utillinux, libffi
, xz, pam, acl, libuuid, m4, e2fsprogs, utillinux, libffi
, glib, kbd, libxslt, coreutils, libgcrypt, libgpgerror, libidn2, libapparmor
, audit, lz4, bzip2, libmicrohttpd, pcre2
, linuxHeaders ? stdenv.cc.libc.linuxHeaders
Expand All @@ -8,14 +8,19 @@
, ninja, meson, python3Packages, glibcLocales
, patchelf
, getent
, cryptsetup, lvm2
, buildPackages
, perl
, withSelinux ? false, libselinux
, withLibseccomp ? lib.any (lib.meta.platformMatch stdenv.hostPlatform) libseccomp.meta.platforms, libseccomp
, withKexectools ? lib.any (lib.meta.platformMatch stdenv.hostPlatform) kexectools.meta.platforms, kexectools
}:

stdenv.mkDerivation rec {
let
# to avoid circular dependencies, build cryptsetup with a lvm2 without udev support
_cryptsetup = cryptsetup.override { lvm2 = lvm2.override { udev = null; }; };

in stdenv.mkDerivation rec {
version = "242";
name = "systemd-${version}";

Expand All @@ -42,7 +47,7 @@ stdenv.mkDerivation rec {
];
buildInputs =
[ linuxHeaders libcap kmod xz pam acl
/* cryptsetup */ libuuid glib libgcrypt libgpgerror libidn2
_cryptsetup libuuid glib libgcrypt libgpgerror libidn2
libmicrohttpd pcre2 ] ++
stdenv.lib.optional withKexectools kexectools ++
stdenv.lib.optional withLibseccomp libseccomp ++
Expand Down Expand Up @@ -107,12 +112,14 @@ stdenv.mkDerivation rec {
export LC_ALL="en_US.UTF-8";
# FIXME: patch this in systemd properly (and send upstream).
# already fixed in f00929ad622c978f8ad83590a15a765b4beecac9: (u)mount
for i in src/remount-fs/remount-fs.c src/core/mount.c src/core/swap.c src/fsck/fsck.c units/emergency.service.in units/rescue.service.in src/journal/cat.c src/shutdown/shutdown.c src/nspawn/nspawn.c src/shared/generator.c; do
for i in src/cryptsetup/cryptsetup-generator.c src/remount-fs/remount-fs.c src/core/mount.c src/core/swap.c src/fsck/fsck.c units/emergency.service.in units/rescue.service.in src/journal/cat.c src/shutdown/shutdown.c src/nspawn/nspawn.c src/shared/generator.c; do
test -e $i
substituteInPlace $i \
--replace /usr/bin/getent ${getent}/bin/getent \
--replace /sbin/mkswap ${lib.getBin utillinux}/sbin/mkswap \
--replace /sbin/swapon ${lib.getBin utillinux}/sbin/swapon \
--replace /sbin/swapoff ${lib.getBin utillinux}/sbin/swapoff \
--replace /sbin/mke2fs ${lib.getBin e2fsprogs}/sbin/mke2fs \
--replace /sbin/fsck ${lib.getBin utillinux}/sbin/fsck \
--replace /bin/echo ${coreutils}/bin/echo \
--replace /bin/cat ${coreutils}/bin/cat \
Expand Down
3 changes: 3 additions & 0 deletions pkgs/top-level/aliases.nix
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,8 @@ mapAliases ({
suil-qt5 = suil; # added 2018-05-01
surf-webkit2 = surf; # added 2017-04-02
system_config_printer = system-config-printer; # added 2016-01-03
systemd-cryptsetup-generator = throw "please add lvm2 system generators by setting systemd.system-generators = [ pkgs.lvm2 ];"; # added 2019-05-13
systemd_with_lvm2 = throw "please add lvm2 system generators by setting systemd.system-generators = [ pkgs.lvm2 ];";
systool = sysfsutils; # added 2018-04-25
tahoelafs = tahoe-lafs; # added 2018-03-26
telepathy_farstream = telepathy-farstream; # added 2018-02-25
Expand Down Expand Up @@ -344,6 +346,7 @@ mapAliases ({
truecrypt = veracrypt; # added 2018-10-24
tshark = wireshark-cli; # added 2018-04-25
ucsFonts = ucs-fonts; # added 2016-07-15
udev = systemd; # added 2019-05-13
ultrastardx-beta = ultrastardx; # added 2017-08-12
usb_modeswitch = usb-modeswitch; # added 2016-05-10
vimbWrapper = vimb; # added 2015-01
Expand Down
13 changes: 0 additions & 13 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15898,19 +15898,6 @@ in
systemd = callPackage ../os-specific/linux/systemd {
utillinux = utillinuxMinimal; # break the cyclic dependency
};
udev = systemd; # TODO: move to aliases.nix

# standalone cryptsetup generator for systemd
systemd-cryptsetup-generator = callPackage ../os-specific/linux/systemd/cryptsetup-generator.nix { };

# In nixos, you can set systemd.package = pkgs.systemd_with_lvm2 to get
# LVM2 working in systemd.
systemd_with_lvm2 = pkgs.appendToName "with-lvm2" (pkgs.lib.overrideDerivation pkgs.systemd (p: {
postInstall = p.postInstall + ''
cp "${pkgs.lvm2}/lib/systemd/system-generators/"* $out/lib/systemd/system-generators
'';
}));

systemd-wait = callPackage ../os-specific/linux/systemd-wait { };

sysvinit = callPackage ../os-specific/linux/sysvinit { };
Expand Down