diff options
author | Vincent Ambo <Vincent Ambo> | 2020-01-09T00·46+0000 |
---|---|---|
committer | Vincent Ambo <Vincent Ambo> | 2020-01-09T00·46+0000 |
commit | 2a170f1ed744b2e80973fe58c8a68885fd1510bb (patch) | |
tree | c03b595592d35ab1525deedc0a6785a21922f985 /nix | |
parent | 06362a812ecec867b88c59e8565da1b43a39adb0 (diff) |
fix(buildLisp): Perform a topological sort of dependencies r/355
This ensures that dependencies are loaded in the correct order in larger dependency graphs.
Diffstat (limited to 'nix')
-rw-r--r-- | nix/buildLisp/default.nix | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/nix/buildLisp/default.nix b/nix/buildLisp/default.nix index e8d235df7c32..15dddfbbab93 100644 --- a/nix/buildLisp/default.nix +++ b/nix/buildLisp/default.nix @@ -61,15 +61,14 @@ let )) ''; + # 'dependsOn' determines whether Lisp library 'b' depends on 'a'. + dependsOn = a: b: builtins.elem a b.lispDeps; + # 'allDeps' flattens the list of dependencies (and their - # dependencies) into one list of unique deps. - # - # TODO(tazjin): Ordering needs to be stable (first occurences from - # innermost to outer), I don't know if this works accidentally or is - # guaranteed by these lib functions. - allDeps = deps: lib.reverseList ( - lib.unique (lib.flatten (deps ++ (map (d: d.lispDeps) deps))) - ); + # dependencies) into one ordered list of unique deps. + allDeps = deps: (lib.toposort dependsOn (lib.unique ( + lib.flatten (deps ++ (map (d: d.lispDeps) deps)) + ))).result; # 'genDumpLisp' generates a Lisp file that instructs SBCL to dump # the currently loaded image as an executable to $out/bin/$name. |