aboutsummaryrefslogtreecommitdiffhomepage
path: root/cmd/fpkg/with.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-04-13 03:23:28 +0900
committerOphestra <cat@gensokyo.uk>2025-04-13 03:30:19 +0900
commit31b7ddd122d54c36edb101d2c8bdf230651f27d4 (patch)
tree2dd0623bfa0d410d83aabfc51d276df3a14ef3e8 /cmd/fpkg/with.go
parentc460892cbdfa66a2cf1f0ebcec59cf550e67962e (diff)
fst: improve config
The config struct more or less "grew" to what it is today. This change moves things around to make more sense and fixes nonsensical comments describing obsolete behaviour. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'cmd/fpkg/with.go')
-rw-r--r--cmd/fpkg/with.go108
1 files changed, 56 insertions, 52 deletions
diff --git a/cmd/fpkg/with.go b/cmd/fpkg/with.go
index 92c5ba9e..9de1a397 100644
--- a/cmd/fpkg/with.go
+++ b/cmd/fpkg/with.go
@@ -16,7 +16,8 @@ func withNixDaemon(
app *appInfo, pathSet *appPathSet, dropShell bool, beforeFail func(),
) {
mustRunAppDropShell(ctx, updateConfig(&fst.Config{
- ID: app.ID,
+ ID: app.ID,
+
Path: shellPath,
Args: []string{shellPath, "-lc", "rm -f /nix/var/nix/daemon-socket/socket && " +
// start nix-daemon
@@ -29,33 +30,34 @@ func withNixDaemon(
// terminate nix-daemon
" && pkill nix-daemon",
},
- Confinement: fst.ConfinementConfig{
- AppID: app.AppID,
- Username: "fortify",
- Inner: path.Join("/data/data", app.ID),
- Outer: pathSet.homeDir,
- Shell: shellPath,
- Sandbox: &fst.SandboxConfig{
- Hostname: formatHostname(app.Name) + "-" + action,
- Userns: true, // nix sandbox requires userns
- Net: net,
- Seccomp: seccomp.FilterMultiarch,
- Tty: dropShell,
- Filesystem: []*fst.FilesystemConfig{
- {Src: pathSet.nixPath, Dst: "/nix", Write: true, Must: true},
- },
- Link: [][2]string{
- {app.CurrentSystem, "/run/current-system"},
- {"/run/current-system/sw/bin", "/bin"},
- {"/run/current-system/sw/bin", "/usr/bin"},
- },
- Etc: path.Join(pathSet.cacheDir, "etc"),
- AutoEtc: true,
+
+ Username: "fortify",
+ Shell: shellPath,
+ Data: pathSet.homeDir,
+ Dir: path.Join("/data/data", app.ID),
+ ExtraPerms: []*fst.ExtraPermConfig{
+ {Path: dataHome, Execute: true},
+ {Ensure: true, Path: pathSet.baseDir, Read: true, Write: true, Execute: true},
+ },
+
+ Identity: app.Identity,
+
+ Container: &fst.ContainerConfig{
+ Hostname: formatHostname(app.Name) + "-" + action,
+ Userns: true, // nix sandbox requires userns
+ Net: net,
+ Seccomp: seccomp.FilterMultiarch,
+ Tty: dropShell,
+ Filesystem: []*fst.FilesystemConfig{
+ {Src: pathSet.nixPath, Dst: "/nix", Write: true, Must: true},
},
- ExtraPerms: []*fst.ExtraPermConfig{
- {Path: dataHome, Execute: true},
- {Ensure: true, Path: pathSet.baseDir, Read: true, Write: true, Execute: true},
+ Link: [][2]string{
+ {app.CurrentSystem, "/run/current-system"},
+ {"/run/current-system/sw/bin", "/bin"},
+ {"/run/current-system/sw/bin", "/usr/bin"},
},
+ Etc: path.Join(pathSet.cacheDir, "etc"),
+ AutoEtc: true,
},
}), dropShell, beforeFail)
}
@@ -65,36 +67,38 @@ func withCacheDir(
action string, command []string, workDir string,
app *appInfo, pathSet *appPathSet, dropShell bool, beforeFail func()) {
mustRunAppDropShell(ctx, &fst.Config{
- ID: app.ID,
+ ID: app.ID,
+
Path: shellPath,
Args: []string{shellPath, "-lc", strings.Join(command, " && ")},
- Confinement: fst.ConfinementConfig{
- AppID: app.AppID,
- Username: "nixos",
- Inner: path.Join("/data/data", app.ID, "cache"),
- Outer: pathSet.cacheDir, // this also ensures cacheDir via shim
- Shell: shellPath,
- Sandbox: &fst.SandboxConfig{
- Hostname: formatHostname(app.Name) + "-" + action,
- Seccomp: seccomp.FilterMultiarch,
- Tty: dropShell,
- Filesystem: []*fst.FilesystemConfig{
- {Src: path.Join(workDir, "nix"), Dst: "/nix", Must: true},
- {Src: workDir, Dst: path.Join(fst.Tmp, "bundle"), Must: true},
- },
- Link: [][2]string{
- {app.CurrentSystem, "/run/current-system"},
- {"/run/current-system/sw/bin", "/bin"},
- {"/run/current-system/sw/bin", "/usr/bin"},
- },
- Etc: path.Join(workDir, "etc"),
- AutoEtc: true,
+
+ Username: "nixos",
+ Shell: shellPath,
+ Data: pathSet.cacheDir, // this also ensures cacheDir via shim
+ Dir: path.Join("/data/data", app.ID, "cache"),
+ ExtraPerms: []*fst.ExtraPermConfig{
+ {Path: dataHome, Execute: true},
+ {Ensure: true, Path: pathSet.baseDir, Read: true, Write: true, Execute: true},
+ {Path: workDir, Execute: true},
+ },
+
+ Identity: app.Identity,
+
+ Container: &fst.ContainerConfig{
+ Hostname: formatHostname(app.Name) + "-" + action,
+ Seccomp: seccomp.FilterMultiarch,
+ Tty: dropShell,
+ Filesystem: []*fst.FilesystemConfig{
+ {Src: path.Join(workDir, "nix"), Dst: "/nix", Must: true},
+ {Src: workDir, Dst: path.Join(fst.Tmp, "bundle"), Must: true},
},
- ExtraPerms: []*fst.ExtraPermConfig{
- {Path: dataHome, Execute: true},
- {Ensure: true, Path: pathSet.baseDir, Read: true, Write: true, Execute: true},
- {Path: workDir, Execute: true},
+ Link: [][2]string{
+ {app.CurrentSystem, "/run/current-system"},
+ {"/run/current-system/sw/bin", "/bin"},
+ {"/run/current-system/sw/bin", "/usr/bin"},
},
+ Etc: path.Join(workDir, "etc"),
+ AutoEtc: true,
},
}, dropShell, beforeFail)
}