|
48 | 48 | activate = rec {
|
49 | 49 | custom =
|
50 | 50 | {
|
51 |
| - __functor = customSelf: base: activate: |
52 |
| - final.buildEnv { |
53 |
| - name = ("activatable-" + base.name); |
54 |
| - paths = |
55 |
| - [ |
56 |
| - base |
57 |
| - (final.writeTextFile { |
| 51 | + __functor = customSelf: base: activate: |
| 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 { |
58 | 59 | name = base.name + "-activate-path";
|
59 | 60 | text = ''
|
60 | 61 | #!${final.runtimeShell}
|
|
71 | 72 | fi
|
72 | 73 | '';
|
73 | 74 | executable = true;
|
74 |
| - destination = "/deploy-rs-activate"; |
75 |
| - }) |
76 |
| - (final.writeTextFile { |
77 |
| - name = base.name + "-activate-rs"; |
78 |
| - text = '' |
| 75 | + }; |
| 76 | +
|
| 77 | + activateRs = final.writeTextFile { |
| 78 | + name = base.name + "-activate-rs"; |
| 79 | + text = '' |
79 | 80 | #!${final.runtimeShell}
|
80 | 81 | exec ${self.packages.${system}.default}/bin/activate "$@"
|
81 | 82 | '';
|
82 | 83 | executable = true;
|
83 |
| - destination = "/activate-rs"; |
84 |
| - }) |
85 |
| - ]; |
86 |
| - }; |
87 |
| - }; |
| 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 | + }); |
| 107 | + }; |
88 | 108 |
|
89 | 109 | nixos = base:
|
90 | 110 | (custom // {
|
|
0 commit comments