aboutsummaryrefslogtreecommitdiffhomepage
path: root/cmd/hpkg
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-10-07 01:50:56 +0900
committerOphestra <cat@gensokyo.uk>2025-10-07 04:24:45 +0900
commit9e48d7f5626aa966a23754534f3120855d6a7c32 (patch)
treeade6eb09abd52b4c64bb5eb9dfb5246ee93454fe /cmd/hpkg
parentf280994957bdc1c6defdd4bd9dcc44dd83a5cfd5 (diff)
hst/config: move container fields from toplevel
This change also moves pd behaviour to cmd/hakurei, as this does not belong in the hst API. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'cmd/hpkg')
-rw-r--r--cmd/hpkg/app.go14
-rw-r--r--cmd/hpkg/test/test.py6
-rw-r--r--cmd/hpkg/with.go50
3 files changed, 37 insertions, 33 deletions
diff --git a/cmd/hpkg/app.go b/cmd/hpkg/app.go
index 1a1437ff..a4910aae 100644
--- a/cmd/hpkg/app.go
+++ b/cmd/hpkg/app.go
@@ -66,19 +66,12 @@ func (app *appInfo) toHst(pathSet *appPathSet, pathname *container.Absolute, arg
config := &hst.Config{
ID: app.ID,
- Path: pathname,
- Args: argv,
-
Enablements: app.Enablements,
SystemBus: app.SystemBus,
SessionBus: app.SessionBus,
DirectWayland: app.DirectWayland,
- Username: "hakurei",
- Shell: pathShell,
- Home: pathDataData.Append(app.ID),
-
Identity: app.Identity,
Groups: app.Groups,
@@ -107,6 +100,13 @@ func (app *appInfo) toHst(pathSet *appPathSet, pathname *container.Absolute, arg
{FilesystemConfig: &hst.FSBind{Source: container.AbsFHSSys.Append("devices"), Optional: true}},
{FilesystemConfig: &hst.FSBind{Target: pathDataData.Append(app.ID), Source: pathSet.homeDir, Write: true, Ensure: true}},
},
+
+ Username: "hakurei",
+ Shell: pathShell,
+ Home: pathDataData.Append(app.ID),
+
+ Path: pathname,
+ Args: argv,
},
ExtraPerms: []*hst.ExtraPermConfig{
{Path: dataHome, Execute: true},
diff --git a/cmd/hpkg/test/test.py b/cmd/hpkg/test/test.py
index d491def3..e2a002d6 100644
--- a/cmd/hpkg/test/test.py
+++ b/cmd/hpkg/test/test.py
@@ -62,11 +62,11 @@ def check_state(name, enablements):
config = instance['config']
- if len(config['args']) != 1 or not (config['args'][0].startswith("/nix/store/")) or f"hakurei-{name}-" not in (config['args'][0]):
- raise Exception(f"unexpected args {instance['config']['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 {instance['config']['enablements']}")
+ raise Exception(f"unexpected enablements {config['enablements']}")
start_all()
diff --git a/cmd/hpkg/with.go b/cmd/hpkg/with.go
index 59545c62..b3ccd47a 100644
--- a/cmd/hpkg/with.go
+++ b/cmd/hpkg/with.go
@@ -18,22 +18,6 @@ func withNixDaemon(
mustRunAppDropShell(ctx, msg, updateConfig(&hst.Config{
ID: app.ID,
- Path: pathShell,
- Args: []string{bash, "-lc", "rm -f /nix/var/nix/daemon-socket/socket && " +
- // start nix-daemon
- "nix-daemon --store / & " +
- // wait for socket to appear
- "(while [ ! -S /nix/var/nix/daemon-socket/socket ]; do sleep 0.01; done) && " +
- // create directory so nix stops complaining
- "mkdir -p /nix/var/nix/profiles/per-user/root/channels && " +
- strings.Join(command, " && ") +
- // terminate nix-daemon
- " && pkill nix-daemon",
- },
-
- Username: "hakurei",
- Shell: pathShell,
- Home: pathDataData.Append(app.ID),
ExtraPerms: []*hst.ExtraPermConfig{
{Path: dataHome, Execute: true},
{Ensure: true, Path: pathSet.baseDir, Read: true, Write: true, Execute: true},
@@ -55,6 +39,23 @@ func withNixDaemon(
{FilesystemConfig: &hst.FSLink{Target: container.AbsFHSUsrBin, Linkname: pathSwBin.String()}},
{FilesystemConfig: &hst.FSBind{Target: pathDataData.Append(app.ID), Source: pathSet.homeDir, Write: true, Ensure: true}},
},
+
+ Username: "hakurei",
+ Shell: pathShell,
+ Home: pathDataData.Append(app.ID),
+
+ Path: pathShell,
+ Args: []string{bash, "-lc", "rm -f /nix/var/nix/daemon-socket/socket && " +
+ // start nix-daemon
+ "nix-daemon --store / & " +
+ // wait for socket to appear
+ "(while [ ! -S /nix/var/nix/daemon-socket/socket ]; do sleep 0.01; done) && " +
+ // create directory so nix stops complaining
+ "mkdir -p /nix/var/nix/profiles/per-user/root/channels && " +
+ strings.Join(command, " && ") +
+ // terminate nix-daemon
+ " && pkill nix-daemon",
+ },
},
}), dropShell, beforeFail)
}
@@ -67,12 +68,6 @@ func withCacheDir(
mustRunAppDropShell(ctx, msg, &hst.Config{
ID: app.ID,
- Path: pathShell,
- Args: []string{bash, "-lc", strings.Join(command, " && ")},
-
- Username: "nixos",
- Shell: pathShell,
- Home: pathDataData.Append(app.ID, "cache"),
ExtraPerms: []*hst.ExtraPermConfig{
{Path: dataHome, Execute: true},
{Ensure: true, Path: pathSet.baseDir, Read: true, Write: true, Execute: true},
@@ -94,13 +89,22 @@ func withCacheDir(
{FilesystemConfig: &hst.FSBind{Source: workDir, Target: hst.AbsTmp.Append("bundle")}},
{FilesystemConfig: &hst.FSBind{Target: pathDataData.Append(app.ID, "cache"), Source: pathSet.cacheDir, Write: true, Ensure: true}},
},
+
+ Username: "nixos",
+ Shell: pathShell,
+ Home: pathDataData.Append(app.ID, "cache"),
+
+ Path: pathShell,
+ Args: []string{bash, "-lc", strings.Join(command, " && ")},
},
}, dropShell, beforeFail)
}
func mustRunAppDropShell(ctx context.Context, msg container.Msg, config *hst.Config, dropShell bool, beforeFail func()) {
if dropShell {
- config.Args = []string{bash, "-l"}
+ if config.Container != nil {
+ config.Container.Args = []string{bash, "-l"}
+ }
mustRunApp(ctx, msg, config, beforeFail)
beforeFail()
msg.BeforeExit()