aboutsummaryrefslogtreecommitdiffhomepage
path: root/cmd/app/app.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-09-17 02:30:10 +0900
committerOphestra <cat@gensokyo.uk>2026-09-17 02:30:10 +0900
commit4078289cdadb4def6ae28428ce8bf3c7907f66f1 (patch)
treefd7c9dd9192cc4bb9aeb94c1efb7411687535231 /cmd/app/app.go
parent3fbdf138bb7ce07319d2c9e3d89b3a3892e139d2 (diff)
cmd/app: alternative merged template layout
This implements an optional, alternative template layout to accommodate ZFS and equivalent setups where each template occupies a different filesystem. In such a setup, the default, separate workdir is unusable as overlayfs requires the workdir to reside on the same filesystem as the writable upperdir. The "merge" build tag enables this alternative behaviour. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'cmd/app/app.go')
-rw-r--r--cmd/app/app.go26
1 files changed, 22 insertions, 4 deletions
diff --git a/cmd/app/app.go b/cmd/app/app.go
index 9679413f..ca809334 100644
--- a/cmd/app/app.go
+++ b/cmd/app/app.go
@@ -14,6 +14,24 @@ import (
"hakurei.app/hst"
)
+// base is the root of the persistent state directory.
+type base check.Absolute
+
+// append calls filepath.Join with b as the first element.
+func (b *base) append(elem ...string) *check.Absolute {
+ return (*check.Absolute)(b).Append(elem...)
+}
+
+// initial returns the pathname of the bottom layer.
+func (b *base) initial() *check.Absolute {
+ return b.append("initial")
+}
+
+// state returns the pathname of the home directory for id.
+func (b *base) state(id string) *check.Absolute {
+ return b.append("state", id)
+}
+
// parsePair parses a NUL-delimited quoted paths pair.
func parsePair(s string) (source, target *check.Absolute, err error) {
var p string
@@ -35,7 +53,7 @@ func parsePair(s string) (source, target *check.Absolute, err error) {
// corresponding [hst.Config].
func parse(
id string,
- base *check.Absolute,
+ base *base,
r io.Reader,
templateP *string,
) (*hst.Config, error) {
@@ -44,7 +62,7 @@ func parse(
root := hst.FSOverlay{
Target: fhs.AbsRoot,
- Lower: []*check.Absolute{base.Append("initial")},
+ Lower: []*check.Absolute{base.initial()},
}
c := hst.Config{
ID: id,
@@ -65,7 +83,7 @@ func parse(
{FilesystemConfig: &root},
{FilesystemConfig: &hst.FSBind{
Target: home,
- Source: base.Append("state", id),
+ Source: base.state(id),
Write: true,
Ensure: true,
}},
@@ -110,7 +128,7 @@ func parse(
*templateP = template
}
c.Identity = v
- root.Upper = base.Append("template", template)
+ root.Upper = base.template(template)
}
if err := scanOnce(); err != nil {