|
49 | 49 | custom =
|
50 | 50 | {
|
51 | 51 | __functor = customSelf: base: activate:
|
52 |
| - final.buildEnv { |
53 |
| - name = ("activatable-" + base.name); |
54 |
| - paths = |
55 |
| - [ |
56 |
| - base |
57 |
| - (final.writeTextFile { |
58 |
| - name = base.name + "-activate-path"; |
59 |
| - text = '' |
60 |
| - #!${final.runtimeShell} |
61 |
| - set -euo pipefail |
62 |
| -
|
63 |
| - if [[ "''${DRY_ACTIVATE:-}" == "1" ]] |
64 |
| - then |
65 |
| - ${customSelf.dryActivate or "echo ${final.writeScript "activate" activate}"} |
66 |
| - elif [[ "''${BOOT:-}" == "1" ]] |
67 |
| - then |
68 |
| - ${customSelf.boot or "echo ${final.writeScript "activate" activate}"} |
69 |
| - else |
70 |
| - ${activate} |
71 |
| - fi |
72 |
| - ''; |
73 |
| - executable = true; |
74 |
| - destination = "/deploy-rs-activate"; |
75 |
| - }) |
76 |
| - (final.writeTextFile { |
| 52 | + base.overrideAttrs (oldAttrs: { |
| 53 | + name = "activatable-${base.name}"; |
| 54 | + buildCommand = '' |
| 55 | + set -euo pipefail |
| 56 | + ${nixpkgs.lib.concatStringsSep "\n" (map (outputName: |
| 57 | + let |
| 58 | + activatePath = final.writeTextFile { |
| 59 | + name = base.name + "-activate-path"; |
| 60 | + text = '' |
| 61 | + #!${final.runtimeShell} |
| 62 | + set -euo pipefail |
| 63 | +
|
| 64 | + if [[ "''${DRY_ACTIVATE:-}" == "1" ]] |
| 65 | + then |
| 66 | + ${customSelf.dryActivate or "echo ${final.writeScript "activate" activate}"} |
| 67 | + elif [[ "''${BOOT:-}" == "1" ]] |
| 68 | + then |
| 69 | + ${customSelf.boot or "echo ${final.writeScript "activate" activate}"} |
| 70 | + else |
| 71 | + ${activate} |
| 72 | + fi |
| 73 | + ''; |
| 74 | + executable = true; |
| 75 | + }; |
| 76 | +
|
| 77 | + activateRs = final.writeTextFile { |
77 | 78 | name = base.name + "-activate-rs";
|
78 | 79 | text = ''
|
79 |
| - #!${final.runtimeShell} |
80 |
| - exec ${self.packages.${system}.default}/bin/activate "$@" |
81 |
| - ''; |
82 |
| - executable = true; |
83 |
| - destination = "/activate-rs"; |
84 |
| - }) |
85 |
| - ]; |
86 |
| - }; |
| 80 | + #!${final.runtimeShell} |
| 81 | + exec ${self.packages.${system}.default}/bin/activate "$@" |
| 82 | + ''; |
| 83 | + executable = true; |
| 84 | + }; |
| 85 | + in ('' |
| 86 | + ${final.coreutils}/bin/mkdir "''$${outputName}" |
| 87 | +
|
| 88 | + echo "Linking activation components in ${outputName}" |
| 89 | + ${final.coreutils}/bin/ln -s "${activatePath}" "''$${outputName}/deploy-rs-activate" |
| 90 | + ${final.coreutils}/bin/ln -s "${activateRs}" "''$${outputName}/activate-rs" |
| 91 | +
|
| 92 | + echo "Linking output contents of ${outputName}" |
| 93 | + ${final.findutils}/bin/find "${base.${outputName}}" -maxdepth 1 | while read -r file; do |
| 94 | + ${final.coreutils}/bin/ln -s "$file" "''$${outputName}/$(${final.coreutils}/bin/basename "$file")" |
| 95 | + done |
| 96 | + '' + nixpkgs.lib.optionalString |
| 97 | + (outputName == "out") '' |
| 98 | + # Workaround for https://github.com/serokell/deploy-rs/issues/185 |
| 99 | + if [ -x "${base.${outputName}}/prepare-root" ]; then |
| 100 | + echo "Copying prepare-root" |
| 101 | + rm "$out/prepare-root" || : |
| 102 | + cp "${base.${outputName}}/prepare-root" "$out/prepare-root" |
| 103 | + fi |
| 104 | + '')) (base.outputs or [ "out" ]))} |
| 105 | + ''; |
| 106 | + }); |
87 | 107 | };
|
88 | 108 |
|
89 | 109 | nixos = base:
|
|
0 commit comments