summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorยท๐‘‘๐‘ด๐‘•๐‘‘๐‘ฉ๐‘ค2026-01-02 18:15:34 +0000
committerยท๐‘‘๐‘ด๐‘•๐‘‘๐‘ฉ๐‘ค2026-01-02 18:15:34 +0000
commit034a4c5c3be5ffe5f15633214746b05ed69bf548 (patch)
tree4cfe6c80e28e109af59db630c0475f3ff67e76d6
parent939ebcc0ff3414083bb6d1bbd366aca64dfd4f6b (diff)
downloadnixtaml-034a4c5c3be5ffe5f15633214746b05ed69bf548.tar
nixtaml-034a4c5c3be5ffe5f15633214746b05ed69bf548.tar.gz
nixtaml-034a4c5c3be5ffe5f15633214746b05ed69bf548.tar.bz2
nixtaml-034a4c5c3be5ffe5f15633214746b05ed69bf548.tar.lz
nixtaml-034a4c5c3be5ffe5f15633214746b05ed69bf548.tar.xz
nixtaml-034a4c5c3be5ffe5f15633214746b05ed69bf548.tar.zst
nixtaml-034a4c5c3be5ffe5f15633214746b05ed69bf548.zip
Silo: make names a folder for the future
-rw-r--r--lib/input_foreman.ml23
1 files changed, 20 insertions, 3 deletions
diff --git a/lib/input_foreman.ml b/lib/input_foreman.ml
index 4c38dcb..dec3f32 100644
--- a/lib/input_foreman.ml
+++ b/lib/input_foreman.ml
@@ -190,6 +190,15 @@ let unlink_or_rm_silo ~(at : [`Path of _ Eio.Path.t | `Name of Name.t]) =
| _ ->
()
+(* TODO: make
+ .silo/{name}/elotl
+ .silo/{name}/milpa
+ .silo/{name}/by-hash
+
+ Where elotl (ear of maize) refers to the one using now & milpa
+ (maizefield) refers to the generation. This is similar to profiles &
+ could allow rollbacks & such.
+*)
let make_silo_gc_root ~proc_mgr ~name ~store_path =
let name = Name.take name in
let silo_path = Eio.Path.(Working_directory.(get () / silo_dir)) in
@@ -200,12 +209,20 @@ let make_silo_gc_root ~proc_mgr ~name ~store_path =
| _ -> failwith (Fmt.str "%a not a directory" Eio.Path.pp silo_path)
end;
let path = Eio.Path.(silo_path / name) in
- Logs.info (fun m -> m "Silo: filling with %s โ†ฆ %s โ€ฆ" name store_path);
- unlink_or_rm_silo ~at: (`Path path);
+ begin
+ match Eio.Path.kind ~follow: false path with
+ | `Directory -> ()
+ | `Symbolic_link -> Eio.Path.unlink path;
+ | `Regular_file | `Socket -> Eio.Path.rmtree path;
+ | _ -> ()
+ end;
+ Logs.info (fun m -> m "Silo: elotl now %s โ†ฆ %s โ€ฆ" name store_path);
+ let elotl_path = Eio.Path.(path / "elotl") in
+ unlink_or_rm_silo ~at: (`Path elotl_path);
Eio.Process.run proc_mgr [
"nix-store";
"--add-root";
- Eio.Path.native_exn path;
+ Eio.Path.native_exn elotl_path;
"--realize";
store_path
]