2021-01-24 00:40:18 +00:00
|
|
|
{ lib
|
|
|
|
, pkgs
|
2014-09-21 16:28:07 +00:00
|
|
|
, kernel ? pkgs.linux
|
2021-01-23 01:33:55 +00:00
|
|
|
, img ? pkgs.stdenv.hostPlatform.linux-kernel.target
|
2016-09-27 23:42:05 +00:00
|
|
|
, storeDir ? builtins.storeDir
|
2012-04-11 07:45:12 +00:00
|
|
|
, rootModules ?
|
2018-09-25 08:41:39 +00:00
|
|
|
[ "virtio_pci" "virtio_mmio" "virtio_blk" "virtio_balloon" "virtio_rng" "ext4" "unix" "9p" "9pnet_virtio" "crc32c_generic" ]
|
2021-11-21 01:50:41 +00:00
|
|
|
++ pkgs.lib.optional pkgs.stdenv.hostPlatform.isx86 "rtc_cmos"
|
2011-02-01 12:11:05 +00:00
|
|
|
}:
|
2008-03-17 17:29:07 +00:00
|
|
|
|
2021-09-30 18:43:31 +00:00
|
|
|
let
|
|
|
|
inherit (pkgs) bash bashInteractive busybox cpio coreutils e2fsprogs fetchurl kmod rpm
|
|
|
|
stdenv util-linux
|
|
|
|
buildPackages writeScript writeText runCommand;
|
|
|
|
in
|
2008-03-14 13:51:01 +00:00
|
|
|
rec {
|
2021-06-23 15:46:46 +00:00
|
|
|
qemu-common = import ../../../nixos/lib/qemu-common.nix { inherit lib pkgs; };
|
2008-03-14 13:51:01 +00:00
|
|
|
|
2021-01-17 14:43:14 +00:00
|
|
|
qemu = buildPackages.qemu_kvm;
|
2013-07-04 16:30:26 +00:00
|
|
|
|
2021-09-30 18:43:31 +00:00
|
|
|
modulesClosure = pkgs.makeModulesClosure {
|
2011-02-01 12:11:05 +00:00
|
|
|
inherit kernel rootModules;
|
2018-01-08 13:13:28 +00:00
|
|
|
firmware = kernel;
|
2008-03-14 13:51:01 +00:00
|
|
|
};
|
|
|
|
|
2009-04-09 08:12:16 +00:00
|
|
|
|
2010-06-13 23:49:16 +00:00
|
|
|
hd = "vda"; # either "sda" or "vda"
|
|
|
|
|
2010-06-10 12:28:04 +00:00
|
|
|
initrdUtils = runCommand "initrd-utils"
|
2021-01-17 14:43:14 +00:00
|
|
|
{ nativeBuildInputs = [ buildPackages.nukeReferences ];
|
2010-06-10 12:28:04 +00:00
|
|
|
allowedReferences = [ "out" modulesClosure ]; # prevent accidents like glibc being included in the initrd
|
|
|
|
}
|
|
|
|
''
|
2012-01-18 20:16:00 +00:00
|
|
|
mkdir -p $out/bin
|
|
|
|
mkdir -p $out/lib
|
2012-08-27 17:39:13 +00:00
|
|
|
|
2010-06-10 12:28:04 +00:00
|
|
|
# Copy what we need from Glibc.
|
2022-05-10 21:52:26 +00:00
|
|
|
cp -p ${pkgs.stdenv.cc.libc}/lib/ld-linux*.so.? $out/lib
|
|
|
|
cp -p ${pkgs.stdenv.cc.libc}/lib/libc.so.* $out/lib
|
|
|
|
cp -p ${pkgs.stdenv.cc.libc}/lib/libm.so.* $out/lib
|
|
|
|
cp -p ${pkgs.stdenv.cc.libc}/lib/libresolv.so.* $out/lib
|
2012-12-18 15:57:11 +00:00
|
|
|
|
|
|
|
# Copy BusyBox.
|
2015-01-12 16:42:59 +00:00
|
|
|
cp -pd ${pkgs.busybox}/bin/* $out/bin
|
2012-08-27 17:39:13 +00:00
|
|
|
|
2010-06-10 12:28:04 +00:00
|
|
|
# Run patchelf to make the programs refer to the copied libraries.
|
|
|
|
for i in $out/bin/* $out/lib/*; do if ! test -L $i; then nuke-refs $i; fi; done
|
|
|
|
|
|
|
|
for i in $out/bin/*; do
|
2012-12-18 15:57:11 +00:00
|
|
|
if [ -f "$i" -a ! -L "$i" ]; then
|
|
|
|
echo "patching $i..."
|
|
|
|
patchelf --set-interpreter $out/lib/ld-linux*.so.? --set-rpath $out/lib $i || true
|
|
|
|
fi
|
2010-06-10 12:28:04 +00:00
|
|
|
done
|
|
|
|
''; # */
|
2009-03-02 13:22:31 +00:00
|
|
|
|
2012-08-27 17:39:13 +00:00
|
|
|
|
2008-03-14 13:51:01 +00:00
|
|
|
stage1Init = writeScript "vm-run-stage1" ''
|
2012-12-18 15:57:11 +00:00
|
|
|
#! ${initrdUtils}/bin/ash -e
|
2008-03-14 13:51:01 +00:00
|
|
|
|
2010-06-10 12:28:04 +00:00
|
|
|
export PATH=${initrdUtils}/bin
|
2008-03-14 13:51:01 +00:00
|
|
|
|
|
|
|
mkdir /etc
|
|
|
|
echo -n > /etc/fstab
|
|
|
|
|
|
|
|
mount -t proc none /proc
|
2009-12-18 12:10:35 +00:00
|
|
|
mount -t sysfs none /sys
|
2008-03-14 13:51:01 +00:00
|
|
|
|
2013-07-04 21:35:31 +00:00
|
|
|
echo 2 > /proc/sys/vm/panic_on_oom
|
|
|
|
|
2008-03-14 13:51:01 +00:00
|
|
|
for o in $(cat /proc/cmdline); do
|
|
|
|
case $o in
|
2008-03-17 10:40:47 +00:00
|
|
|
mountDisk=1)
|
|
|
|
mountDisk=1
|
2008-03-14 13:51:01 +00:00
|
|
|
;;
|
|
|
|
command=*)
|
|
|
|
set -- $(IFS==; echo $o)
|
|
|
|
command=$2
|
|
|
|
;;
|
|
|
|
out=*)
|
|
|
|
set -- $(IFS==; echo $o)
|
|
|
|
export out=$2
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2013-08-01 12:35:04 +00:00
|
|
|
echo "loading kernel modules..."
|
2008-03-14 13:51:01 +00:00
|
|
|
for i in $(cat ${modulesClosure}/insmod-list); do
|
2018-05-03 23:04:11 +00:00
|
|
|
insmod $i || echo "warning: unable to load $i"
|
2008-03-14 13:51:01 +00:00
|
|
|
done
|
|
|
|
|
2017-12-06 18:28:43 +00:00
|
|
|
mount -t devtmpfs devtmpfs /dev
|
2021-12-07 23:49:25 +00:00
|
|
|
ln -s /proc/self/fd /dev/fd
|
|
|
|
ln -s /proc/self/fd/0 /dev/stdin
|
|
|
|
ln -s /proc/self/fd/1 /dev/stdout
|
|
|
|
ln -s /proc/self/fd/2 /dev/stderr
|
2012-08-27 17:39:13 +00:00
|
|
|
|
2013-07-05 13:02:43 +00:00
|
|
|
ifconfig lo up
|
|
|
|
|
2008-03-14 13:51:01 +00:00
|
|
|
mkdir /fs
|
|
|
|
|
2008-03-17 10:40:47 +00:00
|
|
|
if test -z "$mountDisk"; then
|
2008-03-14 13:51:01 +00:00
|
|
|
mount -t tmpfs none /fs
|
|
|
|
else
|
2011-10-11 13:22:09 +00:00
|
|
|
mount /dev/${hd} /fs
|
2008-03-14 13:51:01 +00:00
|
|
|
fi
|
2010-06-13 23:49:16 +00:00
|
|
|
|
2008-03-14 13:51:01 +00:00
|
|
|
mkdir -p /fs/dev
|
|
|
|
mount -o bind /dev /fs/dev
|
|
|
|
|
2016-09-04 13:42:43 +00:00
|
|
|
mkdir -p /fs/dev/shm /fs/dev/pts
|
2015-05-07 13:27:45 +00:00
|
|
|
mount -t tmpfs -o "mode=1777" none /fs/dev/shm
|
2016-09-04 13:42:43 +00:00
|
|
|
mount -t devpts none /fs/dev/pts
|
2015-05-07 13:27:45 +00:00
|
|
|
|
2011-08-09 14:05:40 +00:00
|
|
|
echo "mounting Nix store..."
|
2016-09-27 23:42:05 +00:00
|
|
|
mkdir -p /fs${storeDir}
|
2021-12-16 17:48:51 +00:00
|
|
|
mount -t 9p store /fs${storeDir} -o trans=virtio,version=9p2000.L,cache=loose,msize=131072
|
2011-08-09 14:05:40 +00:00
|
|
|
|
2015-05-08 11:00:54 +00:00
|
|
|
mkdir -p /fs/tmp /fs/run /fs/var
|
2014-11-18 13:49:14 +00:00
|
|
|
mount -t tmpfs -o "mode=1777" none /fs/tmp
|
2015-05-08 11:00:54 +00:00
|
|
|
mount -t tmpfs -o "mode=755" none /fs/run
|
|
|
|
ln -sfn /run /fs/var/run
|
2008-03-14 13:51:01 +00:00
|
|
|
|
2011-08-09 14:05:40 +00:00
|
|
|
echo "mounting host's temporary directory..."
|
|
|
|
mkdir -p /fs/tmp/xchg
|
2021-12-16 17:48:51 +00:00
|
|
|
mount -t 9p xchg /fs/tmp/xchg -o trans=virtio,version=9p2000.L,msize=131072
|
2011-08-09 14:05:40 +00:00
|
|
|
|
2008-03-14 13:51:01 +00:00
|
|
|
mkdir -p /fs/proc
|
|
|
|
mount -t proc none /fs/proc
|
|
|
|
|
2009-12-18 12:10:35 +00:00
|
|
|
mkdir -p /fs/sys
|
|
|
|
mount -t sysfs none /fs/sys
|
|
|
|
|
2008-03-14 13:51:01 +00:00
|
|
|
mkdir -p /fs/etc
|
|
|
|
ln -sf /proc/mounts /fs/etc/mtab
|
2013-07-05 13:02:43 +00:00
|
|
|
echo "127.0.0.1 localhost" > /fs/etc/hosts
|
2020-02-20 23:19:05 +00:00
|
|
|
# Ensures tools requiring /etc/passwd will work (e.g. nix)
|
|
|
|
if [ ! -e /fs/etc/passwd ]; then
|
|
|
|
echo "root:x:0:0:System administrator:/root:/bin/sh" > /fs/etc/passwd
|
|
|
|
fi
|
2012-08-27 17:39:13 +00:00
|
|
|
|
2013-08-01 12:35:04 +00:00
|
|
|
echo "starting stage 2 ($command)"
|
2015-05-08 11:01:10 +00:00
|
|
|
exec switch_root /fs $command $out
|
2008-03-14 13:51:01 +00:00
|
|
|
'';
|
|
|
|
|
2012-08-27 17:39:13 +00:00
|
|
|
|
2021-09-30 18:43:31 +00:00
|
|
|
initrd = pkgs.makeInitrd {
|
2008-03-14 13:51:01 +00:00
|
|
|
contents = [
|
|
|
|
{ object = stage1Init;
|
|
|
|
symlink = "/init";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2012-08-27 17:39:13 +00:00
|
|
|
|
2008-03-14 13:51:01 +00:00
|
|
|
stage2Init = writeScript "vm-run-stage2" ''
|
|
|
|
#! ${bash}/bin/sh
|
2011-08-09 14:05:40 +00:00
|
|
|
source /tmp/xchg/saved-env
|
2012-08-27 17:39:13 +00:00
|
|
|
|
2014-03-18 14:02:09 +00:00
|
|
|
# Set the system time from the hardware clock. Works around an
|
|
|
|
# apparent KVM > 1.5.2 bug.
|
2021-09-30 18:43:31 +00:00
|
|
|
${util-linux}/bin/hwclock -s
|
2014-03-18 14:02:09 +00:00
|
|
|
|
2016-09-27 23:42:05 +00:00
|
|
|
export NIX_STORE=${storeDir}
|
2011-08-09 14:05:40 +00:00
|
|
|
export NIX_BUILD_TOP=/tmp
|
|
|
|
export TMPDIR=/tmp
|
2008-03-14 13:51:01 +00:00
|
|
|
export PATH=/empty
|
2011-08-09 14:05:40 +00:00
|
|
|
out="$1"
|
2008-03-14 13:51:01 +00:00
|
|
|
cd "$NIX_BUILD_TOP"
|
|
|
|
|
|
|
|
if ! test -e /bin/sh; then
|
|
|
|
${coreutils}/bin/mkdir -p /bin
|
|
|
|
${coreutils}/bin/ln -s ${bash}/bin/sh /bin/sh
|
|
|
|
fi
|
|
|
|
|
2015-05-08 11:01:10 +00:00
|
|
|
# Set up automatic kernel module loading.
|
2019-01-29 20:17:44 +00:00
|
|
|
export MODULE_DIR=${kernel}/lib/modules/
|
2015-05-08 11:01:10 +00:00
|
|
|
${coreutils}/bin/cat <<EOF > /run/modprobe
|
2019-01-15 22:41:31 +00:00
|
|
|
#! ${bash}/bin/sh
|
2015-05-08 11:01:10 +00:00
|
|
|
export MODULE_DIR=$MODULE_DIR
|
|
|
|
exec ${kmod}/bin/modprobe "\$@"
|
|
|
|
EOF
|
|
|
|
${coreutils}/bin/chmod 755 /run/modprobe
|
|
|
|
echo /run/modprobe > /proc/sys/kernel/modprobe
|
|
|
|
|
2008-03-14 13:51:01 +00:00
|
|
|
# For debugging: if this is the second time this image is run,
|
|
|
|
# then don't start the build again, but instead drop the user into
|
|
|
|
# an interactive shell.
|
|
|
|
if test -n "$origBuilder" -a ! -e /.debug; then
|
2015-06-04 18:08:24 +00:00
|
|
|
exec < /dev/null
|
2008-03-14 13:51:01 +00:00
|
|
|
${coreutils}/bin/touch /.debug
|
2015-05-08 11:01:10 +00:00
|
|
|
$origBuilder $origArgs
|
|
|
|
echo $? > /tmp/xchg/in-vm-exit
|
|
|
|
|
|
|
|
${busybox}/bin/mount -o remount,ro dummy /
|
|
|
|
|
|
|
|
${busybox}/bin/poweroff -f
|
2008-03-14 13:51:01 +00:00
|
|
|
else
|
|
|
|
export PATH=/bin:/usr/bin:${coreutils}/bin
|
|
|
|
echo "Starting interactive shell..."
|
|
|
|
echo "(To run the original builder: \$origBuilder \$origArgs)"
|
2021-06-23 15:46:46 +00:00
|
|
|
exec ${busybox}/bin/setsid ${bashInteractive}/bin/bash < /dev/${qemu-common.qemuSerialDevice} &> /dev/${qemu-common.qemuSerialDevice}
|
2008-03-14 13:51:01 +00:00
|
|
|
fi
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
2008-04-29 12:32:17 +00:00
|
|
|
qemuCommandLinux = ''
|
2021-06-23 15:46:46 +00:00
|
|
|
${qemu-common.qemuBinary qemu} \
|
2008-03-14 13:51:01 +00:00
|
|
|
-nographic -no-reboot \
|
2016-07-27 09:29:18 +00:00
|
|
|
-device virtio-rng-pci \
|
2016-09-27 23:42:05 +00:00
|
|
|
-virtfs local,path=${storeDir},security_model=none,mount_tag=store \
|
2013-07-04 22:06:08 +00:00
|
|
|
-virtfs local,path=$TMPDIR/xchg,security_model=none,mount_tag=xchg \
|
2018-09-25 08:41:39 +00:00
|
|
|
''${diskImage:+-drive file=$diskImage,if=virtio,cache=unsafe,werror=report} \
|
2011-02-01 12:11:05 +00:00
|
|
|
-kernel ${kernel}/${img} \
|
2008-03-14 13:51:01 +00:00
|
|
|
-initrd ${initrd}/initrd \
|
2021-06-23 15:46:46 +00:00
|
|
|
-append "console=${qemu-common.qemuSerialDevice} panic=1 command=${stage2Init} out=$out mountDisk=$mountDisk loglevel=4" \
|
2008-03-14 13:51:01 +00:00
|
|
|
$QEMU_OPTS
|
|
|
|
'';
|
|
|
|
|
2010-06-14 00:18:54 +00:00
|
|
|
|
2008-04-29 12:32:17 +00:00
|
|
|
vmRunCommand = qemuCommand: writeText "vm-run" ''
|
2008-03-14 13:51:01 +00:00
|
|
|
export > saved-env
|
|
|
|
|
2010-06-15 16:13:10 +00:00
|
|
|
PATH=${coreutils}/bin
|
2011-08-09 14:05:40 +00:00
|
|
|
mkdir xchg
|
|
|
|
mv saved-env xchg/
|
2008-03-14 13:51:01 +00:00
|
|
|
|
|
|
|
eval "$preVM"
|
|
|
|
|
2017-02-21 13:53:16 +00:00
|
|
|
if [ "$enableParallelBuilding" = 1 ]; then
|
|
|
|
if [ ''${NIX_BUILD_CORES:-0} = 0 ]; then
|
|
|
|
QEMU_OPTS+=" -smp cpus=$(nproc)"
|
|
|
|
else
|
|
|
|
QEMU_OPTS+=" -smp cpus=$NIX_BUILD_CORES"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2008-03-14 13:51:01 +00:00
|
|
|
# Write the command to start the VM to a file so that the user can
|
|
|
|
# debug inside the VM if the build fails (when Nix is called with
|
|
|
|
# the -K option to preserve the temporary build directory).
|
|
|
|
cat > ./run-vm <<EOF
|
|
|
|
#! ${bash}/bin/sh
|
2018-01-03 18:25:48 +00:00
|
|
|
''${diskImage:+diskImage=$diskImage}
|
2008-03-14 13:51:01 +00:00
|
|
|
TMPDIR=$TMPDIR
|
2010-06-14 11:18:57 +00:00
|
|
|
cd $TMPDIR
|
2008-03-14 13:51:01 +00:00
|
|
|
${qemuCommand}
|
|
|
|
EOF
|
|
|
|
|
2011-05-02 14:55:16 +00:00
|
|
|
mkdir -p -m 0700 $out
|
|
|
|
|
2008-03-14 13:51:01 +00:00
|
|
|
chmod +x ./run-vm
|
|
|
|
source ./run-vm
|
2012-08-27 17:39:13 +00:00
|
|
|
|
2011-08-09 14:05:40 +00:00
|
|
|
if ! test -e xchg/in-vm-exit; then
|
2008-03-14 13:51:01 +00:00
|
|
|
echo "Virtual machine didn't produce an exit code."
|
|
|
|
exit 1
|
|
|
|
fi
|
2012-08-27 17:39:13 +00:00
|
|
|
|
2016-09-04 13:42:26 +00:00
|
|
|
exitCode="$(cat xchg/in-vm-exit)"
|
|
|
|
if [ "$exitCode" != "0" ]; then
|
|
|
|
exit "$exitCode"
|
|
|
|
fi
|
2008-04-29 12:32:17 +00:00
|
|
|
|
2016-09-04 13:42:26 +00:00
|
|
|
eval "$postVM"
|
2008-03-14 13:51:01 +00:00
|
|
|
'';
|
|
|
|
|
2021-09-29 07:33:14 +00:00
|
|
|
/*
|
|
|
|
A bash script fragment that produces a disk image at `destination`.
|
|
|
|
*/
|
|
|
|
createEmptyImage = {
|
|
|
|
# Disk image size in MiB
|
|
|
|
size,
|
|
|
|
# Name that will be written to ${destination}/nix-support/full-name
|
|
|
|
fullName,
|
|
|
|
# Where to write the image files, defaulting to $out
|
|
|
|
destination ? "$out"
|
|
|
|
}: ''
|
|
|
|
mkdir -p ${destination}
|
|
|
|
diskImage=${destination}/disk-image.qcow2
|
2013-07-31 12:35:53 +00:00
|
|
|
${qemu}/bin/qemu-img create -f qcow2 $diskImage "${toString size}M"
|
2008-03-17 17:08:40 +00:00
|
|
|
|
2021-09-29 07:33:14 +00:00
|
|
|
mkdir ${destination}/nix-support
|
|
|
|
echo "${fullName}" > ${destination}/nix-support/full-name
|
2008-03-17 17:08:40 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
|
2011-10-11 13:22:09 +00:00
|
|
|
defaultCreateRootFS = ''
|
2008-03-17 17:08:40 +00:00
|
|
|
mkdir /mnt
|
2015-01-12 16:42:59 +00:00
|
|
|
${e2fsprogs}/bin/mkfs.ext4 /dev/${hd}
|
2020-11-24 15:29:28 +00:00
|
|
|
${util-linux}/bin/mount -t ext4 /dev/${hd} /mnt
|
2008-03-17 17:08:40 +00:00
|
|
|
|
|
|
|
if test -e /mnt/.debug; then
|
|
|
|
exec ${bash}/bin/sh
|
|
|
|
fi
|
|
|
|
touch /mnt/.debug
|
|
|
|
|
2013-05-08 11:59:28 +00:00
|
|
|
mkdir /mnt/proc /mnt/dev /mnt/sys
|
2008-03-17 17:08:40 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
|
|
/* Run a derivation in a Linux virtual machine (using Qemu/KVM). By
|
|
|
|
default, there is no disk image; the root filesystem is a tmpfs,
|
2016-09-27 23:42:05 +00:00
|
|
|
and the nix store is shared with the host (via the 9P protocol).
|
2013-07-04 22:06:08 +00:00
|
|
|
Thus, any pure Nix derivation should run unmodified, e.g. the
|
|
|
|
call
|
2008-03-17 17:08:40 +00:00
|
|
|
|
|
|
|
runInLinuxVM patchelf
|
|
|
|
|
|
|
|
will build the derivation `patchelf' inside a VM. The attribute
|
|
|
|
`preVM' can optionally contain a shell command to be evaluated
|
|
|
|
*before* the VM is started (i.e., on the host). The attribute
|
|
|
|
`memSize' specifies the memory size of the VM in megabytes,
|
2013-07-04 21:36:17 +00:00
|
|
|
defaulting to 512. The attribute `diskImage' can optionally
|
2008-03-17 17:08:40 +00:00
|
|
|
specify a file system image to be attached to /dev/sda. (Note
|
|
|
|
that currently we expect the image to contain a filesystem, not a
|
|
|
|
full disk image with a partition table etc.)
|
|
|
|
|
|
|
|
If the build fails and Nix is run with the `-K' option, a script
|
|
|
|
`run-vm' will be left behind in the temporary build directory
|
|
|
|
that allows you to boot into the VM and debug it interactively. */
|
2012-08-27 17:39:13 +00:00
|
|
|
|
2018-09-25 08:41:39 +00:00
|
|
|
runInLinuxVM = drv: lib.overrideDerivation drv ({ memSize ? 512, QEMU_OPTS ? "", args, builder, ... }: {
|
2010-08-29 21:27:06 +00:00
|
|
|
requiredSystemFeatures = [ "kvm" ];
|
2008-03-14 13:51:01 +00:00
|
|
|
builder = "${bash}/bin/sh";
|
2008-04-29 12:32:17 +00:00
|
|
|
args = ["-e" (vmRunCommand qemuCommandLinux)];
|
2015-10-06 13:03:26 +00:00
|
|
|
origArgs = args;
|
|
|
|
origBuilder = builder;
|
|
|
|
QEMU_OPTS = "${QEMU_OPTS} -m ${toString memSize}";
|
2016-07-14 12:11:17 +00:00
|
|
|
passAsFile = []; # HACK fix - see https://github.com/NixOS/nixpkgs/issues/16742
|
2008-03-14 13:51:01 +00:00
|
|
|
});
|
|
|
|
|
2012-08-27 17:39:13 +00:00
|
|
|
|
2011-01-19 09:06:12 +00:00
|
|
|
extractFs = {file, fs ? null} :
|
2021-09-30 18:43:31 +00:00
|
|
|
runInLinuxVM (
|
2011-01-19 09:06:12 +00:00
|
|
|
stdenv.mkDerivation {
|
|
|
|
name = "extract-file";
|
2020-11-24 15:29:28 +00:00
|
|
|
buildInputs = [ util-linux ];
|
2011-01-19 09:06:12 +00:00
|
|
|
buildCommand = ''
|
2019-01-29 20:17:44 +00:00
|
|
|
ln -s ${kernel}/lib /lib
|
2016-04-22 07:40:57 +00:00
|
|
|
${kmod}/bin/modprobe loop
|
|
|
|
${kmod}/bin/modprobe ext4
|
|
|
|
${kmod}/bin/modprobe hfs
|
|
|
|
${kmod}/bin/modprobe hfsplus
|
|
|
|
${kmod}/bin/modprobe squashfs
|
|
|
|
${kmod}/bin/modprobe iso9660
|
|
|
|
${kmod}/bin/modprobe ufs
|
|
|
|
${kmod}/bin/modprobe cramfs
|
2011-01-19 09:06:12 +00:00
|
|
|
|
2012-01-18 20:16:00 +00:00
|
|
|
mkdir -p $out
|
|
|
|
mkdir -p tmp
|
2011-01-19 10:59:26 +00:00
|
|
|
mount -o loop,ro,ufstype=44bsd ${lib.optionalString (fs != null) "-t ${fs} "}${file} tmp ||
|
|
|
|
mount -o loop,ro ${lib.optionalString (fs != null) "-t ${fs} "}${file} tmp
|
2011-01-31 18:02:46 +00:00
|
|
|
cp -Rv tmp/* $out/ || exit 0
|
2011-01-19 09:06:12 +00:00
|
|
|
'';
|
|
|
|
});
|
|
|
|
|
2012-08-27 17:39:13 +00:00
|
|
|
|
2011-01-19 09:06:12 +00:00
|
|
|
extractMTDfs = {file, fs ? null} :
|
2021-09-30 18:43:31 +00:00
|
|
|
runInLinuxVM (
|
2011-01-19 09:06:12 +00:00
|
|
|
stdenv.mkDerivation {
|
|
|
|
name = "extract-file-mtd";
|
2021-09-30 18:43:31 +00:00
|
|
|
buildInputs = [ pkgs.util-linux pkgs.mtdutils ];
|
2011-01-19 09:06:12 +00:00
|
|
|
buildCommand = ''
|
2019-01-29 20:17:44 +00:00
|
|
|
ln -s ${kernel}/lib /lib
|
2016-04-22 07:40:57 +00:00
|
|
|
${kmod}/bin/modprobe mtd
|
|
|
|
${kmod}/bin/modprobe mtdram total_size=131072
|
|
|
|
${kmod}/bin/modprobe mtdchar
|
|
|
|
${kmod}/bin/modprobe mtdblock
|
|
|
|
${kmod}/bin/modprobe jffs2
|
|
|
|
${kmod}/bin/modprobe zlib
|
2011-01-19 09:06:12 +00:00
|
|
|
|
2012-01-18 20:16:00 +00:00
|
|
|
mkdir -p $out
|
|
|
|
mkdir -p tmp
|
2011-01-19 09:06:12 +00:00
|
|
|
|
|
|
|
dd if=${file} of=/dev/mtd0
|
|
|
|
mount ${lib.optionalString (fs != null) "-t ${fs} "}/dev/mtdblock0 tmp
|
|
|
|
|
|
|
|
cp -R tmp/* $out/
|
|
|
|
'';
|
|
|
|
});
|
2008-03-14 13:51:01 +00:00
|
|
|
|
2012-08-27 17:39:13 +00:00
|
|
|
|
2008-03-17 17:08:40 +00:00
|
|
|
/* Like runInLinuxVM, but run the build not using the stdenv from
|
|
|
|
the Nix store, but using the tools provided by /bin, /usr/bin
|
|
|
|
etc. from the specified filesystem image, which typically is a
|
|
|
|
filesystem containing a non-NixOS Linux distribution. */
|
2012-08-27 17:39:13 +00:00
|
|
|
|
2013-05-15 05:15:16 +00:00
|
|
|
runInLinuxImage = drv: runInLinuxVM (lib.overrideDerivation drv (attrs: {
|
2008-03-17 17:08:40 +00:00
|
|
|
mountDisk = true;
|
2008-03-14 13:51:01 +00:00
|
|
|
|
2008-03-17 17:08:40 +00:00
|
|
|
/* Mount `image' as the root FS, but use a temporary copy-on-write
|
|
|
|
image since we don't want to (and can't) write to `image'. */
|
|
|
|
preVM = ''
|
2009-03-02 14:31:33 +00:00
|
|
|
diskImage=$(pwd)/disk-image.qcow2
|
2008-03-17 17:08:40 +00:00
|
|
|
origImage=${attrs.diskImage}
|
2009-03-02 14:31:33 +00:00
|
|
|
if test -d "$origImage"; then origImage="$origImage/disk-image.qcow2"; fi
|
2021-10-27 22:05:27 +00:00
|
|
|
${qemu}/bin/qemu-img create -F ${attrs.diskImageFormat} -b "$origImage" -f qcow2 $diskImage
|
2008-03-17 17:08:40 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
/* Inside the VM, run the stdenv setup script normally, but at the
|
|
|
|
very end set $PATH and $SHELL to the `native' paths for the
|
|
|
|
distribution inside the VM. */
|
|
|
|
postHook = ''
|
|
|
|
PATH=/usr/bin:/bin:/usr/sbin:/sbin
|
|
|
|
SHELL=/bin/sh
|
2008-03-17 17:29:07 +00:00
|
|
|
eval "$origPostHook"
|
2008-03-17 17:08:40 +00:00
|
|
|
'';
|
|
|
|
|
2008-03-17 17:29:07 +00:00
|
|
|
origPostHook = if attrs ? postHook then attrs.postHook else "";
|
|
|
|
|
2008-03-17 17:08:40 +00:00
|
|
|
/* Don't run Nix-specific build steps like patchelf. */
|
|
|
|
fixupPhase = "true";
|
2013-05-15 05:15:16 +00:00
|
|
|
}));
|
2008-03-17 17:08:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Create a filesystem image of the specified size and fill it with
|
|
|
|
a set of RPM packages. */
|
2012-08-27 17:39:13 +00:00
|
|
|
|
2008-03-14 13:51:01 +00:00
|
|
|
fillDiskWithRPMs =
|
2011-08-08 14:01:16 +00:00
|
|
|
{ size ? 4096, rpms, name, fullName, preInstall ? "", postInstall ? ""
|
2011-10-11 13:22:09 +00:00
|
|
|
, runScripts ? true, createRootFS ? defaultCreateRootFS
|
2016-03-30 07:47:09 +00:00
|
|
|
, QEMU_OPTS ? "", memSize ? 512
|
2013-05-08 11:59:28 +00:00
|
|
|
, unifiedSystemDir ? false
|
2011-08-08 14:01:16 +00:00
|
|
|
}:
|
2012-08-27 17:39:13 +00:00
|
|
|
|
2008-03-14 13:51:01 +00:00
|
|
|
runInLinuxVM (stdenv.mkDerivation {
|
2016-03-30 07:47:09 +00:00
|
|
|
inherit name preInstall postInstall rpms QEMU_OPTS memSize;
|
2008-03-17 17:08:40 +00:00
|
|
|
preVM = createEmptyImage {inherit size fullName;};
|
2008-03-14 13:51:01 +00:00
|
|
|
|
|
|
|
buildCommand = ''
|
2008-03-17 17:08:40 +00:00
|
|
|
${createRootFS}
|
2008-03-14 13:51:01 +00:00
|
|
|
|
2008-03-18 21:14:02 +00:00
|
|
|
chroot=$(type -tP chroot)
|
2012-08-27 17:39:13 +00:00
|
|
|
|
2013-05-08 11:59:28 +00:00
|
|
|
# Make the Nix store available in /mnt, because that's where the RPMs live.
|
2016-09-27 23:42:05 +00:00
|
|
|
mkdir -p /mnt${storeDir}
|
2020-11-24 15:29:28 +00:00
|
|
|
${util-linux}/bin/mount -o bind ${storeDir} /mnt${storeDir}
|
2013-05-08 11:59:28 +00:00
|
|
|
|
|
|
|
# Newer distributions like Fedora 18 require /lib etc. to be
|
|
|
|
# symlinked to /usr.
|
|
|
|
${lib.optionalString unifiedSystemDir ''
|
|
|
|
mkdir -p /mnt/usr/bin /mnt/usr/sbin /mnt/usr/lib /mnt/usr/lib64
|
|
|
|
ln -s /usr/bin /mnt/bin
|
|
|
|
ln -s /usr/sbin /mnt/sbin
|
|
|
|
ln -s /usr/lib /mnt/lib
|
|
|
|
ln -s /usr/lib64 /mnt/lib64
|
2020-11-24 15:29:28 +00:00
|
|
|
${util-linux}/bin/mount -t proc none /mnt/proc
|
2013-05-08 11:59:28 +00:00
|
|
|
''}
|
|
|
|
|
2008-03-18 14:56:47 +00:00
|
|
|
echo "unpacking RPMs..."
|
2015-02-10 10:24:22 +00:00
|
|
|
set +o pipefail
|
2008-03-18 14:56:47 +00:00
|
|
|
for i in $rpms; do
|
|
|
|
echo "$i..."
|
2019-12-08 17:13:40 +00:00
|
|
|
${rpm}/bin/rpm2cpio "$i" | chroot /mnt ${cpio}/bin/cpio -i --make-directories --unconditional
|
2008-03-18 14:56:47 +00:00
|
|
|
done
|
2008-03-14 13:51:01 +00:00
|
|
|
|
2008-03-18 14:56:47 +00:00
|
|
|
eval "$preInstall"
|
2008-03-14 13:51:01 +00:00
|
|
|
|
2008-03-18 21:14:02 +00:00
|
|
|
echo "initialising RPM DB..."
|
2008-05-21 09:35:15 +00:00
|
|
|
PATH=/usr/bin:/bin:/usr/sbin:/sbin $chroot /mnt \
|
|
|
|
ldconfig -v || true
|
2008-03-18 21:14:02 +00:00
|
|
|
PATH=/usr/bin:/bin:/usr/sbin:/sbin $chroot /mnt \
|
|
|
|
rpm --initdb
|
|
|
|
|
2020-11-24 15:29:28 +00:00
|
|
|
${util-linux}/bin/mount -o bind /tmp /mnt/tmp
|
2012-08-27 17:39:13 +00:00
|
|
|
|
2008-03-18 14:56:47 +00:00
|
|
|
echo "installing RPMs..."
|
|
|
|
PATH=/usr/bin:/bin:/usr/sbin:/sbin $chroot /mnt \
|
2015-02-12 15:55:44 +00:00
|
|
|
rpm -iv --nosignature ${if runScripts then "" else "--noscripts"} $rpms
|
2008-03-14 13:51:01 +00:00
|
|
|
|
|
|
|
echo "running post-install script..."
|
|
|
|
eval "$postInstall"
|
2012-08-27 17:39:13 +00:00
|
|
|
|
2008-03-17 17:08:40 +00:00
|
|
|
rm /mnt/.debug
|
2011-10-11 13:22:09 +00:00
|
|
|
|
2020-11-24 15:29:28 +00:00
|
|
|
${util-linux}/bin/umount /mnt${storeDir} /mnt/tmp ${lib.optionalString unifiedSystemDir "/mnt/proc"}
|
|
|
|
${util-linux}/bin/umount /mnt
|
2008-03-14 13:51:01 +00:00
|
|
|
'';
|
2008-11-12 17:19:12 +00:00
|
|
|
|
2011-08-08 14:01:16 +00:00
|
|
|
passthru = { inherit fullName; };
|
2008-03-14 13:51:01 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
2008-03-17 17:08:40 +00:00
|
|
|
/* Generate a script that can be used to run an interactive session
|
|
|
|
in the given image. */
|
2012-08-27 17:39:13 +00:00
|
|
|
|
2008-03-14 13:51:01 +00:00
|
|
|
makeImageTestScript = image: writeScript "image-test" ''
|
|
|
|
#! ${bash}/bin/sh
|
|
|
|
if test -z "$1"; then
|
|
|
|
echo "Syntax: $0 <copy-on-write-temp-file>"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
diskImage="$1"
|
|
|
|
if ! test -e "$diskImage"; then
|
2013-07-31 12:35:53 +00:00
|
|
|
${qemu}/bin/qemu-img create -b ${image}/disk-image.qcow2 -f qcow2 "$diskImage"
|
2008-03-14 13:51:01 +00:00
|
|
|
fi
|
|
|
|
export TMPDIR=$(mktemp -d)
|
|
|
|
export out=/dummy
|
|
|
|
export origBuilder=
|
|
|
|
export origArgs=
|
2011-08-09 14:05:40 +00:00
|
|
|
mkdir $TMPDIR/xchg
|
|
|
|
export > $TMPDIR/xchg/saved-env
|
2008-03-18 14:56:47 +00:00
|
|
|
mountDisk=1
|
2008-04-29 12:32:17 +00:00
|
|
|
${qemuCommandLinux}
|
2008-03-14 13:51:01 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
|
2008-03-17 17:08:40 +00:00
|
|
|
/* Build RPM packages from the tarball `src' in the Linux
|
|
|
|
distribution installed in the filesystem `diskImage'. The
|
|
|
|
tarball must contain an RPM specfile. */
|
2012-08-27 17:39:13 +00:00
|
|
|
|
2008-03-18 21:14:02 +00:00
|
|
|
buildRPM = attrs: runInLinuxImage (stdenv.mkDerivation ({
|
2021-12-27 21:44:39 +00:00
|
|
|
prePhases = [ "prepareImagePhase" "sysInfoPhase" ];
|
2021-08-20 21:31:26 +00:00
|
|
|
dontConfigure = true;
|
2008-03-18 21:14:02 +00:00
|
|
|
|
|
|
|
outDir = "rpms/${attrs.diskImage.name}";
|
2008-04-09 06:37:59 +00:00
|
|
|
|
|
|
|
prepareImagePhase = ''
|
2008-04-12 05:19:37 +00:00
|
|
|
if test -n "$extraRPMs"; then
|
2009-10-01 07:25:50 +00:00
|
|
|
for rpmdir in $extraRPMs ; do
|
|
|
|
rpm -iv $(ls $rpmdir/rpms/*/*.rpm | grep -v 'src\.rpm' | sort | head -1)
|
|
|
|
done
|
2008-04-12 05:03:36 +00:00
|
|
|
fi
|
2008-04-09 06:37:59 +00:00
|
|
|
'';
|
2012-08-27 17:39:13 +00:00
|
|
|
|
2008-03-17 17:29:07 +00:00
|
|
|
sysInfoPhase = ''
|
2008-09-12 12:06:40 +00:00
|
|
|
echo "System/kernel: $(uname -a)"
|
2008-04-09 12:51:54 +00:00
|
|
|
if test -e /etc/fedora-release; then echo "Fedora release: $(cat /etc/fedora-release)"; fi
|
|
|
|
if test -e /etc/SuSE-release; then echo "SUSE release: $(cat /etc/SuSE-release)"; fi
|
|
|
|
header "installed RPM packages"
|
2008-03-17 17:29:07 +00:00
|
|
|
rpm -qa --qf "%{Name}-%{Version}-%{Release} (%{Arch}; %{Distribution}; %{Vendor})\n"
|
|
|
|
stopNest
|
|
|
|
'';
|
2012-08-27 17:39:13 +00:00
|
|
|
|
2008-03-17 17:08:40 +00:00
|
|
|
buildPhase = ''
|
2008-03-18 12:54:21 +00:00
|
|
|
eval "$preBuild"
|
2008-03-18 14:56:47 +00:00
|
|
|
|
2021-12-22 23:29:48 +00:00
|
|
|
srcName="$(rpmspec --srpm -q --qf '%{source}' *.spec)"
|
2008-03-18 12:54:21 +00:00
|
|
|
cp "$src" "$srcName" # `ln' doesn't work always work: RPM requires that the file is owned by root
|
|
|
|
|
2008-11-27 18:58:37 +00:00
|
|
|
export HOME=/tmp/home
|
|
|
|
mkdir $HOME
|
|
|
|
|
|
|
|
rpmout=/tmp/rpmout
|
|
|
|
mkdir $rpmout $rpmout/SPECS $rpmout/BUILD $rpmout/RPMS $rpmout/SRPMS
|
|
|
|
|
|
|
|
echo "%_topdir $rpmout" >> $HOME/.rpmmacros
|
2012-08-27 17:39:13 +00:00
|
|
|
|
2013-10-23 10:49:28 +00:00
|
|
|
if [ `uname -m` = i686 ]; then extra="--target i686-linux"; fi
|
|
|
|
rpmbuild -vv $extra -ta "$srcName"
|
2008-03-14 13:51:01 +00:00
|
|
|
|
2008-03-18 12:54:21 +00:00
|
|
|
eval "$postBuild"
|
2008-03-17 17:08:40 +00:00
|
|
|
'';
|
2008-03-14 13:51:01 +00:00
|
|
|
|
2008-03-17 17:08:40 +00:00
|
|
|
installPhase = ''
|
2008-11-13 12:45:08 +00:00
|
|
|
eval "$preInstall"
|
2011-05-02 14:55:16 +00:00
|
|
|
|
2012-01-18 20:16:00 +00:00
|
|
|
mkdir -p $out/$outDir
|
2008-11-27 18:58:37 +00:00
|
|
|
find $rpmout -name "*.rpm" -exec cp {} $out/$outDir \;
|
2008-03-18 12:54:21 +00:00
|
|
|
|
2008-03-18 21:14:02 +00:00
|
|
|
for i in $out/$outDir/*.rpm; do
|
2008-03-18 12:54:21 +00:00
|
|
|
header "Generated RPM/SRPM: $i"
|
|
|
|
rpm -qip $i
|
|
|
|
stopNest
|
|
|
|
done
|
2008-11-13 12:45:08 +00:00
|
|
|
|
|
|
|
eval "$postInstall"
|
2008-03-18 21:14:02 +00:00
|
|
|
''; # */
|
|
|
|
} // attrs));
|
2008-03-14 13:51:01 +00:00
|
|
|
|
|
|
|
|
2008-03-17 17:08:40 +00:00
|
|
|
/* Create a filesystem image of the specified size and fill it with
|
|
|
|
a set of Debian packages. `debs' must be a list of list of
|
|
|
|
.deb files, namely, the Debian packages grouped together into
|
|
|
|
strongly connected components. See deb/deb-closure.nix. */
|
|
|
|
|
2008-03-14 13:51:01 +00:00
|
|
|
fillDiskWithDebs =
|
2016-05-11 13:40:44 +00:00
|
|
|
{ size ? 4096, debs, name, fullName, postInstall ? null, createRootFS ? defaultCreateRootFS
|
|
|
|
, QEMU_OPTS ? "", memSize ? 512 }:
|
2012-08-27 17:39:13 +00:00
|
|
|
|
2008-03-14 13:51:01 +00:00
|
|
|
runInLinuxVM (stdenv.mkDerivation {
|
2016-05-11 13:40:44 +00:00
|
|
|
inherit name postInstall QEMU_OPTS memSize;
|
2008-03-14 13:51:01 +00:00
|
|
|
|
|
|
|
debs = (lib.intersperse "|" debs);
|
|
|
|
|
2008-03-17 17:08:40 +00:00
|
|
|
preVM = createEmptyImage {inherit size fullName;};
|
2008-03-14 13:51:01 +00:00
|
|
|
|
|
|
|
buildCommand = ''
|
2008-03-17 17:08:40 +00:00
|
|
|
${createRootFS}
|
2008-03-14 13:51:01 +00:00
|
|
|
|
2021-09-30 18:43:31 +00:00
|
|
|
PATH=$PATH:${lib.makeBinPath [ pkgs.dpkg pkgs.glibc pkgs.xz ]}
|
2008-03-14 13:51:01 +00:00
|
|
|
|
|
|
|
# Unpack the .debs. We do this to prevent pre-install scripts
|
|
|
|
# (which have lots of circular dependencies) from barfing.
|
|
|
|
echo "unpacking Debs..."
|
2012-08-27 17:39:13 +00:00
|
|
|
|
2008-03-14 13:51:01 +00:00
|
|
|
for deb in $debs; do
|
|
|
|
if test "$deb" != "|"; then
|
|
|
|
echo "$deb..."
|
|
|
|
dpkg-deb --extract "$deb" /mnt
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
# Make the Nix store available in /mnt, because that's where the .debs live.
|
2016-09-27 23:42:05 +00:00
|
|
|
mkdir -p /mnt/inst${storeDir}
|
2020-11-24 15:29:28 +00:00
|
|
|
${util-linux}/bin/mount -o bind ${storeDir} /mnt/inst${storeDir}
|
|
|
|
${util-linux}/bin/mount -o bind /proc /mnt/proc
|
|
|
|
${util-linux}/bin/mount -o bind /dev /mnt/dev
|
2012-08-27 17:39:13 +00:00
|
|
|
|
2008-03-14 13:51:01 +00:00
|
|
|
# Misc. files/directories assumed by various packages.
|
2008-11-12 17:15:09 +00:00
|
|
|
echo "initialising Dpkg DB..."
|
2008-03-14 13:51:01 +00:00
|
|
|
touch /mnt/etc/shells
|
|
|
|
touch /mnt/var/lib/dpkg/status
|
|
|
|
touch /mnt/var/lib/dpkg/available
|
|
|
|
touch /mnt/var/lib/dpkg/diversions
|
|
|
|
|
|
|
|
# Now install the .debs. This is basically just to register
|
|
|
|
# them with dpkg and to make their pre/post-install scripts
|
|
|
|
# run.
|
|
|
|
echo "installing Debs..."
|
|
|
|
|
|
|
|
export DEBIAN_FRONTEND=noninteractive
|
2012-08-27 17:39:13 +00:00
|
|
|
|
2008-03-14 13:51:01 +00:00
|
|
|
oldIFS="$IFS"
|
|
|
|
IFS="|"
|
|
|
|
for component in $debs; do
|
|
|
|
IFS="$oldIFS"
|
|
|
|
echo
|
|
|
|
echo ">>> INSTALLING COMPONENT: $component"
|
|
|
|
debs=
|
|
|
|
for i in $component; do
|
|
|
|
debs="$debs /inst/$i";
|
|
|
|
done
|
|
|
|
chroot=$(type -tP chroot)
|
2013-07-29 05:33:58 +00:00
|
|
|
|
|
|
|
# Create a fake start-stop-daemon script, as done in debootstrap.
|
|
|
|
mv "/mnt/sbin/start-stop-daemon" "/mnt/sbin/start-stop-daemon.REAL"
|
|
|
|
echo "#!/bin/true" > "/mnt/sbin/start-stop-daemon"
|
|
|
|
chmod 755 "/mnt/sbin/start-stop-daemon"
|
|
|
|
|
2008-03-14 13:51:01 +00:00
|
|
|
PATH=/usr/bin:/bin:/usr/sbin:/sbin $chroot /mnt \
|
2011-02-14 16:52:32 +00:00
|
|
|
/usr/bin/dpkg --install --force-all $debs < /dev/null || true
|
2013-07-29 05:33:58 +00:00
|
|
|
|
|
|
|
# Move the real start-stop-daemon back into its place.
|
|
|
|
mv "/mnt/sbin/start-stop-daemon.REAL" "/mnt/sbin/start-stop-daemon"
|
2008-03-14 13:51:01 +00:00
|
|
|
done
|
2012-08-27 17:39:13 +00:00
|
|
|
|
2008-03-14 13:51:01 +00:00
|
|
|
echo "running post-install script..."
|
|
|
|
eval "$postInstall"
|
2009-10-02 09:34:37 +00:00
|
|
|
ln -sf dash /mnt/bin/sh
|
|
|
|
|
2008-03-14 13:51:01 +00:00
|
|
|
rm /mnt/.debug
|
2012-08-27 17:39:13 +00:00
|
|
|
|
2020-11-24 15:29:28 +00:00
|
|
|
${util-linux}/bin/umount /mnt/inst${storeDir}
|
|
|
|
${util-linux}/bin/umount /mnt/proc
|
|
|
|
${util-linux}/bin/umount /mnt/dev
|
|
|
|
${util-linux}/bin/umount /mnt
|
2008-03-14 13:51:01 +00:00
|
|
|
'';
|
2008-11-12 17:19:12 +00:00
|
|
|
|
2011-08-08 14:01:16 +00:00
|
|
|
passthru = { inherit fullName; };
|
2008-03-14 13:51:01 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
2008-04-09 12:02:15 +00:00
|
|
|
/* Generate a Nix expression containing fetchurl calls for the
|
|
|
|
closure of a set of top-level RPM packages from the
|
2008-04-11 11:52:40 +00:00
|
|
|
`primary.xml.gz' file of a Fedora or openSUSE distribution. */
|
2012-08-27 17:39:13 +00:00
|
|
|
|
2008-04-09 12:02:15 +00:00
|
|
|
rpmClosureGenerator =
|
2011-10-11 13:22:09 +00:00
|
|
|
{name, packagesLists, urlPrefixes, packages, archs ? []}:
|
2012-08-27 17:46:51 +00:00
|
|
|
assert (builtins.length packagesLists) == (builtins.length urlPrefixes);
|
2021-01-17 14:43:14 +00:00
|
|
|
runCommand "${name}.nix" {
|
|
|
|
nativeBuildInputs = [ buildPackages.perl buildPackages.perlPackages.XMLSimple ];
|
|
|
|
inherit archs;
|
|
|
|
} ''
|
2011-10-11 13:22:09 +00:00
|
|
|
${lib.concatImapStrings (i: pl: ''
|
|
|
|
gunzip < ${pl} > ./packages_${toString i}.xml
|
|
|
|
'') packagesLists}
|
2008-04-09 12:02:15 +00:00
|
|
|
perl -w ${rpm/rpm-closure.pl} \
|
2011-10-11 13:22:09 +00:00
|
|
|
${lib.concatImapStrings (i: pl: "./packages_${toString i}.xml ${pl.snd} " ) (lib.zipLists packagesLists urlPrefixes)} \
|
|
|
|
${toString packages} > $out
|
2008-04-09 12:02:15 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
|
|
/* Helper function that combines rpmClosureGenerator and
|
|
|
|
fillDiskWithRPMs to generate a disk image from a set of package
|
|
|
|
names. */
|
2012-08-27 17:39:13 +00:00
|
|
|
|
2008-04-09 12:02:15 +00:00
|
|
|
makeImageFromRPMDist =
|
2011-10-11 13:22:09 +00:00
|
|
|
{ name, fullName, size ? 4096
|
|
|
|
, urlPrefix ? "", urlPrefixes ? [urlPrefix]
|
|
|
|
, packagesList ? "", packagesLists ? [packagesList]
|
2010-06-14 18:42:18 +00:00
|
|
|
, packages, extraPackages ? []
|
|
|
|
, preInstall ? "", postInstall ? "", archs ? ["noarch" "i386"]
|
2013-05-08 11:59:28 +00:00
|
|
|
, runScripts ? true, createRootFS ? defaultCreateRootFS
|
2016-03-30 07:47:09 +00:00
|
|
|
, QEMU_OPTS ? "", memSize ? 512
|
2013-05-08 11:59:28 +00:00
|
|
|
, unifiedSystemDir ? false }:
|
2008-04-09 12:02:15 +00:00
|
|
|
|
|
|
|
fillDiskWithRPMs {
|
2016-03-30 07:47:09 +00:00
|
|
|
inherit name fullName size preInstall postInstall runScripts createRootFS unifiedSystemDir QEMU_OPTS memSize;
|
2008-04-09 12:02:15 +00:00
|
|
|
rpms = import (rpmClosureGenerator {
|
2011-10-11 13:22:09 +00:00
|
|
|
inherit name packagesLists urlPrefixes archs;
|
2010-06-14 18:42:18 +00:00
|
|
|
packages = packages ++ extraPackages;
|
2011-08-08 14:01:16 +00:00
|
|
|
}) { inherit fetchurl; };
|
2008-04-09 12:02:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* Like `rpmClosureGenerator', but now for Debian/Ubuntu releases
|
|
|
|
(i.e. generate a closure from a Packages.bz2 file). */
|
|
|
|
|
|
|
|
debClosureGenerator =
|
2012-08-27 17:46:51 +00:00
|
|
|
{name, packagesLists, urlPrefix, packages}:
|
2012-08-27 17:39:13 +00:00
|
|
|
|
2021-01-17 14:43:14 +00:00
|
|
|
runCommand "${name}.nix"
|
|
|
|
{ nativeBuildInputs = [ buildPackages.perl buildPackages.dpkg ]; } ''
|
2012-08-27 17:46:51 +00:00
|
|
|
for i in ${toString packagesLists}; do
|
|
|
|
echo "adding $i..."
|
2015-05-28 20:55:55 +00:00
|
|
|
case $i in
|
|
|
|
*.xz | *.lzma)
|
|
|
|
xz -d < $i >> ./Packages
|
|
|
|
;;
|
|
|
|
*.bz2)
|
|
|
|
bunzip2 < $i >> ./Packages
|
|
|
|
;;
|
|
|
|
*.gz)
|
|
|
|
gzip -dc < $i >> ./Packages
|
|
|
|
;;
|
|
|
|
esac
|
2012-08-27 17:46:51 +00:00
|
|
|
done
|
2008-09-12 13:17:52 +00:00
|
|
|
|
|
|
|
# Work around this bug: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=452279
|
2012-03-06 18:49:44 +00:00
|
|
|
sed -i ./Packages -e s/x86_64-linux-gnu/x86-64-linux-gnu/g
|
2008-09-12 13:17:52 +00:00
|
|
|
|
2012-12-04 18:56:31 +00:00
|
|
|
perl -w ${deb/deb-closure.pl} \
|
2008-04-09 12:02:15 +00:00
|
|
|
./Packages ${urlPrefix} ${toString packages} > $out
|
|
|
|
'';
|
2012-08-27 17:39:13 +00:00
|
|
|
|
2008-04-09 12:02:15 +00:00
|
|
|
|
|
|
|
/* Helper function that combines debClosureGenerator and
|
|
|
|
fillDiskWithDebs to generate a disk image from a set of package
|
|
|
|
names. */
|
2012-08-27 17:39:13 +00:00
|
|
|
|
2008-04-09 12:02:15 +00:00
|
|
|
makeImageFromDebDist =
|
2012-08-27 17:46:51 +00:00
|
|
|
{ name, fullName, size ? 4096, urlPrefix
|
|
|
|
, packagesList ? "", packagesLists ? [packagesList]
|
2016-05-11 13:40:44 +00:00
|
|
|
, packages, extraPackages ? [], postInstall ? ""
|
2019-06-09 17:05:30 +00:00
|
|
|
, extraDebs ? [], createRootFS ? defaultCreateRootFS
|
2016-05-11 13:40:44 +00:00
|
|
|
, QEMU_OPTS ? "", memSize ? 512 }:
|
2008-04-09 12:02:15 +00:00
|
|
|
|
2008-11-12 17:15:09 +00:00
|
|
|
let
|
|
|
|
expr = debClosureGenerator {
|
2012-08-27 17:46:51 +00:00
|
|
|
inherit name packagesLists urlPrefix;
|
2010-06-14 18:42:18 +00:00
|
|
|
packages = packages ++ extraPackages;
|
2008-11-12 17:15:09 +00:00
|
|
|
};
|
|
|
|
in
|
|
|
|
(fillDiskWithDebs {
|
2019-06-09 17:05:30 +00:00
|
|
|
inherit name fullName size postInstall createRootFS QEMU_OPTS memSize;
|
2017-07-27 18:24:42 +00:00
|
|
|
debs = import expr {inherit fetchurl;} ++ extraDebs;
|
2008-11-12 17:15:09 +00:00
|
|
|
}) // {inherit expr;};
|
2008-04-09 12:02:15 +00:00
|
|
|
|
|
|
|
|
2010-06-14 18:42:18 +00:00
|
|
|
/* The set of supported RPM-based distributions. */
|
2012-08-27 17:39:13 +00:00
|
|
|
|
2010-06-14 18:42:18 +00:00
|
|
|
rpmDistros = {
|
2008-04-09 12:02:15 +00:00
|
|
|
|
2018-02-19 10:16:31 +00:00
|
|
|
# Note: no i386 release for Fedora >= 26
|
|
|
|
fedora26x86_64 =
|
|
|
|
let version = "26";
|
2019-08-13 21:52:01 +00:00
|
|
|
in {
|
2018-02-19 10:16:31 +00:00
|
|
|
name = "fedora-${version}-x86_64";
|
|
|
|
fullName = "Fedora ${version} (x86_64)";
|
|
|
|
packagesList = fetchurl rec {
|
|
|
|
url = "mirror://fedora/linux/releases/${version}/Everything/x86_64/os/repodata/${sha256}-primary.xml.gz";
|
|
|
|
sha256 = "880055a50c05b20641530d09b23f64501a000b2f92fe252417c530178730a95e";
|
|
|
|
};
|
|
|
|
urlPrefix = "mirror://fedora/linux/releases/${version}/Everything/x86_64/os";
|
|
|
|
archs = ["noarch" "x86_64"];
|
|
|
|
packages = commonFedoraPackages ++ [ "cronie" "util-linux" ];
|
|
|
|
unifiedSystemDir = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
fedora27x86_64 =
|
|
|
|
let version = "27";
|
2019-08-13 21:52:01 +00:00
|
|
|
in {
|
2018-02-19 10:16:31 +00:00
|
|
|
name = "fedora-${version}-x86_64";
|
|
|
|
fullName = "Fedora ${version} (x86_64)";
|
|
|
|
packagesList = fetchurl rec {
|
|
|
|
url = "mirror://fedora/linux/releases/${version}/Everything/x86_64/os/repodata/${sha256}-primary.xml.gz";
|
|
|
|
sha256 = "48986ce4583cd09825c6d437150314446f0f49fa1a1bd62dcfa1085295030fe9";
|
|
|
|
};
|
|
|
|
urlPrefix = "mirror://fedora/linux/releases/${version}/Everything/x86_64/os";
|
|
|
|
archs = ["noarch" "x86_64"];
|
|
|
|
packages = commonFedoraPackages ++ [ "cronie" "util-linux" ];
|
|
|
|
unifiedSystemDir = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
centos6i386 =
|
|
|
|
let version = "6.9";
|
|
|
|
in rec {
|
|
|
|
name = "centos-${version}-i386";
|
|
|
|
fullName = "CentOS ${version} (i386)";
|
2019-08-20 20:40:07 +00:00
|
|
|
urlPrefix = "mirror://centos/${version}/os/i386";
|
2018-02-19 10:16:31 +00:00
|
|
|
packagesList = fetchurl rec {
|
|
|
|
url = "${urlPrefix}/repodata/${sha256}-primary.xml.gz";
|
|
|
|
sha256 = "b826a45082ef68340325c0855f3d2e5d5a4d0f77d28ba3b871791d6f14a97aeb";
|
|
|
|
};
|
|
|
|
archs = ["noarch" "i386"];
|
|
|
|
packages = commonCentOSPackages ++ [ "procps" ];
|
|
|
|
};
|
|
|
|
|
|
|
|
centos6x86_64 =
|
|
|
|
let version = "6.9";
|
|
|
|
in rec {
|
|
|
|
name = "centos-${version}-x86_64";
|
|
|
|
fullName = "CentOS ${version} (x86_64)";
|
2019-08-20 20:40:07 +00:00
|
|
|
urlPrefix = "mirror://centos/${version}/os/x86_64";
|
2018-02-19 10:16:31 +00:00
|
|
|
packagesList = fetchurl rec {
|
|
|
|
url = "${urlPrefix}/repodata/${sha256}-primary.xml.gz";
|
|
|
|
sha256 = "ed2b2d4ac98d774d4cd3e91467e1532f7e8b0275cfc91a0d214b532dcaf1e979";
|
|
|
|
};
|
|
|
|
archs = ["noarch" "x86_64"];
|
|
|
|
packages = commonCentOSPackages ++ [ "procps" ];
|
2013-07-05 15:52:42 +00:00
|
|
|
};
|
2016-05-24 10:35:39 +00:00
|
|
|
|
|
|
|
# Note: no i386 release for 7.x
|
2018-02-19 10:16:31 +00:00
|
|
|
centos7x86_64 =
|
|
|
|
let version = "7.4.1708";
|
|
|
|
in rec {
|
|
|
|
name = "centos-${version}-x86_64";
|
|
|
|
fullName = "CentOS ${version} (x86_64)";
|
2019-08-20 20:40:07 +00:00
|
|
|
urlPrefix = "mirror://centos/${version}/os/x86_64";
|
2018-02-19 10:16:31 +00:00
|
|
|
packagesList = fetchurl rec {
|
|
|
|
url = "${urlPrefix}/repodata/${sha256}-primary.xml.gz";
|
|
|
|
sha256 = "b686d3a0f337323e656d9387b9a76ce6808b26255fc3a138b1a87d3b1cb95ed5";
|
|
|
|
};
|
|
|
|
archs = ["noarch" "x86_64"];
|
|
|
|
packages = commonCentOSPackages ++ [ "procps-ng" ];
|
2017-11-28 03:06:58 +00:00
|
|
|
};
|
2010-06-14 18:42:18 +00:00
|
|
|
};
|
2009-09-24 07:40:30 +00:00
|
|
|
|
2010-06-14 18:42:18 +00:00
|
|
|
|
|
|
|
/* The set of supported Dpkg-based distributions. */
|
2012-08-27 17:39:13 +00:00
|
|
|
|
2019-08-13 21:52:01 +00:00
|
|
|
debDistros = {
|
2014-05-03 15:51:26 +00:00
|
|
|
ubuntu1404i386 = {
|
|
|
|
name = "ubuntu-14.04-trusty-i386";
|
|
|
|
fullName = "Ubuntu 14.04 Trusty (i386)";
|
|
|
|
packagesLists =
|
|
|
|
[ (fetchurl {
|
2020-04-01 01:11:51 +00:00
|
|
|
url = "mirror://ubuntu/dists/trusty/main/binary-i386/Packages.bz2";
|
2018-02-19 10:16:31 +00:00
|
|
|
sha256 = "1d5y3v3v079gdq45hc07ja0bjlmzqfwdwwlq0brwxi8m75k3iz7x";
|
2014-05-03 15:51:26 +00:00
|
|
|
})
|
|
|
|
(fetchurl {
|
2020-04-01 01:11:51 +00:00
|
|
|
url = "mirror://ubuntu/dists/trusty/universe/binary-i386/Packages.bz2";
|
2018-02-19 10:16:31 +00:00
|
|
|
sha256 = "03x9w92by320rfklrqhcl3qpwmnxds9c8ijl5zhcb21d6dcz5z1a";
|
2014-05-03 15:51:26 +00:00
|
|
|
})
|
|
|
|
];
|
2020-04-01 01:11:51 +00:00
|
|
|
urlPrefix = "mirror://ubuntu";
|
2014-05-03 15:51:26 +00:00
|
|
|
packages = commonDebPackages ++ [ "diffutils" "libc-bin" ];
|
|
|
|
};
|
|
|
|
|
|
|
|
ubuntu1404x86_64 = {
|
|
|
|
name = "ubuntu-14.04-trusty-amd64";
|
|
|
|
fullName = "Ubuntu 14.04 Trusty (amd64)";
|
2018-02-19 10:16:31 +00:00
|
|
|
packagesLists =
|
2014-05-03 15:51:26 +00:00
|
|
|
[ (fetchurl {
|
2020-04-01 01:11:51 +00:00
|
|
|
url = "mirror://ubuntu/dists/trusty/main/binary-amd64/Packages.bz2";
|
2018-02-19 10:16:31 +00:00
|
|
|
sha256 = "1hhzbyqfr5i0swahwnl5gfp5l9p9hspywb1vpihr3b74p1z935bh";
|
2014-05-03 15:51:26 +00:00
|
|
|
})
|
|
|
|
(fetchurl {
|
2020-04-01 01:11:51 +00:00
|
|
|
url = "mirror://ubuntu/dists/trusty/universe/binary-amd64/Packages.bz2";
|
2018-02-19 10:16:31 +00:00
|
|
|
sha256 = "04560ba8s4z4v5iawknagrkn9q1nzvpn081ycmqvhh73p3p3g1jm";
|
2015-11-25 14:40:08 +00:00
|
|
|
})
|
|
|
|
];
|
2020-04-01 01:11:51 +00:00
|
|
|
urlPrefix = "mirror://ubuntu";
|
2015-11-25 14:40:08 +00:00
|
|
|
packages = commonDebPackages ++ [ "diffutils" "libc-bin" ];
|
2016-04-29 10:50:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
ubuntu1604i386 = {
|
|
|
|
name = "ubuntu-16.04-xenial-i386";
|
|
|
|
fullName = "Ubuntu 16.04 Xenial (i386)";
|
|
|
|
packagesLists =
|
|
|
|
[ (fetchurl {
|
2020-04-01 01:11:51 +00:00
|
|
|
url = "mirror://ubuntu/dists/xenial/main/binary-i386/Packages.xz";
|
2016-04-29 10:50:27 +00:00
|
|
|
sha256 = "13r75sp4slqy8w32y5dnr7pp7p3cfvavyr1g7gwnlkyrq4zx4ahy";
|
|
|
|
})
|
|
|
|
(fetchurl {
|
2020-04-01 01:11:51 +00:00
|
|
|
url = "mirror://ubuntu/dists/xenial/universe/binary-i386/Packages.xz";
|
2016-04-29 10:50:27 +00:00
|
|
|
sha256 = "14fid1rqm3sc0wlygcvn0yx5aljf51c2jpd4x0zxij4019316hsh";
|
|
|
|
})
|
|
|
|
];
|
2020-04-01 01:11:51 +00:00
|
|
|
urlPrefix = "mirror://ubuntu";
|
2016-04-29 10:50:27 +00:00
|
|
|
packages = commonDebPackages ++ [ "diffutils" "libc-bin" ];
|
|
|
|
};
|
|
|
|
|
|
|
|
ubuntu1604x86_64 = {
|
|
|
|
name = "ubuntu-16.04-xenial-amd64";
|
|
|
|
fullName = "Ubuntu 16.04 Xenial (amd64)";
|
2018-02-19 10:16:31 +00:00
|
|
|
packagesLists =
|
2016-04-29 10:50:27 +00:00
|
|
|
[ (fetchurl {
|
2020-04-01 01:11:51 +00:00
|
|
|
url = "mirror://ubuntu/dists/xenial/main/binary-amd64/Packages.xz";
|
2016-04-29 10:50:27 +00:00
|
|
|
sha256 = "110qnkhjkkwm316fbig3aivm2595ydz6zskc4ld5cr8ngcrqm1bn";
|
|
|
|
})
|
|
|
|
(fetchurl {
|
2020-04-01 01:11:51 +00:00
|
|
|
url = "mirror://ubuntu/dists/xenial/universe/binary-amd64/Packages.xz";
|
2016-04-29 10:50:27 +00:00
|
|
|
sha256 = "0mm7gj491yi6q4v0n4qkbsm94s59bvqir6fk60j73w7y4la8rg68";
|
|
|
|
})
|
|
|
|
];
|
2020-04-01 01:11:51 +00:00
|
|
|
urlPrefix = "mirror://ubuntu";
|
2016-04-29 10:50:27 +00:00
|
|
|
packages = commonDebPackages ++ [ "diffutils" "libc-bin" ];
|
2015-11-25 14:40:08 +00:00
|
|
|
};
|
|
|
|
|
2021-05-26 21:11:31 +00:00
|
|
|
ubuntu1804i386 = {
|
|
|
|
name = "ubuntu-18.04-bionic-i386";
|
|
|
|
fullName = "Ubuntu 18.04 Bionic (i386)";
|
2017-02-21 13:56:27 +00:00
|
|
|
packagesLists =
|
|
|
|
[ (fetchurl {
|
2021-05-26 21:11:31 +00:00
|
|
|
url = "mirror://ubuntu/dists/bionic/main/binary-i386/Packages.xz";
|
|
|
|
sha256 = "0f0v4131kwf7m7f8j3288rlqdxk1k3vqy74b7fcfd6jz9j8d840i";
|
2017-02-21 13:56:27 +00:00
|
|
|
})
|
|
|
|
(fetchurl {
|
2021-05-26 21:11:31 +00:00
|
|
|
url = "mirror://ubuntu/dists/bionic/universe/binary-i386/Packages.xz";
|
|
|
|
sha256 = "1v75c0dqr0wp0dqd4hnci92qqs4hll8frqdbpswadgxm5chn91bw";
|
2017-02-21 13:56:27 +00:00
|
|
|
})
|
|
|
|
];
|
2020-04-01 01:11:51 +00:00
|
|
|
urlPrefix = "mirror://ubuntu";
|
2017-02-21 13:56:27 +00:00
|
|
|
packages = commonDebPackages ++ [ "diffutils" "libc-bin" ];
|
|
|
|
};
|
|
|
|
|
2021-05-26 21:11:31 +00:00
|
|
|
ubuntu1804x86_64 = {
|
|
|
|
name = "ubuntu-18.04-bionic-amd64";
|
|
|
|
fullName = "Ubuntu 18.04 Bionic (amd64)";
|
2018-02-19 10:16:31 +00:00
|
|
|
packagesLists =
|
2017-02-21 13:56:27 +00:00
|
|
|
[ (fetchurl {
|
2021-05-26 21:11:31 +00:00
|
|
|
url = "mirror://ubuntu/dists/bionic/main/binary-amd64/Packages.xz";
|
|
|
|
sha256 = "1ls81bjyvmfz6i919kszl7xks1ibrh1xqhsk6698ackndkm0wp39";
|
2017-02-21 13:56:27 +00:00
|
|
|
})
|
|
|
|
(fetchurl {
|
2021-05-26 21:11:31 +00:00
|
|
|
url = "mirror://ubuntu/dists/bionic/universe/binary-amd64/Packages.xz";
|
|
|
|
sha256 = "1832nqpn4ap95b3sj870xqayrza9in4kih9jkmjax27pq6x15v1r";
|
2017-02-21 13:56:27 +00:00
|
|
|
})
|
|
|
|
];
|
2020-04-01 01:11:51 +00:00
|
|
|
urlPrefix = "mirror://ubuntu";
|
2017-02-21 13:56:27 +00:00
|
|
|
packages = commonDebPackages ++ [ "diffutils" "libc-bin" ];
|
|
|
|
};
|
|
|
|
|
2021-05-26 21:11:31 +00:00
|
|
|
ubuntu2004i386 = {
|
|
|
|
name = "ubuntu-20.04-focal-i386";
|
|
|
|
fullName = "Ubuntu 20.04 Focal (i386)";
|
2019-01-26 15:32:19 +00:00
|
|
|
packagesLists =
|
|
|
|
[ (fetchurl {
|
2021-05-26 21:11:31 +00:00
|
|
|
url = "mirror://ubuntu/dists/focal/main/binary-i386/Packages.xz";
|
|
|
|
sha256 = "sha256-7RAYURoN3RKYQAHpwBS9TIV6vCmpURpphyMJQmV4wLc=";
|
2019-01-26 15:32:19 +00:00
|
|
|
})
|
|
|
|
(fetchurl {
|
2021-05-26 21:11:31 +00:00
|
|
|
url = "mirror://ubuntu/dists/focal/universe/binary-i386/Packages.xz";
|
|
|
|
sha256 = "sha256-oA551xVE80volUPgkMyvzpQ1d+GhuZd4DAe7dXZnULM=";
|
2019-01-26 15:32:19 +00:00
|
|
|
})
|
|
|
|
];
|
2020-04-01 01:11:51 +00:00
|
|
|
urlPrefix = "mirror://ubuntu";
|
2019-01-26 15:32:19 +00:00
|
|
|
packages = commonDebPackages ++ [ "diffutils" "libc-bin" ];
|
|
|
|
};
|
|
|
|
|
2021-05-26 21:11:31 +00:00
|
|
|
ubuntu2004x86_64 = {
|
|
|
|
name = "ubuntu-20.04-focal-amd64";
|
|
|
|
fullName = "Ubuntu 20.04 Focal (amd64)";
|
2019-01-26 15:32:19 +00:00
|
|
|
packagesLists =
|
|
|
|
[ (fetchurl {
|
2021-05-26 21:11:31 +00:00
|
|
|
url = "mirror://ubuntu/dists/focal/main/binary-amd64/Packages.xz";
|
|
|
|
sha256 = "sha256-d1eSH/j+7Zw5NKDJk21EG6SiOL7j6myMHfXLzUP8mGE=";
|
2019-01-26 15:32:19 +00:00
|
|
|
})
|
|
|
|
(fetchurl {
|
2021-05-26 21:11:31 +00:00
|
|
|
url = "mirror://ubuntu/dists/focal/universe/binary-amd64/Packages.xz";
|
|
|
|
sha256 = "sha256-RqdG2seJvZU3rKVNsWgLnf9RwkgVMRE1A4IZnX2WudE=";
|
2019-01-26 15:32:19 +00:00
|
|
|
})
|
|
|
|
];
|
2020-04-01 01:11:51 +00:00
|
|
|
urlPrefix = "mirror://ubuntu";
|
2019-01-26 15:32:19 +00:00
|
|
|
packages = commonDebPackages ++ [ "diffutils" "libc-bin" ];
|
|
|
|
};
|
|
|
|
|
2022-12-26 10:58:52 +00:00
|
|
|
ubuntu2204i386 = {
|
|
|
|
name = "ubuntu-22.04-jammy-i386";
|
|
|
|
fullName = "Ubuntu 22.04 Jammy (i386)";
|
|
|
|
packagesLists =
|
|
|
|
[ (fetchurl {
|
|
|
|
url = "mirror://ubuntu/dists/jammy/main/binary-i386/Packages.xz";
|
|
|
|
sha256 = "sha256-iZBmwT0ep4v+V3sayybbOgZBOFFZwPGpOKtmuLMMVPQ=";
|
|
|
|
})
|
|
|
|
(fetchurl {
|
|
|
|
url = "mirror://ubuntu/dists/jammy/universe/binary-i386/Packages.xz";
|
|
|
|
sha256 = "sha256-DO2LdpZ9rDDBhWj2gvDWd0TJJVZHxKsYTKTi6GXjm1E=";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
urlPrefix = "mirror://ubuntu";
|
|
|
|
packages = commonDebPackages ++ [ "diffutils" "libc-bin" ];
|
|
|
|
};
|
|
|
|
|
|
|
|
ubuntu2204x86_64 = {
|
|
|
|
name = "ubuntu-22.04-jammy-amd64";
|
|
|
|
fullName = "Ubuntu 22.04 Jammy (amd64)";
|
|
|
|
packagesLists =
|
|
|
|
[ (fetchurl {
|
|
|
|
url = "mirror://ubuntu/dists/jammy/main/binary-amd64/Packages.xz";
|
|
|
|
sha256 = "sha256-N8tX8VVMv6ccWinun/7hipqMF4K7BWjgh0t/9M6PnBE=";
|
|
|
|
})
|
|
|
|
(fetchurl {
|
|
|
|
url = "mirror://ubuntu/dists/jammy/universe/binary-amd64/Packages.xz";
|
|
|
|
sha256 = "sha256-0pyyTJP+xfQyVXBrzn60bUd5lSA52MaKwbsUpvNlXOI=";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
urlPrefix = "mirror://ubuntu";
|
|
|
|
packages = commonDebPackages ++ [ "diffutils" "libc-bin" ];
|
|
|
|
};
|
|
|
|
|
2022-11-26 20:53:24 +00:00
|
|
|
debian10i386 = {
|
|
|
|
name = "debian-10.13-buster-i386";
|
|
|
|
fullName = "Debian 10.13 Buster (i386)";
|
2011-02-14 16:52:32 +00:00
|
|
|
packagesList = fetchurl {
|
2022-11-26 20:53:24 +00:00
|
|
|
url = "https://snapshot.debian.org/archive/debian/20221126T084953Z/dists/buster/main/binary-i386/Packages.xz";
|
|
|
|
hash = "sha256-n9JquhtZgxw3qr9BX0MQoY3ZTIHN0dit+iru3DC31UY=";
|
2011-02-14 16:52:32 +00:00
|
|
|
};
|
2020-04-01 01:11:51 +00:00
|
|
|
urlPrefix = "mirror://debian";
|
2011-02-14 16:52:32 +00:00
|
|
|
packages = commonDebianPackages;
|
|
|
|
};
|
2012-08-27 17:39:13 +00:00
|
|
|
|
2022-11-26 20:53:24 +00:00
|
|
|
debian10x86_64 = {
|
|
|
|
name = "debian-10.13-buster-amd64";
|
|
|
|
fullName = "Debian 10.13 Buster (amd64)";
|
2011-02-14 16:52:32 +00:00
|
|
|
packagesList = fetchurl {
|
2022-11-26 20:53:24 +00:00
|
|
|
url = "https://snapshot.debian.org/archive/debian/20221126T084953Z/dists/buster/main/binary-amd64/Packages.xz";
|
|
|
|
hash = "sha256-YukIIB3u87jgp9oudwklsxyKVKjSL618wFgDSXiFmjU=";
|
2009-02-24 10:56:42 +00:00
|
|
|
};
|
2020-04-01 01:11:51 +00:00
|
|
|
urlPrefix = "mirror://debian";
|
2010-06-14 18:42:18 +00:00
|
|
|
packages = commonDebianPackages;
|
|
|
|
};
|
2009-02-24 10:56:42 +00:00
|
|
|
|
2022-11-26 20:53:24 +00:00
|
|
|
debian11i386 = {
|
|
|
|
name = "debian-11.5-bullseye-i386";
|
|
|
|
fullName = "Debian 11.5 Bullseye (i386)";
|
2013-05-07 09:15:44 +00:00
|
|
|
packagesList = fetchurl {
|
2022-11-26 20:53:24 +00:00
|
|
|
url = "https://snapshot.debian.org/archive/debian/20221126T084953Z/dists/bullseye/main/binary-i386/Packages.xz";
|
|
|
|
hash = "sha256-tHrWSd4K5TCwIaLTPqK/Rcon0O0r+Jsxb7OcchOo8Vo=";
|
2013-05-07 09:15:44 +00:00
|
|
|
};
|
2020-04-01 01:11:51 +00:00
|
|
|
urlPrefix = "mirror://debian";
|
2013-05-07 09:15:44 +00:00
|
|
|
packages = commonDebianPackages;
|
|
|
|
};
|
|
|
|
|
2022-11-26 20:53:24 +00:00
|
|
|
debian11x86_64 = {
|
|
|
|
name = "debian-11.5-bullseye-amd64";
|
|
|
|
fullName = "Debian 11.5 Bullseye (amd64)";
|
2013-05-07 09:15:44 +00:00
|
|
|
packagesList = fetchurl {
|
2022-11-26 20:53:24 +00:00
|
|
|
url = "https://snapshot.debian.org/archive/debian/20221126T084953Z/dists/bullseye/main/binary-amd64/Packages.xz";
|
|
|
|
hash = "sha256-whpBERKOPyhrWguVQ2QchrwRHU4tCkGwu42x6khF/2g=";
|
2013-05-07 09:15:44 +00:00
|
|
|
};
|
2020-04-01 01:11:51 +00:00
|
|
|
urlPrefix = "mirror://debian";
|
2013-05-07 09:15:44 +00:00
|
|
|
packages = commonDebianPackages;
|
|
|
|
};
|
2008-04-09 12:02:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* Common packages for Fedora images. */
|
|
|
|
commonFedoraPackages = [
|
|
|
|
"autoconf"
|
|
|
|
"automake"
|
|
|
|
"basesystem"
|
|
|
|
"bzip2"
|
|
|
|
"curl"
|
|
|
|
"diffutils"
|
|
|
|
"fedora-release"
|
|
|
|
"findutils"
|
|
|
|
"gawk"
|
|
|
|
"gcc-c++"
|
|
|
|
"gzip"
|
|
|
|
"make"
|
|
|
|
"patch"
|
|
|
|
"perl"
|
2018-02-19 10:16:31 +00:00
|
|
|
"pkgconf-pkg-config"
|
2008-04-09 12:02:15 +00:00
|
|
|
"rpm"
|
|
|
|
"rpm-build"
|
|
|
|
"tar"
|
|
|
|
"unzip"
|
|
|
|
];
|
|
|
|
|
2013-07-05 15:52:42 +00:00
|
|
|
commonCentOSPackages = [
|
|
|
|
"autoconf"
|
|
|
|
"automake"
|
|
|
|
"basesystem"
|
|
|
|
"bzip2"
|
|
|
|
"curl"
|
|
|
|
"diffutils"
|
|
|
|
"centos-release"
|
|
|
|
"findutils"
|
|
|
|
"gawk"
|
|
|
|
"gcc-c++"
|
|
|
|
"gzip"
|
|
|
|
"make"
|
|
|
|
"patch"
|
|
|
|
"perl"
|
|
|
|
"pkgconfig"
|
|
|
|
"rpm"
|
|
|
|
"rpm-build"
|
|
|
|
"tar"
|
|
|
|
"unzip"
|
|
|
|
];
|
2012-08-27 17:39:13 +00:00
|
|
|
|
2014-05-01 13:13:26 +00:00
|
|
|
commonRHELPackages = [
|
|
|
|
"autoconf"
|
|
|
|
"automake"
|
|
|
|
"basesystem"
|
|
|
|
"bzip2"
|
|
|
|
"curl"
|
|
|
|
"diffutils"
|
|
|
|
"findutils"
|
|
|
|
"gawk"
|
|
|
|
"gcc-c++"
|
|
|
|
"gzip"
|
|
|
|
"make"
|
|
|
|
"patch"
|
|
|
|
"perl"
|
|
|
|
"pkgconfig"
|
|
|
|
"procps-ng"
|
|
|
|
"rpm"
|
|
|
|
"rpm-build"
|
|
|
|
"tar"
|
|
|
|
"unzip"
|
|
|
|
];
|
|
|
|
|
2008-04-11 11:52:40 +00:00
|
|
|
/* Common packages for openSUSE images. */
|
|
|
|
commonOpenSUSEPackages = [
|
|
|
|
"aaa_base"
|
|
|
|
"autoconf"
|
|
|
|
"automake"
|
|
|
|
"bzip2"
|
|
|
|
"curl"
|
|
|
|
"diffutils"
|
|
|
|
"findutils"
|
|
|
|
"gawk"
|
|
|
|
"gcc-c++"
|
|
|
|
"gzip"
|
|
|
|
"make"
|
|
|
|
"patch"
|
|
|
|
"perl"
|
|
|
|
"pkg-config"
|
|
|
|
"rpm"
|
|
|
|
"tar"
|
|
|
|
"unzip"
|
2008-04-13 21:04:21 +00:00
|
|
|
"util-linux"
|
2009-07-02 12:53:25 +00:00
|
|
|
"gnu-getopt"
|
2008-04-11 11:52:40 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
|
2008-04-09 12:02:15 +00:00
|
|
|
/* Common packages for Debian/Ubuntu images. */
|
2010-06-14 18:42:18 +00:00
|
|
|
commonDebPackages = [
|
2008-04-09 12:02:15 +00:00
|
|
|
"base-passwd"
|
|
|
|
"dpkg"
|
|
|
|
"libc6-dev"
|
|
|
|
"perl"
|
|
|
|
"bash"
|
2009-10-02 09:34:37 +00:00
|
|
|
"dash"
|
2008-04-09 12:02:15 +00:00
|
|
|
"gzip"
|
|
|
|
"bzip2"
|
|
|
|
"tar"
|
|
|
|
"grep"
|
2015-10-26 19:47:16 +00:00
|
|
|
"mawk"
|
2013-05-07 09:15:44 +00:00
|
|
|
"sed"
|
2008-04-09 12:02:15 +00:00
|
|
|
"findutils"
|
|
|
|
"g++"
|
|
|
|
"make"
|
|
|
|
"curl"
|
|
|
|
"patch"
|
2008-11-12 17:15:09 +00:00
|
|
|
"locales"
|
2013-10-23 09:08:12 +00:00
|
|
|
"coreutils"
|
2008-11-25 02:20:41 +00:00
|
|
|
# Needed by checkinstall:
|
2012-08-27 17:39:13 +00:00
|
|
|
"util-linux"
|
2008-11-25 02:20:41 +00:00
|
|
|
"file"
|
|
|
|
"dpkg-dev"
|
2009-07-02 12:53:25 +00:00
|
|
|
"pkg-config"
|
2009-02-24 10:56:42 +00:00
|
|
|
# Needed because it provides /etc/login.defs, whose absence causes
|
|
|
|
# the "passwd" post-installs script to fail.
|
|
|
|
"login"
|
2018-02-19 10:16:31 +00:00
|
|
|
"passwd"
|
2008-04-09 12:02:15 +00:00
|
|
|
];
|
|
|
|
|
2021-05-26 21:12:03 +00:00
|
|
|
commonDebianPackages = commonDebPackages ++ [ "sysvinit" "diff" ];
|
2012-08-27 17:39:13 +00:00
|
|
|
|
2008-04-09 12:02:15 +00:00
|
|
|
|
2010-06-14 18:42:18 +00:00
|
|
|
/* A set of functions that build the Linux distributions specified
|
|
|
|
in `rpmDistros' and `debDistros'. For instance,
|
|
|
|
`diskImageFuns.ubuntu1004x86_64 { }' builds an Ubuntu 10.04 disk
|
|
|
|
image containing the default packages specified above. Overrides
|
|
|
|
of the default image parameters can be given. In particular,
|
|
|
|
`extraPackages' specifies the names of additional packages from
|
|
|
|
the distribution that should be included in the image; `packages'
|
2022-12-18 00:39:44 +00:00
|
|
|
allows the entire set of packages to be overridden; and `size'
|
2010-06-14 18:42:18 +00:00
|
|
|
sets the size of the disk in megabytes. E.g.,
|
|
|
|
`diskImageFuns.ubuntu1004x86_64 { extraPackages = ["firefox"];
|
|
|
|
size = 8192; }' builds an 8 GiB image containing Firefox in
|
|
|
|
addition to the default packages. */
|
2012-08-27 17:39:13 +00:00
|
|
|
diskImageFuns =
|
2010-06-14 18:42:18 +00:00
|
|
|
(lib.mapAttrs (name: as: as2: makeImageFromRPMDist (as // as2)) rpmDistros) //
|
|
|
|
(lib.mapAttrs (name: as: as2: makeImageFromDebDist (as // as2)) debDistros);
|
2009-11-05 14:49:17 +00:00
|
|
|
|
2012-08-27 17:39:13 +00:00
|
|
|
|
2010-06-14 18:42:18 +00:00
|
|
|
/* Shorthand for `diskImageFuns.<attr> { extraPackages = ... }'. */
|
|
|
|
diskImageExtraFuns =
|
|
|
|
lib.mapAttrs (name: f: extraPackages: f { inherit extraPackages; }) diskImageFuns;
|
2009-11-05 14:49:17 +00:00
|
|
|
|
2012-08-27 17:39:13 +00:00
|
|
|
|
2010-06-14 18:42:18 +00:00
|
|
|
/* Default disk images generated from the `rpmDistros' and
|
2015-02-12 15:56:42 +00:00
|
|
|
`debDistros' sets. */
|
|
|
|
diskImages = lib.mapAttrs (name: f: f {}) diskImageFuns;
|
2008-03-18 12:54:21 +00:00
|
|
|
|
2020-12-17 05:58:31 +00:00
|
|
|
}
|