# Universe - The big bang to my universe # # Copyright (c) 2023-2024 Sameer Rahmani # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, version 2. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . { lib, stdenv, writeScriptBin, symlinkJoin, libslirp, qemu }: rec { # Add a command to the shell to create the disk create-disk = writeScriptBin "create-disk" '' #!${stdenv.shell} qemu-img create -f qcow2 vdisk1 40G ''; bootImage = image: (writeScriptBin "boot-${image.name}" '' #!${stdenv.shell} SLIRP=yes ${qemu}/bin/qemu-system-x86_64 -enable-kvm -m 2048 -boot d \ -cdrom ${image} -hda vdisk1 -vga std \ -net user,hostfwd=tcp::10022-:22 \ -netdev user,id=eth -device e1000,netdev=eth ''); scripts = symlinkJoin { name = "universe_scripts"; paths = [ create-disk ]; }; sanitizeBuilderConfig = config: (with builtins; assert hasAttr "inVM" config; config ); }