diff --git a/cmd/hakurei/print_test.go b/cmd/hakurei/print_test.go index cbf23d1..41ce554 100644 --- a/cmd/hakurei/print_test.go +++ b/cmd/hakurei/print_test.go @@ -189,154 +189,152 @@ App "instance": "8e2c76b066dabe574cf073bdb46eb5c1", "pid": 3405691582, "shim_pid": 3735928559, - "config": { - "id": "org.chromium.Chromium", - "enablements": { - "wayland": true, - "dbus": true, - "pulse": true + "id": "org.chromium.Chromium", + "enablements": { + "wayland": true, + "dbus": true, + "pulse": true + }, + "session_bus": { + "see": null, + "talk": [ + "org.freedesktop.Notifications", + "org.freedesktop.FileManager1", + "org.freedesktop.ScreenSaver", + "org.freedesktop.secrets", + "org.kde.kwalletd5", + "org.kde.kwalletd6", + "org.gnome.SessionManager" + ], + "own": [ + "org.chromium.Chromium.*", + "org.mpris.MediaPlayer2.org.chromium.Chromium.*", + "org.mpris.MediaPlayer2.chromium.*" + ], + "call": { + "org.freedesktop.portal.*": "*" }, - "session_bus": { - "see": null, - "talk": [ - "org.freedesktop.Notifications", - "org.freedesktop.FileManager1", - "org.freedesktop.ScreenSaver", - "org.freedesktop.secrets", - "org.kde.kwalletd5", - "org.kde.kwalletd6", - "org.gnome.SessionManager" - ], - "own": [ - "org.chromium.Chromium.*", - "org.mpris.MediaPlayer2.org.chromium.Chromium.*", - "org.mpris.MediaPlayer2.chromium.*" - ], - "call": { - "org.freedesktop.portal.*": "*" - }, - "broadcast": { - "org.freedesktop.portal.*": "@/org/freedesktop/portal/*" - }, - "filter": true + "broadcast": { + "org.freedesktop.portal.*": "@/org/freedesktop/portal/*" }, - "system_bus": { - "see": null, - "talk": [ - "org.bluez", - "org.freedesktop.Avahi", - "org.freedesktop.UPower" - ], - "own": null, - "call": null, - "broadcast": null, - "filter": true + "filter": true + }, + "system_bus": { + "see": null, + "talk": [ + "org.bluez", + "org.freedesktop.Avahi", + "org.freedesktop.UPower" + ], + "own": null, + "call": null, + "broadcast": null, + "filter": true + }, + "extra_perms": [ + { + "ensure": true, + "path": "/var/lib/hakurei/u0", + "x": true }, - "extra_perms": [ + { + "path": "/var/lib/hakurei/u0/org.chromium.Chromium", + "r": true, + "w": true, + "x": true + } + ], + "identity": 9, + "groups": [ + "video", + "dialout", + "plugdev" + ], + "container": { + "hostname": "localhost", + "wait_delay": -1, + "env": { + "GOOGLE_API_KEY": "AIzaSyBHDrl33hwRp4rMQY0ziRbj8K9LPA6vUCY", + "GOOGLE_DEFAULT_CLIENT_ID": "77185425430.apps.googleusercontent.com", + "GOOGLE_DEFAULT_CLIENT_SECRET": "OTJgUOQcT7lO7GsGZq2G4IlT" + }, + "filesystem": [ { - "ensure": true, - "path": "/var/lib/hakurei/u0", - "x": true + "type": "bind", + "dst": "/", + "src": "/var/lib/hakurei/base/org.debian", + "write": true, + "special": true }, { - "path": "/var/lib/hakurei/u0/org.chromium.Chromium", - "r": true, - "w": true, - "x": true + "type": "bind", + "dst": "/etc/", + "src": "/etc/", + "special": true + }, + { + "type": "ephemeral", + "dst": "/tmp/", + "write": true, + "perm": 493 + }, + { + "type": "overlay", + "dst": "/nix/store", + "lower": [ + "/var/lib/hakurei/base/org.nixos/ro-store" + ], + "upper": "/var/lib/hakurei/nix/u0/org.chromium.Chromium/rw-store/upper", + "work": "/var/lib/hakurei/nix/u0/org.chromium.Chromium/rw-store/work" + }, + { + "type": "link", + "dst": "/run/current-system", + "linkname": "/run/current-system", + "dereference": true + }, + { + "type": "link", + "dst": "/run/opengl-driver", + "linkname": "/run/opengl-driver", + "dereference": true + }, + { + "type": "bind", + "dst": "/data/data/org.chromium.Chromium", + "src": "/var/lib/hakurei/u0/org.chromium.Chromium", + "write": true, + "ensure": true + }, + { + "type": "bind", + "src": "/dev/dri", + "dev": true, + "optional": true } ], - "identity": 9, - "groups": [ - "video", - "dialout", - "plugdev" + "username": "chronos", + "shell": "/run/current-system/sw/bin/zsh", + "home": "/data/data/org.chromium.Chromium", + "path": "/run/current-system/sw/bin/chromium", + "args": [ + "chromium", + "--ignore-gpu-blocklist", + "--disable-smooth-scrolling", + "--enable-features=UseOzonePlatform", + "--ozone-platform=wayland" ], - "container": { - "hostname": "localhost", - "wait_delay": -1, - "env": { - "GOOGLE_API_KEY": "AIzaSyBHDrl33hwRp4rMQY0ziRbj8K9LPA6vUCY", - "GOOGLE_DEFAULT_CLIENT_ID": "77185425430.apps.googleusercontent.com", - "GOOGLE_DEFAULT_CLIENT_SECRET": "OTJgUOQcT7lO7GsGZq2G4IlT" - }, - "filesystem": [ - { - "type": "bind", - "dst": "/", - "src": "/var/lib/hakurei/base/org.debian", - "write": true, - "special": true - }, - { - "type": "bind", - "dst": "/etc/", - "src": "/etc/", - "special": true - }, - { - "type": "ephemeral", - "dst": "/tmp/", - "write": true, - "perm": 493 - }, - { - "type": "overlay", - "dst": "/nix/store", - "lower": [ - "/var/lib/hakurei/base/org.nixos/ro-store" - ], - "upper": "/var/lib/hakurei/nix/u0/org.chromium.Chromium/rw-store/upper", - "work": "/var/lib/hakurei/nix/u0/org.chromium.Chromium/rw-store/work" - }, - { - "type": "link", - "dst": "/run/current-system", - "linkname": "/run/current-system", - "dereference": true - }, - { - "type": "link", - "dst": "/run/opengl-driver", - "linkname": "/run/opengl-driver", - "dereference": true - }, - { - "type": "bind", - "dst": "/data/data/org.chromium.Chromium", - "src": "/var/lib/hakurei/u0/org.chromium.Chromium", - "write": true, - "ensure": true - }, - { - "type": "bind", - "src": "/dev/dri", - "dev": true, - "optional": true - } - ], - "username": "chronos", - "shell": "/run/current-system/sw/bin/zsh", - "home": "/data/data/org.chromium.Chromium", - "path": "/run/current-system/sw/bin/chromium", - "args": [ - "chromium", - "--ignore-gpu-blocklist", - "--disable-smooth-scrolling", - "--enable-features=UseOzonePlatform", - "--ozone-platform=wayland" - ], - "seccomp_compat": true, - "devel": true, - "userns": true, - "host_net": true, - "host_abstract": true, - "tty": true, - "multiarch": true, - "map_real_uid": true, - "device": true, - "share_runtime": true, - "share_tmpdir": true - } + "seccomp_compat": true, + "devel": true, + "userns": true, + "host_net": true, + "host_abstract": true, + "tty": true, + "multiarch": true, + "map_real_uid": true, + "device": true, + "share_runtime": true, + "share_tmpdir": true }, "time": "1970-01-01T00:00:00.000000009Z" } @@ -537,154 +535,152 @@ func TestPrintPs(t *testing.T) { "instance": "8e2c76b066dabe574cf073bdb46eb5c1", "pid": 3405691582, "shim_pid": 3735928559, - "config": { - "id": "org.chromium.Chromium", - "enablements": { - "wayland": true, - "dbus": true, - "pulse": true + "id": "org.chromium.Chromium", + "enablements": { + "wayland": true, + "dbus": true, + "pulse": true + }, + "session_bus": { + "see": null, + "talk": [ + "org.freedesktop.Notifications", + "org.freedesktop.FileManager1", + "org.freedesktop.ScreenSaver", + "org.freedesktop.secrets", + "org.kde.kwalletd5", + "org.kde.kwalletd6", + "org.gnome.SessionManager" + ], + "own": [ + "org.chromium.Chromium.*", + "org.mpris.MediaPlayer2.org.chromium.Chromium.*", + "org.mpris.MediaPlayer2.chromium.*" + ], + "call": { + "org.freedesktop.portal.*": "*" }, - "session_bus": { - "see": null, - "talk": [ - "org.freedesktop.Notifications", - "org.freedesktop.FileManager1", - "org.freedesktop.ScreenSaver", - "org.freedesktop.secrets", - "org.kde.kwalletd5", - "org.kde.kwalletd6", - "org.gnome.SessionManager" - ], - "own": [ - "org.chromium.Chromium.*", - "org.mpris.MediaPlayer2.org.chromium.Chromium.*", - "org.mpris.MediaPlayer2.chromium.*" - ], - "call": { - "org.freedesktop.portal.*": "*" - }, - "broadcast": { - "org.freedesktop.portal.*": "@/org/freedesktop/portal/*" - }, - "filter": true + "broadcast": { + "org.freedesktop.portal.*": "@/org/freedesktop/portal/*" }, - "system_bus": { - "see": null, - "talk": [ - "org.bluez", - "org.freedesktop.Avahi", - "org.freedesktop.UPower" - ], - "own": null, - "call": null, - "broadcast": null, - "filter": true + "filter": true + }, + "system_bus": { + "see": null, + "talk": [ + "org.bluez", + "org.freedesktop.Avahi", + "org.freedesktop.UPower" + ], + "own": null, + "call": null, + "broadcast": null, + "filter": true + }, + "extra_perms": [ + { + "ensure": true, + "path": "/var/lib/hakurei/u0", + "x": true }, - "extra_perms": [ + { + "path": "/var/lib/hakurei/u0/org.chromium.Chromium", + "r": true, + "w": true, + "x": true + } + ], + "identity": 9, + "groups": [ + "video", + "dialout", + "plugdev" + ], + "container": { + "hostname": "localhost", + "wait_delay": -1, + "env": { + "GOOGLE_API_KEY": "AIzaSyBHDrl33hwRp4rMQY0ziRbj8K9LPA6vUCY", + "GOOGLE_DEFAULT_CLIENT_ID": "77185425430.apps.googleusercontent.com", + "GOOGLE_DEFAULT_CLIENT_SECRET": "OTJgUOQcT7lO7GsGZq2G4IlT" + }, + "filesystem": [ { - "ensure": true, - "path": "/var/lib/hakurei/u0", - "x": true + "type": "bind", + "dst": "/", + "src": "/var/lib/hakurei/base/org.debian", + "write": true, + "special": true }, { - "path": "/var/lib/hakurei/u0/org.chromium.Chromium", - "r": true, - "w": true, - "x": true + "type": "bind", + "dst": "/etc/", + "src": "/etc/", + "special": true + }, + { + "type": "ephemeral", + "dst": "/tmp/", + "write": true, + "perm": 493 + }, + { + "type": "overlay", + "dst": "/nix/store", + "lower": [ + "/var/lib/hakurei/base/org.nixos/ro-store" + ], + "upper": "/var/lib/hakurei/nix/u0/org.chromium.Chromium/rw-store/upper", + "work": "/var/lib/hakurei/nix/u0/org.chromium.Chromium/rw-store/work" + }, + { + "type": "link", + "dst": "/run/current-system", + "linkname": "/run/current-system", + "dereference": true + }, + { + "type": "link", + "dst": "/run/opengl-driver", + "linkname": "/run/opengl-driver", + "dereference": true + }, + { + "type": "bind", + "dst": "/data/data/org.chromium.Chromium", + "src": "/var/lib/hakurei/u0/org.chromium.Chromium", + "write": true, + "ensure": true + }, + { + "type": "bind", + "src": "/dev/dri", + "dev": true, + "optional": true } ], - "identity": 9, - "groups": [ - "video", - "dialout", - "plugdev" + "username": "chronos", + "shell": "/run/current-system/sw/bin/zsh", + "home": "/data/data/org.chromium.Chromium", + "path": "/run/current-system/sw/bin/chromium", + "args": [ + "chromium", + "--ignore-gpu-blocklist", + "--disable-smooth-scrolling", + "--enable-features=UseOzonePlatform", + "--ozone-platform=wayland" ], - "container": { - "hostname": "localhost", - "wait_delay": -1, - "env": { - "GOOGLE_API_KEY": "AIzaSyBHDrl33hwRp4rMQY0ziRbj8K9LPA6vUCY", - "GOOGLE_DEFAULT_CLIENT_ID": "77185425430.apps.googleusercontent.com", - "GOOGLE_DEFAULT_CLIENT_SECRET": "OTJgUOQcT7lO7GsGZq2G4IlT" - }, - "filesystem": [ - { - "type": "bind", - "dst": "/", - "src": "/var/lib/hakurei/base/org.debian", - "write": true, - "special": true - }, - { - "type": "bind", - "dst": "/etc/", - "src": "/etc/", - "special": true - }, - { - "type": "ephemeral", - "dst": "/tmp/", - "write": true, - "perm": 493 - }, - { - "type": "overlay", - "dst": "/nix/store", - "lower": [ - "/var/lib/hakurei/base/org.nixos/ro-store" - ], - "upper": "/var/lib/hakurei/nix/u0/org.chromium.Chromium/rw-store/upper", - "work": "/var/lib/hakurei/nix/u0/org.chromium.Chromium/rw-store/work" - }, - { - "type": "link", - "dst": "/run/current-system", - "linkname": "/run/current-system", - "dereference": true - }, - { - "type": "link", - "dst": "/run/opengl-driver", - "linkname": "/run/opengl-driver", - "dereference": true - }, - { - "type": "bind", - "dst": "/data/data/org.chromium.Chromium", - "src": "/var/lib/hakurei/u0/org.chromium.Chromium", - "write": true, - "ensure": true - }, - { - "type": "bind", - "src": "/dev/dri", - "dev": true, - "optional": true - } - ], - "username": "chronos", - "shell": "/run/current-system/sw/bin/zsh", - "home": "/data/data/org.chromium.Chromium", - "path": "/run/current-system/sw/bin/chromium", - "args": [ - "chromium", - "--ignore-gpu-blocklist", - "--disable-smooth-scrolling", - "--enable-features=UseOzonePlatform", - "--ozone-platform=wayland" - ], - "seccomp_compat": true, - "devel": true, - "userns": true, - "host_net": true, - "host_abstract": true, - "tty": true, - "multiarch": true, - "map_real_uid": true, - "device": true, - "share_runtime": true, - "share_tmpdir": true - } + "seccomp_compat": true, + "devel": true, + "userns": true, + "host_net": true, + "host_abstract": true, + "tty": true, + "multiarch": true, + "map_real_uid": true, + "device": true, + "share_runtime": true, + "share_tmpdir": true }, "time": "1970-01-01T00:00:00.000000009Z" } diff --git a/cmd/hpkg/test/test.py b/cmd/hpkg/test/test.py index e2a002d..6f16729 100644 --- a/cmd/hpkg/test/test.py +++ b/cmd/hpkg/test/test.py @@ -60,13 +60,11 @@ def check_state(name, enablements): raise Exception(f"unexpected state length {len(instances)}") instance = next(iter(instances.values())) - config = instance['config'] + if len(instance['container']['args']) != 1 or not (instance['container']['args'][0].startswith("/nix/store/")) or f"hakurei-{name}-" not in (instance['container']['args'][0]): + raise Exception(f"unexpected args {instance['container']['args']}") - if len(config['container']['args']) != 1 or not (config['container']['args'][0].startswith("/nix/store/")) or f"hakurei-{name}-" not in (config['container']['args'][0]): - raise Exception(f"unexpected args {config['container']['args']}") - - if config['enablements'] != enablements: - raise Exception(f"unexpected enablements {config['enablements']}") + if instance['enablements'] != enablements: + raise Exception(f"unexpected enablements {instance['enablements']}") start_all() diff --git a/hst/instance.go b/hst/instance.go index e2ad5a5..b59a768 100644 --- a/hst/instance.go +++ b/hst/instance.go @@ -80,7 +80,7 @@ type State struct { ShimPID int `json:"shim_pid"` // Configuration used to start the container. - Config *Config `json:"config"` + *Config // Point in time the shim process was created. Time time.Time `json:"time"` diff --git a/test/test.py b/test/test.py index 3c36c61..cfc2f84 100644 --- a/test/test.py +++ b/test/test.py @@ -58,17 +58,15 @@ def check_state(name, enablements): raise Exception(f"unexpected state length {len(instances)}") instance = next(iter(instances.values())) - config = instance['config'] - command = f"{name}-start" - if not (config['container']['path'].startswith("/nix/store/")) or not (config['container']['path'].endswith(command)): - raise Exception(f"unexpected path {config['path']}") + if not (instance['container']['path'].startswith("/nix/store/")) or not (instance['container']['path'].endswith(command)): + raise Exception(f"unexpected path {instance['path']}") - if len(config['container']['args']) != 1 or config['container']['args'][0] != command: - raise Exception(f"unexpected args {config['args']}") + if len(instance['container']['args']) != 1 or instance['container']['args'][0] != command: + raise Exception(f"unexpected args {instance['args']}") - if config['enablements'] != enablements: - raise Exception(f"unexpected enablements {config['enablements']['enablements']}") + if instance['enablements'] != enablements: + raise Exception(f"unexpected enablements {instance['enablements']['enablements']}") def hakurei(command):