diff options
author | Alyssa Ross <hi@alyssa.is> | 2021-12-12 00:23:21 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2021-12-12 00:23:21 +0000 |
commit | 3a39a38945873e1601bfd078583ccc78f1a94422 (patch) | |
tree | 7060b17929a2ebb2b404b5d0edda77edb7e07bcd /vm/app/lynx/default.nix | |
parent | 5582c1b6ce0ee4f898ac953076acd619b8a7647d (diff) | |
download | spectrum-3a39a38945873e1601bfd078583ccc78f1a94422.tar spectrum-3a39a38945873e1601bfd078583ccc78f1a94422.tar.gz spectrum-3a39a38945873e1601bfd078583ccc78f1a94422.tar.bz2 spectrum-3a39a38945873e1601bfd078583ccc78f1a94422.tar.lz spectrum-3a39a38945873e1601bfd078583ccc78f1a94422.tar.xz spectrum-3a39a38945873e1601bfd078583ccc78f1a94422.tar.zst spectrum-3a39a38945873e1601bfd078583ccc78f1a94422.zip |
vm/app/lynx: move to monorepo path
Diffstat (limited to 'vm/app/lynx/default.nix')
-rw-r--r-- | vm/app/lynx/default.nix | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/vm/app/lynx/default.nix b/vm/app/lynx/default.nix new file mode 100644 index 0000000..6c062a4 --- /dev/null +++ b/vm/app/lynx/default.nix @@ -0,0 +1,85 @@ +# SPDX-License-Identifier: EUPL-1.2 +# SPDX-FileCopyrightText: 2021 Alyssa Ross <hi@alyssa.is> + +{ pkgs ? import <nixpkgs> {} +, terminfo ? pkgs.foot.terminfo +}: + +pkgs.pkgsStatic.callPackage ( + +{ lib, stdenv, runCommand, writeReferencesToFile, buildPackages +, s6-rc, tar2ext4 +, busybox, cacert, execline, linux, lynx, mdevd, s6, s6-linux-utils +, s6-portable-utils +}: + +let + inherit (lib) cleanSource cleanSourceWith concatMapStringsSep; + + packages = [ + busybox execline lynx mdevd s6 s6-linux-utils s6-portable-utils s6-rc + ]; + + packagesSysroot = runCommand "packages-sysroot" { + inherit packages; + passAsFile = [ "packages" ]; + } '' + mkdir -p $out/usr/bin $out/usr/share + ln -s ${concatMapStringsSep " " (p: "${p}/bin/*") packages} $out/usr/bin + ln -s ${kernel}/lib "$out" + ln -s ${terminfo}/share/terminfo $out/usr/share + ln -s ${cacert}/etc/ssl $out/usr/share + ''; + + packagesTar = runCommand "packages.tar" {} '' + cd ${packagesSysroot} + tar -cf $out --verbatim-files-from \ + -T ${writeReferencesToFile packagesSysroot} . + ''; + + kernel = buildPackages.linux.override { + structuredExtraConfig = with lib.kernel; { + VIRTIO = yes; + VIRTIO_PCI = yes; + VIRTIO_BLK = yes; + VIRTIO_CONSOLE = yes; + EXT4_FS = yes; + DRM_BOCHS = yes; + DRM = yes; + AGP = yes; + }; + }; +in + +stdenv.mkDerivation { + name = "spectrum-appvm-lynx"; + + src = cleanSourceWith { + filter = name: _type: name != "${toString ./.}/build"; + src = cleanSource ./.; + }; + + nativeBuildInputs = [ s6-rc tar2ext4 ]; + + PACKAGES_TAR = packagesTar; + VMLINUX = "${kernel.dev}/vmlinux"; + + postPatch = '' + mkdir $NIX_BUILD_TOP/empty + substituteInPlace Makefile --replace /var/empty $NIX_BUILD_TOP/empty + ''; + + installPhase = '' + mv build/svc $out + ''; + + enableParallelBuilding = true; + + passthru = { inherit kernel; }; + + meta = with lib; { + license = licenses.eupl12; + platforms = platforms.linux; + }; +} +) {} |