about summary refs log tree commit diff
path: root/pkgs/os-specific/linux/dracut/default.nix
blob: e5461bddbc8f3cd63aec10ce79fc82d36a7a65ef (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
{ stdenv
, lib
, fetchFromGitHub
, gitUpdater
, makeBinaryWrapper
, pkg-config
, asciidoc
, libxslt
, docbook_xsl
, bash
, kmod
, binutils
, bzip2
, coreutils
, cpio
, findutils
, gnugrep
, gnused
, gnutar
, gzip
, lz4
, lzop
, squashfsTools
, util-linux
, xz
, zstd
}:

stdenv.mkDerivation rec {
  pname = "dracut";
  version = "059";

  src = fetchFromGitHub {
    owner = "dracutdevs";
    repo = "dracut";
    rev = version;
    hash = "sha256-zSyC2SnSQkmS/mDpBXG2DtVVanRRI9COKQJqYZZCPJM=";
  };

  strictDeps = true;

  buildInputs = [
    bash
    kmod
  ];

  nativeBuildInputs = [
    makeBinaryWrapper
    pkg-config
    asciidoc
    libxslt
    docbook_xsl
  ];

  postPatch = ''
    substituteInPlace dracut.sh \
      --replace 'dracutbasedir="$dracutsysrootdir"/usr/lib/dracut' 'dracutbasedir="$dracutsysrootdir"'"$out/lib/dracut"
    substituteInPlace lsinitrd.sh \
      --replace 'dracutbasedir=/usr/lib/dracut' "dracutbasedir=$out/lib/dracut"

    echo 'DRACUT_VERSION=${version}' >dracut-version.sh
  '';

  postFixup = ''
    wrapProgram $out/bin/dracut --prefix PATH : ${lib.makeBinPath [
      coreutils
      util-linux
    ]} --suffix DRACUT_PATH : ${lib.makeBinPath [
      bash
      binutils
      coreutils
      findutils
      gnugrep
      gnused
      gnutar
      stdenv.cc.libc  # for ldd command
      util-linux
    ]}
    wrapProgram $out/bin/dracut-catimages --set PATH ${lib.makeBinPath [
      coreutils
      cpio
      findutils
      gzip
    ]}
    wrapProgram $out/bin/lsinitrd --set PATH ${lib.makeBinPath [
      binutils
      bzip2
      coreutils
      cpio
      gnused
      gzip
      lz4
      lzop
      squashfsTools
      util-linux
      xz
      zstd
    ]}
  '';

  passthru.updateScript = gitUpdater { };

  meta = with lib; {
    homepage = "https://github.com/dracutdevs/dracut/wiki";
    description = "An event driven initramfs infrastructure";
    license = licenses.gpl2Plus;
    maintainers = with maintainers; [ lilyinstarlight ];
    platforms = platforms.linux;
  };
}