patches and low-level development discussion
 help / color / mirror / code / Atom feed
* [PATCH] use statically linked cryptsetup in initramfs
@ 2021-12-12 14:11 Yureka
  2022-02-16  0:10 ` Alyssa Ross
  0 siblings, 1 reply; 2+ messages in thread
From: Yureka @ 2021-12-12 14:11 UTC (permalink / raw)
  To: devel; +Cc: Yureka

---
 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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] use statically linked cryptsetup in initramfs
  2021-12-12 14:11 [PATCH] use statically linked cryptsetup in initramfs Yureka
@ 2022-02-16  0:10 ` Alyssa Ross
  0 siblings, 0 replies; 2+ messages in thread
From: Alyssa Ross @ 2022-02-16  0:10 UTC (permalink / raw)
  To: Yureka; +Cc: devel

[-- Attachment #1: Type: text/plain, Size: 2169 bytes --]

On Sun, Dec 12, 2021 at 03:11:14PM +0100, Yureka wrote:
> ---
>  host/initramfs/default.nix | 31 +++++++++++++++++++++++++++----
>  1 file changed, 27 insertions(+), 4 deletions(-)

Just a note to say, I didn't apply this particular patch because you'd
already fixed it in Nixpkgs by the time I saw it, but I have now (finally)
integrated static cryptsetup in Spectrum, and it's working and it made
the initramfs much smaller and faster to build.  Thanks so much for the
work you put into it!

> 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
>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-02-16  0:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-12 14:11 [PATCH] use statically linked cryptsetup in initramfs Yureka
2022-02-16  0:10 ` Alyssa Ross

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).