patches and low-level development discussion
 help / color / mirror / code / Atom feed
From: Yureka <yuka@yuka.dev>
To: devel@spectrum-os.org
Cc: Yureka <yuka@yuka.dev>
Subject: [PATCH] use statically linked cryptsetup in initramfs
Date: Sun, 12 Dec 2021 15:11:14 +0100	[thread overview]
Message-ID: <20211212141114.3238230-1-yuka@yuka.dev> (raw)

---
 host/initramfs/default.nix | 31 +++++++++++++++++++++++++++----
 1 file changed, 27 insertions(+), 4 deletions(-)

diff --git a/host/initramfs/default.nix b/host/initramfs/default.nix
index ba6ede2..91e598f 100644
--- a/host/initramfs/default.nix
+++ b/host/initramfs/default.nix
@@ -2,15 +2,38 @@
 
 { lib, stdenv, runCommand, writeReferencesToFile, pkgsStatic
 , busybox, cpio, cryptsetup, linux, lvm2
+, fetchpatch
 }:
 
-let
-  cryptsetup' = cryptsetup;
-in
 let
   inherit (lib) cleanSource cleanSourceWith concatMapStringsSep;
 
-  cryptsetup = cryptsetup'.override { lvm2 = lvm2.override { udev = null; }; };
+  # https://github.com/NixOS/nixpkgs/pull/148948
+  cryptsetup = (pkgsStatic.cryptsetup.override {
+    lvm2 = (pkgsStatic.lvm2.override {
+      udev = null;
+    }).overrideAttrs (old: {
+      patches = (old.patches or []) ++ [
+        (fetchpatch {
+          url = "https://raw.githubusercontent.com/NixOS/nixpkgs/bf8b0d818a6c5fa65f318603756762af492c1a0c/pkgs/os-specific/linux/lvm2/no-shared.diff";
+          sha256 = "sha256-t67Osvcn92R7q9V+KDW+SyJDmajzVbnTPONlokcBU9U=";
+        })
+      ];
+      configureFlags = old.configureFlags ++ [ "--enable-static_link" ];
+      makeFlags = old.makeFlags ++ [ "libdm.device-mapper" ];
+      installPhase = ''
+        install -D -t $out/lib libdm/ioctl/libdevmapper.a
+        make -C libdm install_include
+        make -C libdm install_pkgconfig
+      '';
+      outputs = [ "out" ];
+    });
+  }).overrideAttrs (old: {
+    NIX_LDFLAGS = "";
+    configureFlags = old.configureFlags ++ [
+      "--enable-static-cryptsetup"
+    ];
+  });
 
   packages = [
     cryptsetup pkgsStatic.mdevd pkgsStatic.execline
-- 
2.34.0


             reply	other threads:[~2021-12-12 14:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-12 14:11 Yureka [this message]
2022-02-16  0:10 ` [PATCH] use statically linked cryptsetup in initramfs Alyssa Ross

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211212141114.3238230-1-yuka@yuka.dev \
    --to=yuka@yuka.dev \
    --cc=devel@spectrum-os.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://spectrum-os.org/git/crosvm
	https://spectrum-os.org/git/doc
	https://spectrum-os.org/git/mktuntap
	https://spectrum-os.org/git/nixpkgs
	https://spectrum-os.org/git/spectrum
	https://spectrum-os.org/git/ucspi-vsock
	https://spectrum-os.org/git/www

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).