patches and low-level development discussion
 help / color / mirror / code / Atom feed
10646d3ec632c6e0f901a92c3e6efa4dffba2210 blob 1395 bytes (raw)

 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
 
# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: 2022 Alyssa Ross <hi@alyssa.is>

{ config ? import ../nix/eval-config.nix {} }:
config.pkgs.pkgsStatic.callPackage (

{ lib, runCommand, writeReferencesToFile, e2fsprogs, tar2ext4 }:

{ name, run, providers ? {} }:

let
  inherit (lib)
    any attrValues concatLists concatStrings hasInfix mapAttrsToList;

  basePackages = (import ../img/app { inherit config; }).packagesSysroot;
in

assert !(any (hasInfix "\n") (concatLists (attrValues providers)));

runCommand "spectrum-vm-${name}" {
  nativeBuildInputs = [ e2fsprogs tar2ext4 ];

  providerDirs = concatStrings (concatLists
    (mapAttrsToList (kind: map (vm: "${kind}/${vm}\n")) providers));
  passAsFile = [ "providerDirs" ];
} ''
  mkdir -p "$out"/data/${name}/{blk,providers}

  mkdir root
  cd root
  ln -s ${run} run
  comm -23 <(sort ${writeReferencesToFile run}) \
      <(sort ${writeReferencesToFile basePackages}) |
      tar -cf ../run.tar --verbatim-files-from -T - run
  tar2ext4 -i ../run.tar -o "$out/data/${name}/blk/run.img"
  e2label "$out/data/${name}/blk/run.img" ext

  pushd "$out/data/${name}/providers"
  xargs -rd '\n' dirname -- < "$providerDirsPath" | xargs -rd '\n' mkdir -p --
  xargs -rd '\n' touch -- < "$providerDirsPath"
  popd

  ln -s /usr/img/appvm/blk/root.img "$out/data/${name}/blk"
  ln -s /usr/img/appvm/vmlinux "$out/data/${name}"
''
) {}
debug log:

solving 10646d3 ...
found 10646d3 in https://spectrum-os.org/lists/archives/spectrum-devel/20220919073659.1703271-7-hi@alyssa.is/

applying [1/1] https://spectrum-os.org/lists/archives/spectrum-devel/20220919073659.1703271-7-hi@alyssa.is/
diff --git a/vm-lib/make-vm.nix b/vm-lib/make-vm.nix
new file mode 100644
index 0000000..10646d3

Checking patch vm-lib/make-vm.nix...
Applied patch vm-lib/make-vm.nix cleanly.

index at:
100644 10646d3ec632c6e0f901a92c3e6efa4dffba2210	vm-lib/make-vm.nix

Code repositories for project(s) associated with this public inbox

	https://spectrum-os.org/git/crosvm
	https://spectrum-os.org/git/doc
	https://spectrum-os.org/git/mktuntap
	https://spectrum-os.org/git/nixpkgs
	https://spectrum-os.org/git/spectrum
	https://spectrum-os.org/git/ucspi-vsock
	https://spectrum-os.org/git/www

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).