-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix misc errors, stop needing a Nix change
- Loading branch information
1 parent
757975d
commit 4a52b29
Showing
7 changed files
with
65 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import os | ||
import subprocess | ||
import sys | ||
import shutil | ||
import typing as t | ||
|
||
def main(): | ||
if len(sys.argv) < 4 or '--' not in sys.argv: | ||
print("Usage: remove-before-wrapper <output> -- <nix command...>") | ||
sys.exit(1) | ||
|
||
# Extract the parts | ||
output: str = sys.argv[1] | ||
nix_command_idx: int = sys.argv.index('--') + 1 | ||
nix_command: t.List[str] = sys.argv[nix_command_idx:] | ||
|
||
output_temp: str = output + '.tmp' | ||
|
||
# Remove the output and temp output in case they exist | ||
shutil.rmtree(output, ignore_errors=True) | ||
shutil.rmtree(output_temp, ignore_errors=True) | ||
|
||
# Execute nix command with `--write-to` tempary output | ||
nix_command_write_to = nix_command + ['--write-to', output_temp] | ||
subprocess.run(nix_command_write_to, check=True) | ||
|
||
# Move the temporary output to the intended location | ||
os.rename(output_temp, output) | ||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters