+def update(args: argparse.Namespace) -> None:
+ v = Verification()
+ config = configparser.ConfigParser()
+ config.read_file(open(args.channels_file), args.channels_file)
+ exprs = []
+ for section in config.sections():
+ if 'channel_url' in config[section]:
+ tarball = fetch_with_nix_prefetch_url(
+ v, config[section]['tarball_url'], Digest16(
+ config[section]['tarball_sha256']))
+ else:
+ channel = Channel(**dict(config[section].items()))
+ ensure_git_rev_available(v, channel)
+ tarball = git_get_tarball(v, channel)
+ exprs.append(
+ 'f: f { name = "%s"; channelName = "%s"; src = builtins.storePath "%s"; }' %
+ (config[section]['release_name'], section, tarball))
+ command = [
+ 'nix-env',
+ '--profile',
+ '/nix/var/nix/profiles/per-user/%s/channels' %
+ getpass.getuser(),
+ '--show-trace',
+ '--file',
+ '<nix/unpack-channel.nix>',
+ '--install',
+ '--from-expression'] + exprs
+ if args.dry_run:
+ print(' '.join(map(shlex.quote, command)))
+ else:
+ v.status('Installing channels with nix-env')
+ process = subprocess.run(command)
+ v.result(process.returncode == 0)
+
+