patches and low-level development discussion
 help / color / mirror / code / Atom feed
80e6ef533c7020c63b032dece658c15e905cc4f2 blob 1655 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
47
48
49
50
51
52
53
54
55
56
57
58
59
 
# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: 2022 Alyssa Ross <hi@alyssa.is>

{ pkgs ? import <nixpkgs> {}

# Paths that are present in the base image that will start this VM's
# run script, and don't so need to be duplicated in the extension
# partition's store.
, basePaths ? builtins.toFile "null" ""
}:

pkgs.pkgsStatic.callPackage (

{ lib, runCommand, writeReferencesToFile, erofs-utils }:

{ run, providers ? {}, sharedDirs ? {} }:

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

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

runCommand "spectrum-vm" {
  nativeBuildInputs = [ erofs-utils ];

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

  ${../scripts/make-erofs.sh} -L ext -- "$out/blk/run.img" ${run} run \
      ${pkgs.pkgsMusl.mesa.drivers} / \
      $(comm -23 <(sort ${writeReferencesToFile run} ${writeReferencesToFile pkgs.pkgsMusl.mesa.drivers}) \
          <(sort ${writeReferencesToFile basePaths}) | sed p)

  pushd "$out"

  pushd providers
  xargs -rd '\n' dirname -- < "$providerDirsPath" | xargs -rd '\n' mkdir -p --
  xargs -rd '\n' touch -- < "$providerDirsPath"
  popd

  pushd shared-dirs
  ${concatStringsSep "\n" (mapAttrsToList (key: { path }: ''
    mkdir ${lib.escapeShellArg key}
    ln -s ${lib.escapeShellArgs [ path "${key}/dir" ]}
  '') sharedDirs)}
  popd

  popd

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

solving 80e6ef5 ...
found 80e6ef5 in https://spectrum-os.org/git/spectrum

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).