This allows 'pinch update' to create a new profile. Updating an
existing profile still doesn't work because nix-env can't read the
existing manifest.
Also, the search path names aren't the best. Multiple links
probably don't work in restricted mode. (This tool is deprecated
& is receiving minimal maintenance; patches welcome.)
- Deprecate pinch.
- Show the channel URL being fetched.
- Use nix 2.3 because 2.4 broke <nix/unpack-channel.nix>.
- Deprecate pinch.
- Show the channel URL being fetched.
- Use nix 2.3 because 2.4 broke <nix/unpack-channel.nix>.
+- Support restricted mode: Allow tarball access with search paths.
def updateCommand(args: argparse.Namespace) -> None:
v = Verification()
exprs: Dict[str, str] = {}
def updateCommand(args: argparse.Namespace) -> None:
v = Verification()
exprs: Dict[str, str] = {}
+ search_paths: List[str] = []
config = {
section: read_pinned_config_section(section, conf) for section,
conf in read_config_files(
config = {
section: read_pinned_config_section(section, conf) for section,
conf in read_config_files(
alias, nonalias = partition_dict(
lambda k, v: isinstance(v[0], AliasSearchPath), config)
alias, nonalias = partition_dict(
lambda k, v: isinstance(v[0], AliasSearchPath), config)
- for section, (sp, pin) in nonalias.items():
+ for section, (sp, pin) in sorted(nonalias.items()):
assert not isinstance(sp, AliasSearchPath) # mypy can't see through
assert not isinstance(pin, AliasPin) # partition_dict()
tarball = sp.fetch(v, pin)
assert not isinstance(sp, AliasSearchPath) # mypy can't see through
assert not isinstance(pin, AliasPin) # partition_dict()
tarball = sp.fetch(v, pin)
+ search_paths.extend(["-I", "pinch_tarball_for_%s=%s" %
+ (pin.release_name, tarball)])
exprs[section] = (
'f: f { name = "%s"; channelName = "%%s"; src = builtins.storePath "%s"; }' %
(pin.release_name, tarball))
exprs[section] = (
'f: f { name = "%s"; channelName = "%%s"; src = builtins.storePath "%s"; }' %
(pin.release_name, tarball))
'--file',
'<nix/unpack-channel.nix>',
'--install',
'--file',
'<nix/unpack-channel.nix>',
'--install',
- '--from-expression'] + [exprs[name] % name for name in sorted(exprs.keys())]
+ ] + search_paths + ['--from-expression'] + [
+ exprs[name] % name for name in sorted(exprs.keys())]
if args.dry_run:
print(' '.join(map(shlex.quote, command)))
else:
if args.dry_run:
print(' '.join(map(shlex.quote, command)))
else:
actual_env_command=`python3 ./pinch.py update --dry-run "$conf"`
actual_env_command=`python3 ./pinch.py update --dry-run "$conf"`
-expected_env_command_RE='^nix-env --profile /nix/var/nix/profiles/per-user/[^/]+/channels --show-trace --file '\''<nix/unpack-channel.nix>'\'' --install --from-expression '\''f: f \{ name = "(repo-[0-9]{10}-[0-9a-f]{11})"; channelName = "bar"; src = builtins.storePath "'"$NIX_STORE_DIR"'/.{32}-\1.tar.xz"; \}'\'' '\''f: f \{ name = "\1"; channelName = "foo"; src = builtins.storePath "'"$NIX_STORE_DIR"'/.{32}-\1.tar.xz"; \}'\''$'
+expected_env_command_RE='^nix-env --profile /nix/var/nix/profiles/per-user/[^/]+/channels --show-trace --file '\''<nix/unpack-channel.nix>'\'' --install -I pinch_tarball_for_(repo-[0-9]{10}-[0-9a-f]{11})=('"$NIX_STORE_DIR"'/.{32}-\1.tar.xz) --from-expression '\''f: f \{ name = "\1"; channelName = "bar"; src = builtins.storePath "\2"; \}'\'' '\''f: f \{ name = "\1"; channelName = "foo"; src = builtins.storePath "\2"; \}'\''$'
if echo "$actual_env_command" | egrep "$expected_env_command_RE" > /dev/null;then
echo PASS
if echo "$actual_env_command" | egrep "$expected_env_command_RE" > /dev/null;then
echo PASS
actual_env_command=`python3 ./pinch.py update --dry-run "$conf"`
actual_env_command=`python3 ./pinch.py update --dry-run "$conf"`
-expected_env_command_RE='^nix-env --profile /nix/var/nix/profiles/per-user/[^/]+/channels --show-trace --file '\''<nix/unpack-channel.nix>'\'' --install --from-expression '\''f: f \{ name = "(repo-[0-9]{10}-[0-9a-f]{11})"; channelName = "foo"; src = builtins.storePath "'"$NIX_STORE_DIR"'/.{32}-\1.tar.xz"; \}'\''$'
+expected_env_command_RE='^nix-env --profile /nix/var/nix/profiles/per-user/[^/]+/channels --show-trace --file '\''<nix/unpack-channel.nix>'\'' --install -I pinch_tarball_for_(repo-[0-9]{10}-[0-9a-f]{11})=('"$NIX_STORE_DIR"'/.{32}-\1.tar.xz) --from-expression '\''f: f \{ name = "\1"; channelName = "foo"; src = builtins.storePath "\2"; \}'\''$'
if echo "$actual_env_command" | egrep "$expected_env_command_RE" > /dev/null;then
echo PASS
if echo "$actual_env_command" | egrep "$expected_env_command_RE" > /dev/null;then
echo PASS
-expected_env_command_RE='^nix-env --profile /nix/var/nix/profiles/per-user/[^/]+/channels --show-trace --file '\''<nix/unpack-channel.nix>'\'' --install --from-expression '\''f: f \{ name = "(repo-[0-9]{10}-[0-9a-f]{11})"; channelName = "bar"; src = builtins.storePath "'"$NIX_STORE_DIR"'/.{32}-\1.tar.xz"; \}'\'' '\''f: f \{ name = "\1"; channelName = "foo"; src = builtins.storePath "'"$NIX_STORE_DIR"'/.{32}-\1.tar.xz"; \}'\''$'
+expected_env_command_RE='^nix-env --profile /nix/var/nix/profiles/per-user/[^/]+/channels --show-trace --file '\''<nix/unpack-channel.nix>'\'' --install -I pinch_tarball_for_(repo-[0-9]{10}-[0-9a-f]{11})=('"$NIX_STORE_DIR"'/.{32}-\1.tar.xz) --from-expression '\''f: f \{ name = "\1"; channelName = "bar"; src = builtins.storePath "\2"; \}'\'' '\''f: f \{ name = "\1"; channelName = "foo"; src = builtins.storePath "\2"; \}'\''$'
if echo "$actual_env_command" | egrep "$expected_env_command_RE" > /dev/null;then
echo PASS
if echo "$actual_env_command" | egrep "$expected_env_command_RE" > /dev/null;then
echo PASS
actual_env_command=`python3 ./pinch.py update --dry-run "$conf"`
actual_env_command=`python3 ./pinch.py update --dry-run "$conf"`
-expected_env_command_RE='^nix-env --profile /nix/var/nix/profiles/per-user/[^/]+/channels --show-trace --file '\''<nix/unpack-channel.nix>'\'' --install --from-expression '\''f: f \{ name = "(repo-[0-9]{10}-[0-9a-f]{11})"; channelName = "foo"; src = builtins.storePath "'"$NIX_STORE_DIR"'/.{32}-\1.tar.xz"; \}'\''$'
+expected_env_command_RE='^nix-env --profile /nix/var/nix/profiles/per-user/[^/]+/channels --show-trace --file '\''<nix/unpack-channel.nix>'\'' --install -I pinch_tarball_for_(repo-[0-9]{10}-[0-9a-f]{11})=('"$NIX_STORE_DIR"'/.{32}-\1.tar.xz) --from-expression '\''f: f \{ name = "\1"; channelName = "foo"; src = builtins.storePath "\2"; \}'\''$'
if echo "$actual_env_command" | egrep "$expected_env_command_RE" > /dev/null;then
echo PASS
if echo "$actual_env_command" | egrep "$expected_env_command_RE" > /dev/null;then
echo PASS
actual_env_command=`python3 ./pinch.py update --dry-run --profile /path/to/profile "$conf"`
actual_env_command=`python3 ./pinch.py update --dry-run --profile /path/to/profile "$conf"`
-expected_env_command_RE='^nix-env --profile /path/to/profile --show-trace --file '\''<nix/unpack-channel.nix>'\'' --install --from-expression '\''f: f \{ name = "(repo-[0-9]{10}-[0-9a-f]{11})"; channelName = "foo"; src = builtins.storePath "'"$NIX_STORE_DIR"'/.{32}-\1.tar.xz"; \}'\''$'
+expected_env_command_RE='^nix-env --profile /path/to/profile --show-trace --file '\''<nix/unpack-channel.nix>'\'' --install -I pinch_tarball_for_(repo-[0-9]{10}-[0-9a-f]{11})=('"$NIX_STORE_DIR"'/.{32}-\1.tar.xz) --from-expression '\''f: f \{ name = "\1"; channelName = "foo"; src = builtins.storePath "\2"; \}'\''$'
if echo "$actual_env_command" | egrep "$expected_env_command_RE" > /dev/null;then
echo PASS
if echo "$actual_env_command" | egrep "$expected_env_command_RE" > /dev/null;then
echo PASS
actual_env_command=`python3 ./pinch.py update --dry-run "$conf"`
actual_env_command=`python3 ./pinch.py update --dry-run "$conf"`
-expected_env_command_RE='^nix-env --profile /nix/var/nix/profiles/per-user/[^/]+/channels --show-trace --file '\''<nix/unpack-channel.nix>'\'' --install --from-expression '\''f: f \{ name = "link"; channelName = "bar"; src = builtins.storePath "'"$NIX_STORE_DIR"'/.{32}-link.tar.gz"; \}'\'' '\''f: f \{ name = "(repo-[0-9]{10}-[0-9a-f]{11})"; channelName = "foo"; src = builtins.storePath "'"$NIX_STORE_DIR"'/.{32}-\1.tar.xz"; \}'\''$'
+expected_env_command_RE='^nix-env --profile /nix/var/nix/profiles/per-user/[^/]+/channels --show-trace --file '\''<nix/unpack-channel.nix>'\'' --install -I pinch_tarball_for_link=('"$NIX_STORE_DIR"'/.{32}-link.tar.gz) -I pinch_tarball_for_(repo-[0-9]{10}-[0-9a-f]{11})=('"$NIX_STORE_DIR"'/.{32}-\2.tar.xz) --from-expression '\''f: f \{ name = "link"; channelName = "bar"; src = builtins.storePath "\1"; \}'\'' '\''f: f \{ name = "\2"; channelName = "foo"; src = builtins.storePath "\3"; \}'\''$'
if echo "$actual_env_command" | egrep "$expected_env_command_RE" > /dev/null;then
echo PASS
if echo "$actual_env_command" | egrep "$expected_env_command_RE" > /dev/null;then
echo PASS