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
| | # SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: 2022 Alyssa Ross <hi@alyssa.is>
{ config ? import ../../../../nix/eval-config.nix {} }:
import ../../make-vm.nix { inherit config; } {
providers.net = [ "netvm" ];
sharedDirs.virtiofs0.path = "/ext";
run = config.pkgs.pkgsStatic.callPackage (
{ lib, runCommand, writeScript, nix }:
let
inherit (lib) concatStringsSep const hasSuffix makeBinPath;
bin = builtins.filterSource (name: _type:
name == toString bin/. || name == toString bin/vm-rebuild) ./.;
nixPath = [
"nixpkgs=https://nixos.org/channels/nixos-unstable/nixexprs.tar.xz"
"spectrum=/run/virtiofs/virtiofs0/vm-config/spectrum"
"spectrum-vms=/run/virtiofs/virtiofs0/vm-config/vms.nix"
];
resolve_in_root = import ../../../tools/resolve_in_root {
config = config // { pkgs = config.pkgs.pkgsStatic; };
};
in
writeScript "run-nix" ''
#!/bin/execlineb -P
importas -i PATH PATH
export NIX_CONFIG "build-users-group ="
export NIX_REMOTE /run/virtiofs/virtiofs0
export NIX_PATH ${concatStringsSep ":" nixPath}
export PATH ${makeBinPath [ bin nix resolve_in_root ]}:''${PATH}
export XDG_CACHE_HOME /run/cache
# FIXME: can be removed when we have nix#7070.
export XDG_DATA_HOME /run/data
if { /etc/mdev/wait virtiofs0 }
/bin/sh -il
''
) { };
}
|