mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
add NixOS support to mach and automatically re-launch mach in nix-shell
This commit is contained in:
parent
2cade89ede
commit
8e48b6fd74
2 changed files with 17 additions and 1 deletions
12
mach
12
mach
|
@ -106,4 +106,14 @@ if __name__ == '__main__':
|
||||||
orig_command_line = forking.get_command_line
|
orig_command_line = forking.get_command_line
|
||||||
forking.get_command_line = my_get_command_line
|
forking.get_command_line = my_get_command_line
|
||||||
|
|
||||||
main(sys.argv)
|
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__))
|
||||||
|
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',
|
'debian gnu/linux',
|
||||||
'fedora',
|
'fedora',
|
||||||
'void',
|
'void',
|
||||||
|
'nixos',
|
||||||
]:
|
]:
|
||||||
raise Exception('mach bootstrap does not support %s, please file a bug' % distrib)
|
raise Exception('mach bootstrap does not support %s, please file a bug' % distrib)
|
||||||
|
|
||||||
|
@ -398,6 +399,11 @@ def bootstrap(context, force=False, specific=None):
|
||||||
elif "linux-gnu" in host_triple():
|
elif "linux-gnu" in host_triple():
|
||||||
distrib, version = get_linux_distribution()
|
distrib, version = get_linux_distribution()
|
||||||
|
|
||||||
|
if distrib.lower() == 'nixos':
|
||||||
|
print('NixOS does not need bootstrap')
|
||||||
|
print('just run ./mach build')
|
||||||
|
return
|
||||||
|
|
||||||
context.distro = distrib
|
context.distro = distrib
|
||||||
context.distro_version = version
|
context.distro_version = version
|
||||||
bootstrapper = LINUX_SPECIFIC_BOOTSTRAPPERS.get(specific, linux)
|
bootstrapper = LINUX_SPECIFIC_BOOTSTRAPPERS.get(specific, linux)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue