diff options
| author | Crash Over Burn | 2026-04-14 13:05:33 +0000 |
|---|---|---|
| committer | ยท๐๐ด๐๐๐ฉ๐ค | 2026-04-14 13:05:33 +0000 |
| commit | e6c901d2e5430a3815109b38ced11a4f695f0226 (patch) | |
| tree | 07a4cf8846035d5968f7a78007f71cc1fc6dd6fc /bin | |
| parent | 26fef65e28c3f085d33a5d222aa1dbac245ec435 (diff) | |
| download | nixtaml-e6c901d2e5430a3815109b38ced11a4f695f0226.tar nixtaml-e6c901d2e5430a3815109b38ced11a4f695f0226.tar.gz nixtaml-e6c901d2e5430a3815109b38ced11a4f695f0226.tar.bz2 nixtaml-e6c901d2e5430a3815109b38ced11a4f695f0226.tar.lz nixtaml-e6c901d2e5430a3815109b38ced11a4f695f0226.tar.xz nixtaml-e6c901d2e5430a3815109b38ced11a4f695f0226.tar.zst nixtaml-e6c901d2e5430a3815109b38ced11a4f695f0226.zip | |
Port upstream patches: Cmdliner 2.x, lockfile auto-creation, schema upgrade, Fossil VCS
Ported from upstream darcs repository (v1.1.2):
- Cmdliner 2.x compatibility fixes (variable shadowing)
- Lockfile auto-creation when missing
- Schema upgrade command with backup/rollback
- Fossil VCS support (new VCS type)
- Clean up Cmdliner warning for unescaped $PWD
Files modified:
- lib/schema.ml (new): Schema versioning module
- lib/nixtamal.ml: Add upgrade function, Fossil meld support
- lib/error.ml: Add Fossil to prefetch_method, Upgrade error
- lib/input.ml: Add Fossil module, Kind variant
- lib/prefetch.ml: Add Fossil prefetch with SRI hash support
- lib/manifest.ml: Add Fossil codec
- lib/lockfile.ml: Add Fossil lockfile type
- lib/lock_loader.ml: Add Fossil feature flag
- lib/input_foreman.ml: Add Fossil display and prefetch check
- bin/cmd.ml: Cmdliner 2.x fixes, add Upgrade command
- bin/dune, lib/dune, test/dune: Deprecation flags
Builds successfully with all tests passing.
Diffstat (limited to 'bin')
| -rw-r--r-- | bin/cmd.ml | 84 | ||||
| -rw-r--r-- | bin/dune | 1 | ||||
| -rw-r--r-- | bin/main.ml | 1 |
3 files changed, 78 insertions, 8 deletions
@@ -29,7 +29,7 @@ module Global = struct & info ["directory"] ~env - ~doc: "Working directory for Nixtamal-related files (default: $PWD/nix/tamal)" + ~doc: "Working directory for Nixtamal-related files (default: \\$PWD/nix/tamal)" ~docv: "PATH" ) @@ -186,8 +186,9 @@ module Set_up = struct $ nixpkgs_revision_arg ) in + let eio_env = env in Term.( - const (fun glb -> Global.run ~env glb @@ run) + const (fun glb -> Global.run ~env: eio_env glb @@ run) $ Global.args $ nixpkgs_arg ) @@ -210,8 +211,9 @@ module Check_soundness = struct let term ~env = let open Cmdliner in + let eio_env = env in Term.( - const (fun glb -> Global.run ~env glb @@ run) + const (fun glb -> Global.run ~env: eio_env glb @@ run) $ Global.args ) @@ -233,8 +235,9 @@ module Tweak = struct let term ~env = let open Cmdliner in + let eio_env = env in Term.( - const (fun glb -> Global.run ~env glb @@ run) + const (fun glb -> Global.run ~env: eio_env glb @@ run) $ Global.args ) @@ -255,8 +258,9 @@ module Show = struct let term ~env = let open Cmdliner in + let eio_env = env in Term.( - const (fun glb -> Global.run ~env glb @@ run) + const (fun glb -> Global.run ~env: eio_env glb @@ run) $ Global.args ) @@ -291,8 +295,9 @@ module Lock = struct & info [] ~docv: "INPUT_NAME" ~doc: "Input names to lock (if already locked, will skip)." ) in + let eio_env = env in Term.( - const (fun glb force -> Global.run ~env glb @@ run force) + const (fun glb force -> Global.run ~env: eio_env glb @@ run force) $ Global.args $ force_arg $ names_arg @@ -315,8 +320,9 @@ module List_stale = struct let term ~env = let open Cmdliner in + let eio_env = env in Term.( - const (fun glb -> Global.run ~env glb @@ run) + const (fun glb -> Global.run ~env: eio_env glb @@ run) $ Global.args ) @@ -345,11 +351,73 @@ module Refresh = struct & info [] ~docv: "INPUT_NAME" ~doc: "Input names to refresh." ) in + let eio_env = env in Term.( - const (fun glb -> Global.run ~env glb @@ run) + const (fun glb -> Global.run ~env: eio_env glb @@ run) $ Global.args $ names_arg ) let cmd ~env = Cmdliner.Cmd.v info (term ~env) end + +module Upgrade = struct + let info = + Cmdliner.Cmd.info + "upgrade" + ~doc: "Upgrade lockfile & manifest to current schema version." + ~exits: Cmdliner.Cmd.Exit.defaults + ~man: common_man + + let run ~env: _ ~domain_count: _ from to_ dry_run : unit = + let open Nixtamal in + match upgrade ?from ?to_ ~dry_run () with + | Ok () -> () + | Error err -> failwith (Fmt.str "%a" Nixtamal.Error.pp err) + + let term ~env = + let eio_env = env in + let open Cmdliner in + let version_conv : Nixtamal.Schema.Version.t Arg.conv = + Arg.conv + ~docv: "VERSION" + ((fun s -> + match Nixtamal.Schema.Version.of_string s with + | Some v -> Ok v + | None -> + let valid = Fmt.(array ~sep: comma Nixtamal.Schema.Version.pp) in + Error (`Msg (Fmt.str "Invalid version %s. Valid versions: %a" s valid Nixtamal.Schema.Version.versions)) + ), + Nixtamal.Schema.Version.pp) + in + let from_arg = + let doc = "Upgrade from a specific version. Must match the lockfile version." in + Arg.( + value + & opt (some version_conv) None + & info ["from"] ~doc ~docv: "VERSION" + ) + and to_arg = + let doc = "Upgrade to a specific version. Must be newer than --from." in + Arg.( + value + & opt (some version_conv) None + & info ["to"] ~doc ~docv: "VERSION" + ) + and dry_run_arg = + Arg.( + value + & flag + & info ["dry-run"] ~doc: "Show what would be upgraded without making changes." + ) + in + Term.( + const (fun glb -> Global.run ~env: eio_env glb @@ run) + $ Global.args + $ from_arg + $ to_arg + $ dry_run_arg + ) + + let cmd ~env = Cmdliner.Cmd.v info (term ~env) +end @@ -13,6 +13,7 @@ logs.cli logs.fmt uri) + (flags (:standard -alert -deprecated)) (preprocess (pps ppx_deriving.show ppx_deriving.eq ppx_deriving.ord ppx_deriving.make))) diff --git a/bin/main.ml b/bin/main.ml index bdb25e7..739776f 100644 --- a/bin/main.ml +++ b/bin/main.ml @@ -27,6 +27,7 @@ let cmd ~env = Cmd.Lock.cmd ~env; Cmd.List_stale.cmd ~env; Cmd.Refresh.cmd ~env; + Cmd.Upgrade.cmd ~env; ] in Cmdliner.Cmd.group info subcommands |
