Skip to content

Instantly share code, notes, and snippets.

@t184256
Created April 13, 2019 06:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save t184256/0ca8d6941b45ee7abdf932b03e51cacf to your computer and use it in GitHub Desktop.
Save t184256/0ca8d6941b45ee7abdf932b03e51cacf to your computer and use it in GitHub Desktop.
aliases['nxu'] = ['sudo', 'nix-channel', '--update']
NX_DEFAULT_ARGS = ['--cores', '4']
$NX_OFFLOAD_HOST = 'fig'
aliases['nxo'] = ['nixos-rebuild', 'build',
'--build-host', $NX_OFFLOAD_HOST] + NX_DEFAULT_ARGS
aliases['nxl'] = ['nix', 'build', '--no-link',
'-f', '<nixpkgs/nixos>', *NX_DEFAULT_ARGS,
'config.system.build.toplevel']
def _nxg(*_):
pushd -q /etc/nixos/t184256
try:
git status
clean = !(git diff --quiet)
git fetch
git --no-pager diff master...origin/master
try:
if not clean:
git stash
git pull --ff-only --rebase
git push
finally:
if not clean:
git stash pop
finally:
popd -q
aliases['nxg'] = _nxg
del _nxg
def _nxt_maker(*extra_args):
def _nxt(args):
TMP_DIR = $(mktemp -d).rstrip()
pushd -q @(TMP_DIR)
sudo nixos-rebuild test @(NX_DEFAULT_ARGS) @(extra_args)
rm -f result
popd -q
rm -d @(TMP_DIR)
return _nxt
aliases['nxt'] = _nxt_maker()
aliases['nxf'] = _nxt_maker('--fast')
aliases['nxs'] = ['sudo', 'nixos-rebuild', 'switch', *NX_DEFAULT_ARGS]
aliases['nxp'] = ['nix', 'build', '--no-link', *NX_DEFAULT_ARGS,
'-f', '<nixpkgs>']
del _nxt_maker
def _nx_combo_maker(letters):
def _combo(args):
for i, l in enumerate(letters):
args_if_last = args if i == len(letters) - 1 else ()
print('#', 'nx' + letters + ':', 'nx' + l, *args_if_last)
r = !(@('nx' + l) @(args_if_last))
if not r:
return r
return _combo
_combos = ['t', 'f', 's', '']
_combos += ['l' + c for c in _combos] + ['o' + c for c in _combos] + ['p']
_combos += ['u' + c for c in _combos]
_combos += ['g' + c for c in _combos]
for c in _combos:
if 'nx' + c not in aliases and c:
aliases['nx' + c] = _nx_combo_maker(c)
del _nx_combo_maker, _combos
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment