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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
|
{ lib
, stdenv
, fetchurl
, fetchpatch
, autoPatchelfHook
, bash
, copyDesktopItems
, coreutils
, cryptsetup
, dosfstools
, e2fsprogs
, exfat
, gawk
, gnugrep
, gnused
, gtk3
, hexdump
, makeDesktopItem
, makeWrapper
, ntfs3g
, parted
, procps
, qtbase
, util-linux
, which
, wrapQtAppsHook
, xfsprogs
, xz
, defaultGuiType ? ""
, withCryptsetup ? false
, withXfs ? false
, withExt4 ? false
, withNtfs ? false
, withGtk3 ? false
, withQt5 ? false
}:
assert lib.elem defaultGuiType [ "" "gtk3" "qt5" ];
assert defaultGuiType == "gtk3" -> withGtk3;
assert defaultGuiType == "qt5" -> withQt5;
let
arch = {
x86_64-linux = "x86_64";
i686-linux = "i386";
aarch64-linux = "aarch64";
mipsel-linux = "mips64el";
}.${stdenv.hostPlatform.system}
or (throw "Unsupported platform ${stdenv.hostPlatform.system}");
in
stdenv.mkDerivation (finalAttrs: {
pname = "ventoy-bin";
version = "1.0.80";
src = fetchurl {
url = "https://github.com/ventoy/Ventoy/releases/download/v${finalAttrs.version}/ventoy-${finalAttrs.version}-linux.tar.gz";
hash = "sha256-FmMpMUy8VqwbOiRWZdoY76ToSoWWbBGM5h/9VS8rYRY=";
};
patches = [
./000-sanitize.patch
./001-add-mips64.diff
./002-fix-for-read-only-file-system.diff
];
patchFlags = [ "-p0" ];
postPatch = ''
# Fix permissions.
find -type f -name \*.sh -exec chmod a+x '{}' \;
# Fix path to log.
sed -i 's:log\.txt:/var/log/ventoy\.log:g' \
WebUI/static/js/languages.js tool/languages.json
'';
nativeBuildInputs = [
autoPatchelfHook
makeWrapper
]
++ lib.optional (withQt5 || withGtk3) copyDesktopItems
++ lib.optional withQt5 wrapQtAppsHook;
buildInputs = [
bash
coreutils
dosfstools
exfat
gawk
gnugrep
gnused
hexdump
parted
procps
util-linux
which
xz
]
++ lib.optional withCryptsetup cryptsetup
++ lib.optional withExt4 e2fsprogs
++ lib.optional withGtk3 gtk3
++ lib.optional withNtfs ntfs3g
++ lib.optional withXfs xfsprogs
++ lib.optional withQt5 qtbase;
desktopItems = [
(makeDesktopItem {
name = "Ventoy";
desktopName = "Ventoy";
comment = "Tool to create bootable USB drive for ISO/WIM/IMG/VHD(x)/EFI files";
icon = "VentoyLogo";
exec = "ventoy-gui";
terminal = false;
categories = [ "Utility" ];
startupNotify = true;
})];
dontConfigure = true;
dontBuild = true;
installPhase = ''
runHook preInstall
# Setup variables.
local VENTOY_PATH="$out"/share/ventoy
local ARCH='${arch}'
# Prepare.
cd tool/"$ARCH"
rm ash* hexdump* mkexfatfs* mount.exfat-fuse* xzcat*
for archive in *.xz; do
xzcat "$archive" > "''${archive%.xz}"
rm "$archive"
done
chmod a+x *
cd -
# Cleanup.
case "$ARCH" in
x86_64) rm -r {tool/,VentoyGUI.}{i386,aarch64,mips64el};;
i386) rm -r {tool/,VentoyGUI.}{x86_64,aarch64,mips64el};;
aarch64) rm -r {tool/,VentoyGUI.}{x86_64,i386,mips64el};;
mips64el) rm -r {tool/,VentoyGUI.}{x86_64,i386,aarch64};;
esac
rm README
rm tool/"$ARCH"/Ventoy2Disk.gtk2 || true # For aarch64 and mips64el.
# Copy from "$src" to "$out".
mkdir -p "$out"/bin "$VENTOY_PATH"
cp -r . "$VENTOY_PATH"
# Fill bin dir.
for f in Ventoy2Disk.sh_ventoy VentoyWeb.sh_ventoy-web \
CreatePersistentImg.sh_ventoy-persistent \
ExtendPersistentImg.sh_ventoy-extend-persistent \
VentoyPlugson.sh_ventoy-plugson; do
local bin="''${f%_*}" wrapper="''${f#*_}"
makeWrapper "$VENTOY_PATH/$bin" "$out/bin/$wrapper" \
--prefix PATH : "${lib.makeBinPath finalAttrs.buildInputs}" \
--chdir "$VENTOY_PATH"
done
''
# VentoGUI uses the `ventoy_gui_type` file to determine the type of GUI.
# See: https://github.com/ventoy/Ventoy/blob/v1.0.78/LinuxGUI/Ventoy2Disk/ventoy_gui.c#L1096
+ lib.optionalString (withGtk3 || withQt5) ''
echo "${defaultGuiType}" > "$VENTOY_PATH/ventoy_gui_type"
makeWrapper "$VENTOY_PATH/VentoyGUI.$ARCH" "$out/bin/ventoy-gui" \
--prefix PATH : "${lib.makeBinPath finalAttrs.buildInputs}" \
--chdir "$VENTOY_PATH"
mkdir "$out"/share/{applications,pixmaps}
ln -s "$VENTOY_PATH"/WebUI/static/img/VentoyLogo.png "$out"/share/pixmaps/
''
+ lib.optionalString (!withGtk3) ''
rm "$VENTOY_PATH"/tool/{"$ARCH"/Ventoy2Disk.gtk3,VentoyGTK.glade}
''
+ lib.optionalString (!withQt5) ''
rm "$VENTOY_PATH/tool/$ARCH/Ventoy2Disk.qt5"
''
+ lib.optionalString (!withGtk3 && !withQt5) ''
rm "$VENTOY_PATH"/VentoyGUI.*
'' +
''
runHook postInstall
'';
meta = with lib; {
description = "A New Bootable USB Solution";
longDescription = ''
homepage = "https://www.ventoy.net";
Ventoy is an open source tool to create bootable USB drive for
ISO/WIM/IMG/VHD(x)/EFI files. With ventoy, you don't need to format the
disk over and over, you just need to copy the ISO/WIM/IMG/VHD(x)/EFI files
to the USB drive and boot them directly. You can copy many files at a time
and ventoy will give you a boot menu to select them. You can also browse
ISO/WIM/IMG/VHD(x)/EFI files in local disk and boot them. x86 Legacy
BIOS, IA32 UEFI, x86_64 UEFI, ARM64 UEFI and MIPS64EL UEFI are supported
in the same way. Most type of OS supported
(Windows/WinPE/Linux/ChromeOS/Unix/VMware/Xen...). With ventoy you can
also browse ISO/WIM/IMG/VHD(x)/EFI files in local disk and boot them.
800+ image files are tested. 90%+ distros in DistroWatch supported.
'';
changelog = "https://www.ventoy.net/doc_news.html";
license = licenses.gpl3Plus;
maintainers = with maintainers; [ AndersonTorres ];
platforms = [ "x86_64-linux" "i686-linux" "aarch64-linux" "mipsel-linux" ];
sourceProvenance = with sourceTypes; [ binaryNativeCode ];
mainProgram = "ventoy";
};
})
|