-
Notifications
You must be signed in to change notification settings - Fork 0
/
update
36 lines (26 loc) · 1.2 KB
/
update
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env python3
import argparse
import json
import os
import subprocess
def main(args):
path = os.getcwd()
if args.nixpkgs:
nixpkgs = args.nixpkgs
else:
nixpkgs = json.loads(subprocess.check_output(['nix', 'eval', '-f', path, 'inputs.nixpkgs.outPath', '--json']).decode('utf-8'))
update_nix = os.path.join(nixpkgs, 'maintainers/scripts/update.nix')
nix_args = [update_nix]
nix_args += ['--arg', 'include-overlays', f'(import {path} {{ }}).outputs.legacyPackages.x86_64-linux.overlays']
nix_args += ['--argstr', 'path', args.attr_path]
if args.commit:
nix_args += ['--argstr', 'commit', 'true']
nix_shell = ['nix-shell'] + nix_args
os.execvp(nix_shell[0], nix_shell)
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Rebuild system')
parser.add_argument('--commit', help='Commit the changes', action='store_true')
parser.add_argument('--nixpkgs', dest='nixpkgs', help='Override the nixpkgs flake input with this path, it will be used fir finding update.nix', nargs='?')
parser.add_argument('attr_path', metavar='attr-path', help='Attribute path of package to update')
args = parser.parse_args()
main(args)