container/path: fhs path constants
All checks were successful
Test / Create distribution (push) Successful in 33s
Test / Sandbox (push) Successful in 2m6s
Test / Hakurei (push) Successful in 3m6s
Test / Sandbox (race detector) (push) Successful in 4m14s
Test / Hpkg (push) Successful in 4m11s
Test / Hakurei (race detector) (push) Successful in 4m40s
Test / Flake checks (push) Successful in 1m18s

This increases readability since this can help disambiguate absolute paths from similarly named path segments.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2025-08-03 20:46:41 +09:00
parent 38245559dc
commit c6be82bcf9
23 changed files with 164 additions and 123 deletions

View File

@@ -6,6 +6,7 @@ import (
"os"
"path"
"hakurei.app/container"
"hakurei.app/container/seccomp"
"hakurei.app/hst"
"hakurei.app/system"
@@ -94,17 +95,17 @@ func (app *appInfo) toFst(pathSet *appPathSet, argv []string, flagDropShell bool
Filesystem: []*hst.FilesystemConfig{
{Src: path.Join(pathSet.nixPath, "store"), Dst: "/nix/store", Must: true},
{Src: pathSet.metaPath, Dst: path.Join(hst.Tmp, "app"), Must: true},
{Src: "/etc/resolv.conf"},
{Src: "/sys/block"},
{Src: "/sys/bus"},
{Src: "/sys/class"},
{Src: "/sys/dev"},
{Src: "/sys/devices"},
{Src: container.FHSEtc + "resolv.conf"},
{Src: container.FHSSys + "block"},
{Src: container.FHSSys + "bus"},
{Src: container.FHSSys + "class"},
{Src: container.FHSSys + "dev"},
{Src: container.FHSSys + "devices"},
},
Link: [][2]string{
{app.CurrentSystem, "/run/current-system"},
{"/run/current-system/sw/bin", "/bin"},
{"/run/current-system/sw/bin", "/usr/bin"},
{app.CurrentSystem, container.FHSRun + "current-system"},
{container.FHSRun + "current-system/sw/bin", "/bin"},
{container.FHSRun + "current-system/sw/bin", container.FHSUsrBin},
},
Etc: path.Join(pathSet.cacheDir, "etc"),
AutoEtc: true,

View File

@@ -11,6 +11,7 @@ import (
"syscall"
"hakurei.app/command"
"hakurei.app/container"
"hakurei.app/hst"
"hakurei.app/internal"
"hakurei.app/internal/hlog"
@@ -275,12 +276,12 @@ func main() {
"path:" + a.NixGL + "#nixVulkanNvidia",
}, true, func(config *hst.Config) *hst.Config {
config.Container.Filesystem = append(config.Container.Filesystem, []*hst.FilesystemConfig{
{Src: "/etc/resolv.conf"},
{Src: "/sys/block"},
{Src: "/sys/bus"},
{Src: "/sys/class"},
{Src: "/sys/dev"},
{Src: "/sys/devices"},
{Src: container.FHSEtc + "resolv.conf"},
{Src: container.FHSSys + "block"},
{Src: container.FHSSys + "bus"},
{Src: container.FHSSys + "class"},
{Src: container.FHSSys + "dev"},
{Src: container.FHSSys + "devices"},
}...)
appendGPUFilesystem(config)
return config

View File

@@ -8,6 +8,7 @@ import (
"strconv"
"sync/atomic"
"hakurei.app/container"
"hakurei.app/hst"
"hakurei.app/internal/hlog"
)
@@ -21,7 +22,7 @@ func init() {
if p, ok := os.LookupEnv("HAKUREI_DATA_HOME"); ok {
dataHome = p
} else {
dataHome = "/var/lib/hakurei/" + strconv.Itoa(os.Getuid())
dataHome = container.FHSVarLib + "hakurei/" + strconv.Itoa(os.Getuid())
}
}

View File

@@ -5,6 +5,7 @@ import (
"path"
"strings"
"hakurei.app/container"
"hakurei.app/container/seccomp"
"hakurei.app/hst"
"hakurei.app/internal"
@@ -52,9 +53,9 @@ func withNixDaemon(
{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"},
{app.CurrentSystem, container.FHSRun + "current-system"},
{container.FHSRun + "current-system/sw/bin", "/bin"},
{container.FHSRun + "current-system/sw/bin", container.FHSUsrBin},
},
Etc: path.Join(pathSet.cacheDir, "etc"),
AutoEtc: true,
@@ -93,11 +94,11 @@ func withCacheDir(
{Src: workDir, Dst: path.Join(hst.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"},
{app.CurrentSystem, container.FHSRun + "current-system"},
{container.FHSRun + "current-system/sw/bin", "/bin"},
{container.FHSRun + "current-system/sw/bin", container.FHSUsrBin},
},
Etc: path.Join(workDir, "etc"),
Etc: path.Join(workDir, container.FHSEtc),
AutoEtc: true,
},
}, dropShell, beforeFail)