|
22 | 22 | }; |
23 | 23 | }; |
24 | 24 |
|
25 | | - handleGit = path: { url, rev, sha256, common_dir }: { |
| 25 | + handleGit = path: { url, rev, sha256, common_dir, ... }: { |
26 | 26 | name = path; |
27 | 27 | path = pkgs.fetchgit { |
28 | 28 | inherit url rev sha256; |
|
32 | 32 | # Corresponds to the ~/.m2/repository directory |
33 | 33 | mavenRepoCache = pkgs.linkFarm "maven-repo-cache" (lib.mapAttrsToList fetchMaven contents.maven); |
34 | 34 |
|
| 35 | + unpreppedGitWorkTrees = lib.mapAttrsToList handleGit contents.git; |
| 36 | + |
35 | 37 | # This corresponds to the ~/.gitlibs/libs directory, containing git worktrees |
36 | | - gitWorktreeCache = pkgs.linkFarm "git-worktree-cache" (lib.mapAttrsToList handleGit contents.git); |
| 38 | + gitWorktreeCache = gitWorkTrees: pkgs.linkFarm "git-worktree-cache" gitWorkTrees; |
37 | 39 |
|
38 | 40 | # This corresponds to the ~/.gitlibs/_repos directory, containing git directories for the above worktrees |
39 | 41 | gitFakeRepoCache = pkgs.runCommandNoCC "git-fake-repo-cache" {} |
|
56 | 58 | echo '{}' > $out/tools/tools.edn |
57 | 59 | ''; |
58 | 60 |
|
59 | | - # Creates the final home directory, combining all parts together |
60 | | - result = pkgs.linkFarm "clojure-home" [ |
61 | | - { |
62 | | - name = ".m2/repository"; |
63 | | - path = mavenRepoCache; |
64 | | - } |
65 | | - { |
66 | | - name = ".gitlibs/libs"; |
67 | | - path = gitWorktreeCache; |
68 | | - } |
69 | | - { |
70 | | - name = ".gitlibs/_repos"; |
71 | | - path = gitFakeRepoCache; |
72 | | - } |
| 61 | + # Creates a home directory for Clojure, combining all parts together |
| 62 | + clojureHome = gitWorkTrees: |
| 63 | + pkgs.linkFarm "clojure-home" [ |
| 64 | + { |
| 65 | + name = ".m2/repository"; |
| 66 | + path = mavenRepoCache; |
| 67 | + } |
| 68 | + { |
| 69 | + name = ".gitlibs/libs"; |
| 70 | + path = gitWorktreeCache gitWorkTrees; |
| 71 | + } |
| 72 | + { |
| 73 | + name = ".gitlibs/_repos"; |
| 74 | + path = gitFakeRepoCache; |
| 75 | + } |
| 76 | + { |
| 77 | + name = ".clojure"; |
| 78 | + path = configDir; |
| 79 | + } |
| 80 | + ]; |
| 81 | + |
| 82 | + unpreppedHome = clojureHome unpreppedGitWorkTrees; |
| 83 | + |
| 84 | + utils = import ./utils.nix { inherit pkgs; }; |
| 85 | + |
| 86 | + prepLib = { path, name }: spec: |
| 87 | + if spec ? prep then |
| 88 | + let prep = spec.prep; in |
| 89 | + pkgs.runCommand "${name}-prepped" |
| 90 | + { nativeBuildInputs = [ (utils.wrapClojure unpreppedHome pkgs.clojure) ]; } |
| 91 | + '' |
| 92 | + cp -r ${path} $out |
| 93 | + chmod -R +w $out |
| 94 | + cd $out |
| 95 | + clojure -X:${prep.alias} ${prep.fn} |
| 96 | + '' |
| 97 | + else |
| 98 | + path; |
| 99 | + |
| 100 | + prepGitWorkTree = { name, ... }@wt: |
73 | 101 | { |
74 | | - name = ".clojure"; |
75 | | - path = configDir; |
76 | | - } |
77 | | - ]; |
| 102 | + inherit name; |
| 103 | + path = prepLib wt (lib.getAttr name contents.git); |
| 104 | + }; |
| 105 | + |
| 106 | + preppedGitWorkTrees = builtins.map prepGitWorkTree unpreppedGitWorkTrees; |
| 107 | + |
| 108 | + preppedHome = clojureHome preppedGitWorkTrees; |
78 | 109 |
|
79 | | -in result |
| 110 | +in preppedHome |
0 commit comments