Compare commits

..

No commits in common. "8fb586c8b67d2a3d61dbbcf8742f7368c0ed0e72" and "add1c4f6bd15f4ccc626edd3eb71b3e7a2959067" have entirely different histories.

4 changed files with 15 additions and 60 deletions

View file

@ -34,10 +34,10 @@ cloud-hypervisor.overrideAttrs (
patches = patchesFromDir (spectrum + "/pkgs/cloud-hypervisor");
vhostPatches = patchesFromDir (spectrum + "/pkgs/cloud-hypervisor/vhost");
};
oldPatchesStruct = oldAttrs.passthru.spectrumPatches or { };
missingPatchPhases = previouslyPatched != { };
previouslyPatched = oldAttrs ? spectrumPatches;
patchPhases = !previouslyPatched;
isNewer = lib.versionOlder oldAttrs.spectrumPatches.version or "2000-00-00" spectrumPatches.version;
oldPatches = oldPatchesStruct.patches or [ ];
oldPatches = oldAttrs.spectrumPatches.patches or [ ];
removeAll = removeElts: lst: builtins.filter (x: !(builtins.elem x removeElts)) lst;
in
optionalAttrs isNewer {
@ -47,7 +47,7 @@ cloud-hypervisor.overrideAttrs (
# Verbatim from spectrum
postUnpack =
oldAttrs.postUnpack or ""
+ optionalString missingPatchPhases ''
+ optionalString patchPhases ''
unpackFile $vhost
chmod -R +w vhost
'';
@ -58,7 +58,7 @@ cloud-hypervisor.overrideAttrs (
# Verbatim copy from spectrum
postPatch =
oldAttrs.postPatch or ""
+ optionalString missingPatchPhases ''
+ optionalString patchPhases ''
pushd ../vhost
for patch in $vhostPatches; do
echo applying patch $patch

View file

@ -13,7 +13,6 @@ import json
import re
from argparse import ArgumentParser
from contextlib import contextmanager, closing, ExitStack
from urllib.parse import urlparse, parse_qs
parser = ArgumentParser("supervise-vm")
@ -158,7 +157,7 @@ class Processes:
print(f"Releasing {args}")
finally:
if subprocess.PIPE in (kwargs["stderr"], kwargs["stdout"]):
print(proc.communicate(timeout=0.125))
print(proc.communicate())
while alive_after(proc, 0.125):
try:
proc.terminate()
@ -355,7 +354,7 @@ class Processes:
"--wayland-sock",
f'{PASSTHRU_ENV["XDG_RUNTIME_DIR"]}/{PASSTHRU_ENV["WAYLAND_DISPLAY"]}', # noqa: E501
"--params",
'{ "context-types": "cross-domain:virgl2" }',
'{ "context-types": "cross-domain" }',
]
with self.popen(
*args,
@ -464,7 +463,7 @@ def connect_ch_vsock(
s.setblocking(blocking)
s.connect(vsock_sock_path)
with closing(s):
with removing(vsock_sock_path):
s.send(b"CONNECT %d\n" % port)
yield s
@ -518,32 +517,12 @@ def main(args, args_next, cleanup, ps):
app_paths = []
for a in args.app:
a = urlparse(a)
nix_file = "./."
attr = None
if a.scheme == "":
nix_file = "<nixpkgs>"
attr = a.path
else:
assert a.fragment, a
attr = a.fragment
nix_file = a.path or "./."
arglist = []
for k, v in parse_qs(a.query).items():
arglist.append("--arg")
arglist.append(k)
arglist.append(v)
assert nix_file is not None, a
assert attr is not None, a
out_path = ps.exec(
"nix-build",
nix_file,
"<nixpkgs>",
"-A",
attr,
*arglist,
a,
"--no-out-link",
cwd=os.getcwd(),
capture_output=True,
text=True,
).stdout.strip()
@ -662,7 +641,6 @@ def main(args, args_next, cleanup, ps):
assert ready
cleanup.enter_context(removing(ps.prefix + "/vsock.sock"))
with connect_ch_vsock(ps.prefix + "/vsock.sock", 24601) as guest:
for r in args.run:
res = {}
@ -678,9 +656,6 @@ def main(args, args_next, cleanup, ps):
"EXTRA_PATH": [
f"{a}/bin" for a in app_paths
], # noqa: E501
"EXTRA_XDG_DATA_DIRS": [
f"{a}/share" for a in app_paths
], # noqa: E501
}
}
).encode("utf8")

View file

@ -55,16 +55,6 @@ class Processes:
"/run/current-system/sw/bin",
],
),
"XDG_DATA_DIRS": ":".join(
[
*os.environ.get("XDG_DATA_DIRS", "").split(":"),
*run.get(
"EXTRA_XDG_DATA_DIRS",
[],
),
"/run/current-system/sw/share",
],
),
}
proc = None
try:
@ -73,8 +63,8 @@ class Processes:
text=text,
env=env,
cwd="/home/user",
stdin=None,
stdout=None,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
)
res["status"] = "exec succeeded"
except Exception as e:
@ -126,7 +116,6 @@ def guest_main():
# IDK why but I keep getting empty messages
if req == b"":
print(f"Lost [{con.fileno()}]")
ps.sources = [s for s in ps.sources if s.fileno() != con.fileno()]
continue
try:
req = json.loads(req)

View file

@ -16,7 +16,6 @@ let
kernelTarget = pkgs.stdenv.hostPlatform.linux-kernel.target;
waylandSock = "/run/user/1000/wayland-1";
env = {
DBUS_SESSION_BUS_ADDRESS = "unix:path=/run/user/1000/bus";
XDG_RUNTIME_DIR = "/run/user/1000";
WAYLAND_DISPLAY = "wayland-1";
@ -45,11 +44,6 @@ in
hardware.graphics.enable = true;
# boot.kernelPackages = pkgs.linuxPackagesFor uvmsPkgs.linux-uvm;
# boot.isContainer = true;
boot.kernel.sysctl = {
"vm.overcommit_memory" = 1; # "always"
# "vm.overcommit_memory" = 2; # "never"
"vm.panic_on_oom" = 1;
};
boot.initrd.kernelModules = [
"drm"
"virtio_blk"
@ -110,7 +104,6 @@ in
};
};
programs.dconf.enable = true;
systemd.mounts = [
{
type = "virtiofs";
@ -217,8 +210,6 @@ in
};
environment.profileRelativeSessionVariables.PATH = lib.mkForce [ "/bin\${PATH:+:}$PATH" ];
environment.profileRelativeSessionVariables.XDG_DATA_DIRS = lib.mkForce [ "/run/current-system/sw/share/\${XDG_DATA_DIRS:+:}$XDG_DATA_DIRS" ];
environment.sessionVariables = env;
environment.variables = env;
systemd.globalEnvironment = env;
@ -311,9 +302,9 @@ in
uvms.ch.settings = mkOption {
default = { };
type = types.submodule (
let
osConfig = config;
in
let
osConfig = config;
in
{ config, ... }:
{
freeformType = jsonType;