diff --git a/.gitignore b/.gitignore index 48e0314..11335fc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .direnv .envrc .ldx +result* diff --git a/default.nix b/default.nix index 043c1fd..0a03704 100644 --- a/default.nix +++ b/default.nix @@ -1,149 +1,119 @@ -# `ldx`: one tool — a CLI that tracks and manages nvim LSP library deps. -# -# Single module, single flake output (`.#ldx`): the CLI binary, with the locked -# per-project resolutions it needs attached as `deps` (`nix build .#ldx.deps.`). -# `ldx sync` resolves each `.ldx.json` manifest against the repo's pinned pkgs by -# building the matching `deps` derivation; its out-link GC-protects every library. -# -# NOTE: `local` refs (any relative path such as `./x`, `../x/y/z`) are deliberately -# NOT resolved in Nix. Inside a flake, paths are copied to the store, so resolving -# them here would yield /nix/store paths. They are passed through verbatim and -# resolved by `ldx sync` against the real, live project directory. {pkgs, ...}: let + pog = import (fetchTarball { + name = "pog-2026-11-26"; + url = "https://github.com/jpetrucciani/pog/archive/main.tar.gz"; + sha256 = "sha256:13nydq0a5sjan5j9g1y8qv1gs8y16pn35nwixahnkqwxyflkmfpy"; + }) { + inherit pkgs; + }; + versionInfo = import ./version.nix; inherit (versionInfo) version; - inherit (builtins) readDir pathExists readFile fromJSON toJSON toString; + inherit (builtins) toJSON; inherit (pkgs) lib; - lapsDir = toString ../.; - - # `vimPlugins.snacks-nvim` -> `VIMPLUGINS_SNACKS_NVIM` (mirrors legacy ldx env naming) - sanitize = s: let - chars = lib.stringToCharacters s; - ok = c: - if builtins.match "[A-Za-z0-9]" c != null - then c - else "_"; - in - lib.toUpper (lib.concatStrings (map ok chars)); - - pkgByPath = attr: lib.getAttrFromPath (lib.splitString "." attr) pkgs; - - # One manifest ref -> a dependency entry. `kind` is one of: - # nix -> `path` is a store path, `subdir` points at the lua library dir - # local -> `path` is the RELATIVE ref, untouched (resolved by `ldx sync` - # against the real project dir, so it is never a store path) - # literal -> `path` is used verbatim (`${3rd}/luv/library`) - resolveRef = _dir: ref: - if lib.hasPrefix "./" ref || lib.hasPrefix "../" ref - then { - kind = "local"; - var = "LDX_LOCAL_${sanitize ref}"; - name = sanitize ref; - path = ref; - } - else if ref == "luv" - then { + + cfg = { + name = "ldx"; + envPrefix = "LDX"; + manifest = ".ldx.json"; + stateDirName = ".ldx"; + stateFileName = "state.json"; + errFileName = "sync.err"; + libDirName = "lib"; + gcrootsDirName = "gcroots"; + luarcName = ".luarc.json"; + luarcLibraryPath = ".workspace.library"; + lockFile = "flake.lock"; + fingerprintSalt = "ldx-state-rev3"; + localPrefixes = ["./" "../"]; + relativeFlakeRoots = ["." ".."]; + defaultFlake = "nixpkgs"; + defaultSubdir = "lua"; + refSeparator = ":"; + }; + + inherit + (cfg) + name + envPrefix + manifest + stateDirName + stateFileName + errFileName + libDirName + gcrootsDirName + luarcName + luarcLibraryPath + lockFile + fingerprintSalt + localPrefixes + relativeFlakeRoots + defaultFlake + defaultSubdir + refSeparator + ; + + inherit (builtins) storeDir; + + localPattern = lib.concatMapStringsSep "|" (p: "${p}*") localPrefixes; + relPattern = lib.concatStringsSep "|" (relativeFlakeRoots ++ [localPattern]); + + specialRefs = { + luv = { kind = "literal"; - var = "LDX_LUV_LIBRARY"; + var = "${envPrefix}_LUV_LIBRARY"; name = "luv"; path = "\${3rd}/luv/library"; - } - else if ref == "vim" - then { - kind = "nix"; - var = "LDX_VIM_RUNTIME"; + }; + vim = { + kind = "nixpkgs"; + var = "${envPrefix}_VIM_RUNTIME"; name = "nvim"; - path = pkgs.neovim-unwrapped; + attr = "neovim-unwrapped"; subdir = "share/nvim/runtime/lua"; - } - else let - parts = lib.splitString ":" ref; - flake = - if builtins.length parts >= 2 - then builtins.elemAt parts 0 - else "nixpkgs"; - attr = - if builtins.length parts == 1 - then builtins.elemAt parts 0 - else builtins.elemAt parts 1; - subdir = - if builtins.length parts == 3 - then builtins.elemAt parts 2 - else "lua"; - - package = - if flake == "nixpkgs" || flake == "." - then pkgByPath attr - else throw "ldx: unsupported flake '${flake}' in ref '${ref}' (${toString _dir})"; - in { - kind = "nix"; - var = "LDX_${sanitize attr}"; - name = sanitize attr; - inherit subdir; - path = package; }; + }; - projectDeps = _name: dir: - map (resolveRef dir) (fromJSON (readFile (dir + "/.ldx.json"))); - - projects = - lib.filterAttrs - (name: type: type == "directory" && pathExists (lapsDir + "/" + name + "/.ldx.json")) - (readDir lapsDir); - - deps = lib.mapAttrs (name: _: let - dir = lapsDir + "/" + name; - projectDeps' = projectDeps name dir; - in - pkgs.runCommand "ldx-deps-${name}" {} '' - mkdir -p $out - echo '${toJSON projectDeps'}' > $out/deps.json - '') - projects; - - repoFlag = { - name = "repo"; - description = "Path to the arnos repository (default: \$ARNOS_REPO or ~/workspaces/arnos)"; + specialRefsFile = pkgs.writeText "${name}-special-refs.json" (toJSON specialRefs); + + workspacesArgument = { + name = "workspaces"; + description = "Workspace dirs (default: current directory)"; + variadic = true; }; prelude = '' - _ldx_repo() { - local r - r="''${repo:-''${ARNOS_REPO:-''${HOME}/workspaces/arnos}}" - r="$({ cd "$r" 2>/dev/null && pwd; } || echo "$r")" - if [[ ! -f "$r/flake.lock" ]]; then - echo "ldx: error: could not find arnos repo at '$r'" >&2 - exit 1 + # each argument must be a dir holding a manifest; no arguments means the cwd + _ldx_workspaces() { + local w d + if [[ $# -eq 0 ]]; then + set -- "$PWD" fi - echo "$r" + for w in "$@"; do + d="$({ cd "$w" 2>/dev/null && pwd; } || true)" + if [[ -z "$d" || ! -f "$d/${manifest}" ]]; then + echo "${name}: error: no manifest at $w/${manifest}" >&2 + return 1 + fi + echo "$d" + done } - # projects: names/dirs given as args, or every dir under apps holding a manifest - _ldx_projects() { - local laps_dir="$1" - shift - local dirs=() - if [[ $# -gt 0 ]]; then - local p d - for p in "$@"; do - if [[ -d "$p" ]]; then d="$p"; else d="$laps_dir/$p"; fi - if [[ ! -f "$d/.ldx.json" ]]; then - echo "ldx: error: no manifest at $d/.ldx.json" >&2 - return 1 - fi - dirs+=("$d") - done - else - # glob avoids relying on find's -mindepth/-maxdepth behaviour - local p - for p in "$laps_dir"/*/.ldx.json; do - [[ -e "$p" ]] || continue - dirs+=("''${p%/.ldx.json}") - done - fi - if [[ ''${#dirs[@]} -gt 0 ]]; then - printf '%s\n' "''${dirs[@]}" - fi + # nearest ancestor (or self) holding the flake lockfile + _ldx_flake_dir() { + local p="$1" + while [[ "$p" != "/" ]]; do + if [[ -f "$p/${lockFile}" ]]; then + echo "$p" + return 0 + fi + p="$(dirname "$p")" + done + return 1 + } + + _ldx_sanitize() { + printf '%s' "$1" | sed 's/[^A-Za-z0-9]/_/g' | tr '[:lower:]' '[:upper:]' } _contains() { @@ -156,24 +126,21 @@ return 1 } - # cheap change detection: manifest + repo lockfile are the only facts that - # can alter resolution, hashing them costs no nix invocations at all + # manifest + lockfile are the only inputs that can alter resolution; the + # salt is bumped whenever resolution semantics change _ldx_fingerprint() { local d="$1" lock="$2" - # "rev2" salt: bump whenever resolution semantics change, so stale state - # (e.g. local deps recorded as /nix/store paths) is re-resolved - { echo "ldx-state-rev2"; cat "$d/.ldx.json"; cat "$lock"; } | sha256sum | cut -d' ' -f1 + { echo "${fingerprintSalt}"; cat "$d/${manifest}"; [[ -z "$lock" ]] || cat "$lock"; } | sha256sum | cut -d' ' -f1 } - # lightweight validation of a previously sync'ed state: every non-literal - # reference must still resolve to a real directory (no nix involved) + # every non-literal reference must still resolve to a real directory _ldx_lightcheck() { local st="$1" kind value real bad=0 [[ -f "$st" ]] || return 1 while IFS=$'\t' read -r kind value; do [[ "$kind" == "literal" ]] && continue # a local dep must be a live working-tree path, never a store copy - if [[ "$kind" == "local" && "$value" == /nix/store/* ]]; then + if [[ "$kind" == "local" && "$value" == ${storeDir}/* ]]; then bad=1 continue fi @@ -186,93 +153,157 @@ } ''; - cli = pkgs.pog.pog { - name = "ldx"; - description = "Lua dependency manager: resolves nvim LSP library references (.luarc.json)"; - inherit version; + cli = pog.pog { + inherit name version; + description = "Lua dependency manager: resolves nvim LSP library references (${luarcName})"; runtimeInputs = [pkgs.jq pkgs.findutils pkgs.gnused pkgs.coreutils]; commands = [ { name = "sync"; - description = "Resolve dependencies and update .luarc.json for projects (default: all)"; - flags = [repoFlag]; - arguments = [ - { - name = "projects"; - description = "Project dirs/names (default: all)"; - variadic = true; - } - ]; + description = "Resolve dependencies and update ${luarcName} for workspaces (default: current directory)"; + arguments = [workspacesArgument]; script = '' ${prelude} - sync_project() { - local d="$1" lock="$2" - local proj ldx_dir fp stored st deps_out json - proj="$(basename "$d")" - ldx_dir="$d/.ldx" - st="$ldx_dir/state.json" + # sets kind, var, name, path, inst, subdir, attr in the caller's scope + resolve_ref() { + local ref="$1" sp flake_ rel + local -a parts=() + kind="" var="" name="" path="" inst="" subdir="" attr="" + + sp="$(jq -c --arg r "$ref" '.[$r] // empty' "${specialRefsFile}")" + if [[ -n "$sp" ]]; then + kind="$(jq -r '.kind' <<< "$sp")" + var="$(jq -r '.var' <<< "$sp")" + name="$(jq -r '.name // ""' <<< "$sp")" + path="$(jq -r '.path // ""' <<< "$sp")" + subdir="$(jq -r '.subdir // ""' <<< "$sp")" + attr="$(jq -r '.attr // ""' <<< "$sp")" + [[ -z "$attr" ]] || inst="${defaultFlake}#$attr" + return 0 + fi + + if [[ "$ref" == *"#"* ]]; then + flake_="''${ref%%#*}" + attr="''${ref#*#}" + case "$flake_" in + ${relPattern}) ;; + *) + echo "${name}: error: $ws: unsupported flake '$flake_' in ref '$ref'" >&2 + return 1 + ;; + esac + rel="$(realpath -m "$d/$flake_")" + kind="flake" + name="$(_ldx_sanitize "$ref")" + var="${envPrefix}_FLAKE_$name" + subdir="${defaultSubdir}" + inst="$rel#$attr" + return 0 + fi - mkdir -p "$ldx_dir/lib" "$ldx_dir/gcroots" || return 1 + case "$ref" in + ${localPattern}) + kind="local" + name="$(_ldx_sanitize "$ref")" + var="${envPrefix}_LOCAL_$name" + path="$ref" + return 0 + ;; + esac + + IFS='${refSeparator}' read -ra parts <<< "$ref" + if [[ ''${#parts[@]} -eq 1 ]]; then + flake_="${defaultFlake}" + attr="''${parts[0]}" + else + flake_="''${parts[0]}" + attr="''${parts[1]}" + fi + if [[ "$flake_" != "${defaultFlake}" ]]; then + echo "${name}: error: $ws: unsupported flake '$flake_' in ref '$ref'" >&2 + return 1 + fi + kind="nixpkgs" + name="$(_ldx_sanitize "$attr")" + var="${envPrefix}_$name" + subdir="''${parts[2]:-${defaultSubdir}}" + inst="$flake_#$attr" + } + + sync_workspace() { + local d="$1" + local ws state_dir fp stored st flake_dir lock link err ref + local kind var name path subdir inst attr value realp abs tmp existing + local -a deps_json=() paths=() names=() roots=() flags=() + ws="$(basename "$d")" + state_dir="$d/${stateDirName}" + st="$state_dir/${stateFileName}" + err="$state_dir/${errFileName}" + + if ! jq -e 'type == "array"' "$d/${manifest}" > /dev/null 2>&1; then + echo "${name}: error: $ws: ${manifest} must be a JSON array" >&2 + return 1 + fi + + mkdir -p "$state_dir/${libDirName}" "$state_dir/${gcrootsDirName}" || return 1 + + flake_dir="$(_ldx_flake_dir "$d" || true)" + lock="" + [[ -z "$flake_dir" ]] || lock="$flake_dir/${lockFile}" fp="$(_ldx_fingerprint "$d" "$lock")" stored="$(jq -r '.fingerprint // ""' "$st" 2>/dev/null || true)" - # fast path: nothing about resolution changed and references still - # exist, so avoid every nix operation + # fast path: nothing changed and references still exist if [[ "$fp" == "$stored" ]] && _ldx_lightcheck "$st"; then - echo "ldx: $proj: up to date" + echo "${name}: $ws: up to date" return 0 fi - echo "ldx: $proj: resolving dependencies..." - # one build per changed project; its closure protects every - # dependency from the garbage collector via the `deps` out-link - deps_out="$(nix build "''${repo_}#ldx.deps.''${proj}" --out-link "$ldx_dir/gcroots/deps" --print-out-paths 2>"$ldx_dir/sync.err")" || true - if [[ -z "$deps_out" || ! -f "$deps_out/deps.json" ]]; then - echo "ldx: error: $proj: dependency resolution failed:" >&2 - sed 's/^/ldx: /' "$ldx_dir/sync.err" >&2 2>/dev/null || true - rm -f "$ldx_dir/sync.err" - return 1 - fi - rm -f "$ldx_dir/sync.err" - json="$(cat "$deps_out/deps.json")" - - local line kind var name path subdir value realp abs tmp existing - local -a deps_json=() paths=() names=() - - while IFS= read -r line; do - [[ -n "$line" ]] || continue - kind="$(jq -r '.kind' <<< "$line")" - var="$(jq -r '.var' <<< "$line")" - name="$(jq -r '.name // ""' <<< "$line")" - path="$(jq -r '.path // ""' <<< "$line")" - subdir="$(jq -r '.subdir // ""' <<< "$line")" + echo "${name}: $ws: resolving dependencies..." + + while IFS= read -r ref; do + [[ -n "$ref" ]] || continue + resolve_ref "$ref" || return 1 value="" case "$kind" in - nix) - if [[ ! -d "$path" || -z "$subdir" || ! -d "$path/$subdir" ]]; then - echo "ldx: error: $proj: $var: missing library dir at $path/$subdir" >&2 + nixpkgs|flake) + link="$state_dir/${gcrootsDirName}/$name" + flags=() + if [[ "$kind" == "nixpkgs" && -n "$flake_dir" ]]; then + flags=(--inputs-from "$flake_dir") + fi + # the out-link protects the dependency from the garbage collector + if ! nix build "''${flags[@]}" "$inst" --out-link "$link" 2>"$err"; then + echo "${name}: error: $ws: $var: resolution of '$inst' failed:" >&2 + sed 's/^/${name}: /' "$err" >&2 2>/dev/null || true + rm -f "$err" return 1 fi - ln -sfn "$path/$subdir" "$ldx_dir/lib/$name" - value="$ldx_dir/lib/$name" + rm -f "$err" + path="$(realpath "$link")" + if [[ -z "$subdir" || ! -d "$path/$subdir" ]]; then + echo "${name}: error: $ws: $var: missing library dir at $path/$subdir" >&2 + return 1 + fi + ln -sfn "$path/$subdir" "$state_dir/${libDirName}/$name" + value="$state_dir/${libDirName}/$name" names+=("$name") + roots+=("$name") ;; local) - # `path` is the raw relative ref from the manifest (./x, ../x/y/z, ...). - # Resolve it against the REAL project dir ($d, a live checkout), - # never against the nix store. + # resolved against the real workspace dir, never the nix store case "$path" in /*) abs="$path" ;; *) abs="$d/$path" ;; esac realp="$(realpath -m "$abs" 2>/dev/null || true)" if [[ -z "$realp" || ! -d "$realp" ]]; then - echo "ldx: error: $proj: $var: local dependency not found at $abs" >&2 + echo "${name}: error: $ws: $var: local dependency not found at $abs" >&2 return 1 fi value="$realp" @@ -281,14 +312,14 @@ value="$path" ;; *) - echo "ldx: error: $proj: unknown kind '$kind' for $var" >&2 + echo "${name}: error: $ws: unknown kind '$kind' for $var" >&2 return 1 ;; esac paths+=("\''${env:''${var}}") deps_json+=("$(jq -nc --arg var "$var" --arg kind "$kind" --arg name "$name" --arg value "$value" --arg path "$path" --arg subdir "$subdir" '{var: $var, kind: $kind, name: $name, value: $value, path: $path, subdir: $subdir}')") - done < <(jq -c '.[]' <<< "$json") + done < <(jq -r '.[]' "$d/${manifest}") local deps_json_s paths_json if [[ ''${#deps_json[@]} -eq 0 ]]; then @@ -296,26 +327,26 @@ else deps_json_s="$(printf '%s\n' "''${deps_json[@]}" | jq -s .)" fi - echo "$deps_json_s" | jq --arg project "$proj" --arg fingerprint "$fp" '{project: $project, fingerprint: $fingerprint, deps: .}' > "$st" + echo "$deps_json_s" | jq --arg workspace "$ws" --arg fingerprint "$fp" '{workspace: $workspace, fingerprint: $fingerprint, deps: .}' > "$st" - # prune stale lib links that are no longer in the manifest - for f in "$ldx_dir"/lib/*; do + # prune lib links and gc roots that are no longer in the manifest + for f in "$state_dir"/${libDirName}/*; do [[ -e "$f" || -L "$f" ]] || continue b="$(basename "$f")" if ! _contains "$b" "''${names[@]}"; then rm -f "$f" fi done - # the only project-level root is `deps` now; drop legacy/per-dep gcroots - for f in "$ldx_dir"/gcroots/*; do + for f in "$state_dir"/${gcrootsDirName}/*; do [[ -e "$f" || -L "$f" ]] || continue b="$(basename "$f")" - [[ "$b" == "deps" ]] || rm -f "$f" + if ! _contains "$b" "''${roots[@]}"; then + rm -f "$f" + fi done - rm -f "$ldx_dir/cache.json" 2>/dev/null || true + rm -f "$state_dir/cache.json" 2>/dev/null || true - # surgical luarc update: ldx owns workspace.library; every other - # key (e.g. diagnostics.globals) is left untouched + # only the library key is rewritten; every other key is left untouched if [[ ''${#paths[@]} -eq 0 ]]; then paths_json="[]" else @@ -323,29 +354,28 @@ fi tmp="$(mktemp)" existing="{}" - [[ -s "$d/.luarc.json" ]] && existing="$(cat "$d/.luarc.json")" - if ! echo "$existing" | jq --argjson p "$paths_json" '.workspace.library = ($p | unique)' > "$tmp"; then + [[ -s "$d/${luarcName}" ]] && existing="$(cat "$d/${luarcName}")" + if ! echo "$existing" | jq --argjson p "$paths_json" '${luarcLibraryPath} = ($p | unique)' > "$tmp"; then rm -f "$tmp" - echo "ldx: error: $proj: failed to write .luarc.json" >&2 + echo "${name}: error: $ws: failed to write ${luarcName}" >&2 return 1 fi - mv "$tmp" "$d/.luarc.json" + mv "$tmp" "$d/${luarcName}" - echo "ldx: $proj: ok (''${#paths[@]} libraries)" + echo "${name}: $ws: ok (''${#paths[@]} libraries)" } - repo_="$(_ldx_repo)" - project_dirs_tmp="$(mktemp)" - if ! _ldx_projects "$repo_/apps" "$@" > "$project_dirs_tmp"; then - rm -f "$project_dirs_tmp" + workspaces_tmp="$(mktemp)" + if ! _ldx_workspaces "$@" > "$workspaces_tmp"; then + rm -f "$workspaces_tmp" exit 1 fi - mapfile -t project_dirs < "$project_dirs_tmp" - rm -f "$project_dirs_tmp" + mapfile -t workspace_dirs < "$workspaces_tmp" + rm -f "$workspaces_tmp" failed=0 - for d in "''${project_dirs[@]}"; do - if ! sync_project "$d" "$repo_/flake.lock"; then - echo "ldx: sync failed: $d" >&2 + for d in "''${workspace_dirs[@]}"; do + if ! sync_workspace "$d"; then + echo "${name}: sync failed: $d" >&2 failed=1 fi done @@ -354,43 +384,35 @@ } { name = "check"; - description = "Verify all resolved references still point at existing directories (default: all)"; - flags = [repoFlag]; - arguments = [ - { - name = "projects"; - description = "Project dirs/names (default: all)"; - variadic = true; - } - ]; + description = "Verify all resolved references still point at existing directories (default: current directory)"; + arguments = [workspacesArgument]; script = '' ${prelude} - repo_="$(_ldx_repo)" - project_dirs_tmp="$(mktemp)" - if ! _ldx_projects "$repo_/apps" "$@" > "$project_dirs_tmp"; then - rm -f "$project_dirs_tmp" + workspaces_tmp="$(mktemp)" + if ! _ldx_workspaces "$@" > "$workspaces_tmp"; then + rm -f "$workspaces_tmp" exit 1 fi - mapfile -t project_dirs < "$project_dirs_tmp" - rm -f "$project_dirs_tmp" + mapfile -t workspace_dirs < "$workspaces_tmp" + rm -f "$workspaces_tmp" failed=0 - for d in "''${project_dirs[@]}"; do - st="$d/.ldx/state.json" + for d in "''${workspace_dirs[@]}"; do + st="$d/${stateDirName}/${stateFileName}" if [[ ! -f "$st" ]]; then - echo "ldx: $d: not synced (run 'ldx sync')" >&2 + echo "${name}: $d: not synced (run '${name} sync')" >&2 failed=1 continue fi if _ldx_lightcheck "$st"; then - echo "ldx: $d: ok" + echo "${name}: $d: ok" else - echo "ldx: $d: broken references found:" >&2 + echo "${name}: $d: broken references found:" >&2 while IFS=$'\t' read -r kind value; do [[ "$kind" == "literal" ]] && continue real="$(realpath "$value" 2>/dev/null || true)" if [[ -z "$real" || ! -d "$real" ]]; then - echo "ldx: ''${value}" >&2 + echo "${name}: ''${value}" >&2 fi done < <(jq -r '.deps[] | [.kind, (.value // "")] | @tsv' "$st") failed=1 @@ -401,32 +423,24 @@ } { name = "env"; - description = "Print export LDX_* lines for the dev shell to source (default: all)"; - flags = [repoFlag]; - arguments = [ - { - name = "projects"; - description = "Project dirs/names (default: all)"; - variadic = true; - } - ]; + description = "Print export ${envPrefix}_* lines for the dev shell to source (default: current directory)"; + arguments = [workspacesArgument]; script = '' ${prelude} - repo_="$(_ldx_repo)" - project_dirs_tmp="$(mktemp)" - if ! _ldx_projects "$repo_/apps" "$@" > "$project_dirs_tmp"; then - rm -f "$project_dirs_tmp" + workspaces_tmp="$(mktemp)" + if ! _ldx_workspaces "$@" > "$workspaces_tmp"; then + rm -f "$workspaces_tmp" exit 1 fi - mapfile -t project_dirs < "$project_dirs_tmp" - rm -f "$project_dirs_tmp" - for d in "''${project_dirs[@]}"; do - st="$d/.ldx/state.json" + mapfile -t workspace_dirs < "$workspaces_tmp" + rm -f "$workspaces_tmp" + for d in "''${workspace_dirs[@]}"; do + st="$d/${stateDirName}/${stateFileName}" if [[ -f "$st" ]]; then jq -r '.deps[] | "export " + .var + "=\u0027" + .value + "\u0027"' "$st" else - echo "ldx: warning: $d: not synced (run 'ldx sync')" >&2 + echo "${name}: warning: $d: not synced (run '${name} sync')" >&2 fi done ''; @@ -435,10 +449,10 @@ name = "version"; description = "Print version information"; script = '' - echo "ldx ${version}" + echo "${name} ${version}" ''; } ]; }; in - cli // {inherit deps;} + cli diff --git a/flake.lock b/flake.lock index 1d8c9ac..d567f67 100644 --- a/flake.lock +++ b/flake.lock @@ -1,39 +1,5 @@ { "nodes": { - "flake-compat": { - "flake": false, - "locked": { - "lastModified": 1767039857, - "narHash": "sha256-vNpUSpF5Nuw8xvDLj2KCwwksIbjua2LZCqhV1LNRDns=", - "owner": "edolstra", - "repo": "flake-compat", - "rev": "5edf11c44bc78a0d334f6334cdaf7d60d732daab", - "type": "github" - }, - "original": { - "owner": "edolstra", - "repo": "flake-compat", - "type": "github" - } - }, - "flake-utils": { - "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1731533236, - "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, "nixpkgs": { "locked": { "lastModified": 1794458702, @@ -49,50 +15,12 @@ "type": "github" } }, - "pog": { - "inputs": { - "flake-compat": "flake-compat", - "flake-utils": "flake-utils", - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1785982312, - "narHash": "sha256-/ro6qfOd42mh6pHbMuw1wSP9wsbIh5dksUrqogBu3o4=", - "owner": "jpetrucciani", - "repo": "pog", - "rev": "d5327fff16292e065d4263df10f20cd1f2688836", - "type": "github" - }, - "original": { - "owner": "jpetrucciani", - "repo": "pog", - "type": "github" - } - }, "root": { "inputs": { "nixpkgs": "nixpkgs", - "pog": "pog", "yalms": "yalms" } }, - "systems": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - }, "yalms": { "inputs": { "nixpkgs": [ diff --git a/flake.nix b/flake.nix index 1eb3011..c28c7fe 100644 --- a/flake.nix +++ b/flake.nix @@ -4,11 +4,6 @@ inputs = { nixpkgs.url = "github:nixos/nixpkgs"; - pog = { - url = "github:jpetrucciani/pog"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - yalms = { url = "github:ar-at-localhost/yalms"; inputs.nixpkgs.follows = "nixpkgs"; @@ -30,7 +25,7 @@ inherit self system; pkgs = import inputs.nixpkgs { inherit system; - overlays = [inputs.pog.overlays.default inputs.yalms.overlays.default]; + overlays = [inputs.yalms.overlays.default]; }; } );