mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Auto merge of #28463 - mkg20001:nixos-mach, r=jdm
add NixOS support to mach and automatically re-launch mach in nix-shell <!-- Please describe your changes on the following line: --> This is a followup for #28454 which adds nixos support directly to mach, saving the user from typing `nix-shell` everytime --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [ ] `./mach build -d` does not report any errors - [ ] `./mach test-tidy` does not report any errors - [ ] These changes fix #___ (GitHub issue number if applicable) <!-- Either: --> - [ ] There are tests for these changes OR - [x] These changes do not require tests because they just extend mach <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
This commit is contained in:
commit
d12aa889a6
2 changed files with 22 additions and 1 deletions
11
mach
11
mach
|
@ -106,4 +106,15 @@ if __name__ == '__main__':
|
|||
orig_command_line = forking.get_command_line
|
||||
forking.get_command_line = my_get_command_line
|
||||
|
||||
if os.path.exists('/etc/NIXOS') and not 'IN_NIX_SHELL' in os.environ: # we're on a nixOS system, need to run mach in nix-shell
|
||||
import subprocess
|
||||
from shlex import quote
|
||||
mach_dir = os.path.abspath(os.path.dirname(__file__))
|
||||
print('NOTE: Entering nix-shell etc/shell.nix')
|
||||
try:
|
||||
# sys argv already contains the ./mach part, so we just need to pass it as-is
|
||||
subprocess.Popen(['nix-shell', mach_dir + '/etc/shell.nix', '--run', ' '.join(map(quote, sys.argv))]).wait()
|
||||
except KeyboardInterrupt:
|
||||
sys.exit(0)
|
||||
else:
|
||||
main(sys.argv)
|
||||
|
|
|
@ -383,6 +383,7 @@ def get_linux_distribution():
|
|||
'debian gnu/linux',
|
||||
'fedora',
|
||||
'void',
|
||||
'nixos',
|
||||
]:
|
||||
raise Exception('mach bootstrap does not support %s, please file a bug' % distrib)
|
||||
|
||||
|
@ -398,6 +399,15 @@ def bootstrap(context, force=False, specific=None):
|
|||
elif "linux-gnu" in host_triple():
|
||||
distrib, version = get_linux_distribution()
|
||||
|
||||
if distrib.lower() == 'nixos':
|
||||
print('NixOS does not need bootstrap, it will automatically enter a nix-shell')
|
||||
print('Just run ./mach build')
|
||||
print('')
|
||||
print('You will need to run a nix-shell if you are trying to run any of the built binaries')
|
||||
print('To enter the nix-shell manually use:')
|
||||
print(' $ nix-shell etc/shell.nix')
|
||||
return
|
||||
|
||||
context.distro = distrib
|
||||
context.distro_version = version
|
||||
bootstrapper = LINUX_SPECIFIC_BOOTSTRAPPERS.get(specific, linux)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue