From 53a27350551844e1ed1a9257690294767389ef0d Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Wed, 1 Jul 2020 00:05:38 -0700 Subject: [PATCH 001/100] 2.1.1: Pin faster --- Changelog | 4 ++++ default.nix | 2 +- pinch.py | 2 ++ setup.py | 2 +- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index 11afedc..2a12d5a 100644 --- a/Changelog +++ b/Changelog @@ -1,5 +1,9 @@ ## [Unreleased] +## [2.1.1] - 2020-07-01 +### Changed +- Pin faster: Skip archive comparison if git rev is unchanged + ## [2.1.0] - 2020-06-30 ### Added diff --git a/default.nix b/default.nix index dcd9c66..6ad80df 100644 --- a/default.nix +++ b/default.nix @@ -3,7 +3,7 @@ pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix, git, autopep8, mypy, pylint, }: buildPythonPackage rec { pname = "pinch"; - version = "2.1.0"; + version = "2.1.1"; src = lib.cleanSource ./.; checkInputs = [ nix git mypy ] ++ lib.optionals lint [ autopep8 pylint ]; doCheck = true; diff --git a/pinch.py b/pinch.py index a7f3449..ed33c92 100644 --- a/pinch.py +++ b/pinch.py @@ -186,6 +186,8 @@ class ChannelSearchPath(NamedTuple): channel_html, forwarded_url = fetch_channel(v, self) table, new_gitpin = parse_channel(v, channel_html) + if old_pin is not None and old_pin.git_revision == new_gitpin.git_revision: + return old_pin fetch_resources(v, new_gitpin, forwarded_url, table) ensure_git_rev_available(v, self, new_gitpin, old_revision) check_channel_contents(v, self, table, new_gitpin) diff --git a/setup.py b/setup.py index a460921..40618e9 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup setup( name="pinch", - version="2.1.0", + version="2.1.1", py_modules=['pinch'], entry_points={"console_scripts": ["pinch = pinch:main"]}, ) -- 2.50.1 From 25e38f08151f05d53bb978f5185e32cdc94650af Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Tue, 30 Jun 2020 13:35:54 -0700 Subject: [PATCH 002/100] Start on 3.0.0 --- default.nix | 2 +- setup.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/default.nix b/default.nix index 6ad80df..1a05419 100644 --- a/default.nix +++ b/default.nix @@ -3,7 +3,7 @@ pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix, git, autopep8, mypy, pylint, }: buildPythonPackage rec { pname = "pinch"; - version = "2.1.1"; + version = "3.0.0-pre"; src = lib.cleanSource ./.; checkInputs = [ nix git mypy ] ++ lib.optionals lint [ autopep8 pylint ]; doCheck = true; diff --git a/setup.py b/setup.py index 40618e9..2c5dfc8 100644 --- a/setup.py +++ b/setup.py @@ -1,8 +1,8 @@ from setuptools import setup setup( - name="pinch", - version="2.1.1", + name='pinch', + version='3.0.0-pre', py_modules=['pinch'], - entry_points={"console_scripts": ["pinch = pinch:main"]}, + entry_points={'console_scripts': ['pinch = pinch:main']}, ) -- 2.50.1 From d06918bc9c80208be1f75162021bfe308b9a0161 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Fri, 10 Jul 2020 13:22:22 -0700 Subject: [PATCH 003/100] Move git_cache out to a separate library --- Changelog | 2 + default.nix | 27 ++++++++++-- pinch.py | 124 +++++++++------------------------------------------- setup.py | 1 + 4 files changed, 47 insertions(+), 107 deletions(-) diff --git a/Changelog b/Changelog index 2a12d5a..32f74a5 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,6 @@ ## [Unreleased] +### Changed +- Moved git cache out to a separate library ## [2.1.1] - 2020-07-01 ### Changed diff --git a/default.nix b/default.nix index 1a05419..b3fc3a5 100644 --- a/default.nix +++ b/default.nix @@ -1,11 +1,32 @@ { pkgs ? import { }, lint ? false }: -pkgs.python3Packages.callPackage -({ lib, buildPythonPackage, nix, git, autopep8, mypy, pylint, }: + +let + git-cache-fallback = { buildPythonPackage, fetchgit, git, mypy, }: + buildPythonPackage rec { + pname = "git-cache"; + version = "1.0.0"; + src = fetchgit { + url = "https://scottworley.com/git-cache.git"; + rev = "v${version}"; + sha256 = "06mzjc424988n2s1h25x2bi3mxbk2pnba31zkjljgw4cgw2p9036"; + }; + checkInputs = [ git mypy ]; + doCheck = true; + checkPhase = "./test.sh"; + }; + +in pkgs.python3Packages.callPackage +({ lib, buildPythonPackage, nix, git, autopep8, mypy, pylint, git-cache, }: buildPythonPackage rec { pname = "pinch"; version = "3.0.0-pre"; src = lib.cleanSource ./.; + propagatedBuildInputs = [ git-cache ]; checkInputs = [ nix git mypy ] ++ lib.optionals lint [ autopep8 pylint ]; doCheck = true; checkPhase = "./test.sh"; - }) { } + }) { + git-cache = + pkgs.python3Packages.git-cache or (pkgs.python3Packages.callPackage + git-cache-fallback { }); + } diff --git a/pinch.py b/pinch.py index ed33c92..5eb7601 100644 --- a/pinch.py +++ b/pinch.py @@ -34,6 +34,8 @@ from typing import ( Union, ) +import git_cache + # Use xdg module when it's less painful to have as a dependency @@ -160,17 +162,17 @@ class GitSearchPath(NamedTuple): git_repo: str def pin(self, v: Verification, old_pin: Optional[Pin]) -> GitPin: + _, new_revision = git_cache.fetch(self.git_repo, self.git_ref) if old_pin is not None: assert isinstance(old_pin, GitPin) - old_revision = old_pin.git_revision if old_pin is not None else None - - new_revision = git_fetch(v, self, None, old_revision) + verify_git_ancestry(v, self, old_pin.git_revision, new_revision) return GitPin(release_name=git_revision_name(v, self, new_revision), git_revision=new_revision) def fetch(self, v: Verification, pin: Pin) -> str: assert isinstance(pin, GitPin) - ensure_git_rev_available(v, self, pin, None) + git_cache.ensure_rev_available( + self.git_repo, self.git_ref, pin.git_revision) return git_get_tarball(v, self, pin) @@ -182,14 +184,17 @@ class ChannelSearchPath(NamedTuple): def pin(self, v: Verification, old_pin: Optional[Pin]) -> ChannelPin: if old_pin is not None: assert isinstance(old_pin, ChannelPin) - old_revision = old_pin.git_revision if old_pin is not None else None channel_html, forwarded_url = fetch_channel(v, self) table, new_gitpin = parse_channel(v, channel_html) if old_pin is not None and old_pin.git_revision == new_gitpin.git_revision: return old_pin fetch_resources(v, new_gitpin, forwarded_url, table) - ensure_git_rev_available(v, self, new_gitpin, old_revision) + git_cache.ensure_rev_available( + self.git_repo, self.git_ref, new_gitpin.git_revision) + if old_pin is not None: + verify_git_ancestry( + v, self, old_pin.git_revision, new_gitpin.git_revision) check_channel_contents(v, self, table, new_gitpin) return ChannelPin( release_name=new_gitpin.release_name, @@ -345,13 +350,6 @@ def fetch_resources( v.result(open(table['git-revision'].file).read(999) == pin.git_revision) -def git_cachedir(git_repo: str) -> str: - return os.path.join( - xdg.XDG_CACHE_HOME, - 'pinch/git', - digest_string(git_repo.encode())) - - def tarball_cache_file(channel: TarrableSearchPath, pin: GitPin) -> str: return os.path.join( xdg.XDG_CACHE_HOME, @@ -365,101 +363,19 @@ def tarball_cache_file(channel: TarrableSearchPath, pin: GitPin) -> str: def verify_git_ancestry( v: Verification, channel: TarrableSearchPath, - new_revision: str, - old_revision: Optional[str]) -> None: - cachedir = git_cachedir(channel.git_repo) - v.status('Verifying rev is an ancestor of ref') + old_revision: str, + new_revision: str) -> None: + cachedir = git_cache.git_cachedir(channel.git_repo) + v.status('Verifying rev is an ancestor of previous rev %s' % old_revision) process = subprocess.run(['git', '-C', cachedir, 'merge-base', '--is-ancestor', - new_revision, - channel.git_ref]) - v.result(process.returncode == 0) - - if old_revision is not None: - v.status( - 'Verifying rev is an ancestor of previous rev %s' % - old_revision) - process = subprocess.run(['git', - '-C', - cachedir, - 'merge-base', - '--is-ancestor', - old_revision, - new_revision]) - v.result(process.returncode == 0) - - -def git_fetch( - v: Verification, - channel: TarrableSearchPath, - desired_revision: Optional[str], - old_revision: Optional[str]) -> str: - # It would be nice if we could share the nix git cache, but as of the time - # of writing it is transitioning from gitv2 (deprecated) to gitv3 (not ready - # yet), and trying to straddle them both is too far into nix implementation - # details for my comfort. So we re-implement here half of nix.fetchGit. - # :( - - cachedir = git_cachedir(channel.git_repo) - if not os.path.exists(cachedir): - v.status("Initializing git repo") - process = subprocess.run( - ['git', 'init', '--bare', cachedir]) - v.result(process.returncode == 0) - - v.status('Fetching ref "%s" from %s' % (channel.git_ref, channel.git_repo)) - # We don't use --force here because we want to abort and freak out if forced - # updates are happening. - process = subprocess.run(['git', - '-C', - cachedir, - 'fetch', - channel.git_repo, - '%s:%s' % (channel.git_ref, - channel.git_ref)]) + old_revision, + new_revision]) v.result(process.returncode == 0) - if desired_revision is not None: - v.status('Verifying that fetch retrieved this rev') - process = subprocess.run( - ['git', '-C', cachedir, 'cat-file', '-e', desired_revision]) - v.result(process.returncode == 0) - - new_revision = open( - os.path.join( - cachedir, - 'refs', - 'heads', - channel.git_ref)).read(999).strip() - - verify_git_ancestry(v, channel, new_revision, old_revision) - - return new_revision - - -def ensure_git_rev_available( - v: Verification, - channel: TarrableSearchPath, - pin: GitPin, - old_revision: Optional[str]) -> None: - cachedir = git_cachedir(channel.git_repo) - if os.path.exists(cachedir): - v.status('Checking if we already have this rev:') - process = subprocess.run( - ['git', '-C', cachedir, 'cat-file', '-e', pin.git_revision]) - if process.returncode == 0: - v.status('yes') - if process.returncode == 1: - v.status('no') - v.result(process.returncode == 0 or process.returncode == 1) - if process.returncode == 0: - verify_git_ancestry(v, channel, pin.git_revision, old_revision) - return - git_fetch(v, channel, pin.git_revision, old_revision) - def compare_tarball_and_git( v: Verification, @@ -511,7 +427,7 @@ def git_checkout( v.status('Checking out corresponding git revision') git = subprocess.Popen(['git', '-C', - git_cachedir(channel.git_repo), + git_cache.git_cachedir(channel.git_repo), 'archive', pin.git_revision], stdout=subprocess.PIPE) @@ -543,7 +459,7 @@ def git_get_tarball( pin.git_revision) git = subprocess.Popen(['git', '-C', - git_cachedir(channel.git_repo), + git_cache.git_cachedir(channel.git_repo), 'archive', '--prefix=%s/' % pin.release_name, pin.git_revision], @@ -610,7 +526,7 @@ def git_revision_name( v.status('Getting commit date') process = subprocess.run(['git', '-C', - git_cachedir(channel.git_repo), + git_cache.git_cachedir(channel.git_repo), 'log', '-n1', '--format=%ct-%h', diff --git a/setup.py b/setup.py index 2c5dfc8..9d10977 100644 --- a/setup.py +++ b/setup.py @@ -5,4 +5,5 @@ setup( version='3.0.0-pre', py_modules=['pinch'], entry_points={'console_scripts': ['pinch = pinch:main']}, + dependency_links=['https://scottworley.com/git/git-cache'], ) -- 2.50.1 From b1590faa718dad9dae442a1b8e6731be071489a9 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Fri, 10 Jul 2020 21:57:57 -0700 Subject: [PATCH 004/100] Release 3.0.0 --- Changelog | 4 ++++ default.nix | 2 +- setup.py | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index 32f74a5..3b326d6 100644 --- a/Changelog +++ b/Changelog @@ -1,7 +1,11 @@ ## [Unreleased] + + +## [3.0.0] - 2020-07-10 ### Changed - Moved git cache out to a separate library + ## [2.1.1] - 2020-07-01 ### Changed - Pin faster: Skip archive comparison if git rev is unchanged diff --git a/default.nix b/default.nix index b3fc3a5..62798c1 100644 --- a/default.nix +++ b/default.nix @@ -19,7 +19,7 @@ in pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix, git, autopep8, mypy, pylint, git-cache, }: buildPythonPackage rec { pname = "pinch"; - version = "3.0.0-pre"; + version = "3.0.0"; src = lib.cleanSource ./.; propagatedBuildInputs = [ git-cache ]; checkInputs = [ nix git mypy ] ++ lib.optionals lint [ autopep8 pylint ]; diff --git a/setup.py b/setup.py index 9d10977..97dada4 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup setup( name='pinch', - version='3.0.0-pre', + version='3.0.0', py_modules=['pinch'], entry_points={'console_scripts': ['pinch = pinch:main']}, dependency_links=['https://scottworley.com/git/git-cache'], -- 2.50.1 From 5e9aa037b72d6a3a0d088764657cbc99eb81fb95 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Wed, 15 Jul 2020 12:43:20 -0700 Subject: [PATCH 005/100] Start on 3.0.1 --- default.nix | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/default.nix b/default.nix index 62798c1..56f47de 100644 --- a/default.nix +++ b/default.nix @@ -19,7 +19,7 @@ in pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix, git, autopep8, mypy, pylint, git-cache, }: buildPythonPackage rec { pname = "pinch"; - version = "3.0.0"; + version = "3.0.1-pre"; src = lib.cleanSource ./.; propagatedBuildInputs = [ git-cache ]; checkInputs = [ nix git mypy ] ++ lib.optionals lint [ autopep8 pylint ]; diff --git a/setup.py b/setup.py index 97dada4..381debd 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup setup( name='pinch', - version='3.0.0', + version='3.0.1-pre', py_modules=['pinch'], entry_points={'console_scripts': ['pinch = pinch:main']}, dependency_links=['https://scottworley.com/git/git-cache'], -- 2.50.1 From 1c2be76a004c61939e70baf025f0e3cc710f082b Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Wed, 15 Jul 2020 12:44:34 -0700 Subject: [PATCH 006/100] Fix typo in README --- README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README b/README index b0c1ebc..5c45107 100644 --- a/README +++ b/README @@ -31,4 +31,4 @@ Advantages over nix-channel: * Deploy the exact same channel content to multiple machines. * Store your pin file in revision control for more powerful rollback mechanism than `nix-channel --rollback`. - * Chanel contents are verified by hash before being installed. + * Channel contents are verified by hash before being installed. -- 2.50.1 From c36b350d8762bccc7a434bcbdd5587066f931061 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Fri, 17 Jul 2020 15:34:28 -0700 Subject: [PATCH 007/100] Links & feature comparison with require.nix, niv, flakes --- README | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/README b/README index 5c45107..46b1d14 100644 --- a/README +++ b/README @@ -27,8 +27,19 @@ The first "pin" command will add these fields to the file: The second "update" command applies these changes to your nix channels, like `nix-channel --update` does. -Advantages over nix-channel: - - * Deploy the exact same channel content to multiple machines. - * Store your pin file in revision control for more powerful rollback mechanism than `nix-channel --rollback`. - * Channel contents are verified by hash before being installed. +### Feature comparison + +| Feature | nix-channel | [require.nix][] | [niv][] | [flakes][] | pinch | +| ---------------------------- | :---------: | :-------------: | :-----: | :--------: | :---: | +| Same version across machines | - | yes | yes | yes | yes | +| Verifies hashes | - | ? | yes | yes | yes | +| Fetch from git | - | ? | yes | yes | yes | +| Fetch from git with ssh key | - | ? | yes | yes? | yes | +| command_not_found_handle | yes | ? | - | yes | yes | +| Verifies tarball == git repo | - | - | - | - | yes | +| Rejects force pushes | - | - | - | - | yes | +| Ready to use today | yes | - | yes | - | yes | + +[require.nix]: https://www.youtube.com/watch?v=DHOLjsyXPtM +[niv]: https://github.com/nmattia/niv +[flakes]: https://github.com/nixos/rfcs/pull/49 -- 2.50.1 From 36b163ac2e07ace46c1ad43b83e5e02e0c1af73d Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Tue, 4 Aug 2020 14:50:47 -0700 Subject: [PATCH 008/100] Make tests fast again when using recent git-cache with backoff --- Changelog | 2 ++ tests/lib/test-setup.sh | 2 ++ 2 files changed, 4 insertions(+) diff --git a/Changelog b/Changelog index 3b326d6..ecdc6db 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,6 @@ ## [Unreleased] +### Changed +- Make tests fast again when using recent git-cache with backoff ## [3.0.0] - 2020-07-10 diff --git a/tests/lib/test-setup.sh b/tests/lib/test-setup.sh index 4742ff0..86c23a2 100644 --- a/tests/lib/test-setup.sh +++ b/tests/lib/test-setup.sh @@ -1,5 +1,7 @@ set -e +export BACKOFF_MAX_TIME=0 + export GIT_AUTHOR_NAME=automation export GIT_COMMITTER_NAME=automation export GIT_AUTHOR_EMAIL=auto@mati.on -- 2.50.1 From f9bfb2d0d1abda6434b0cc6dda70eec89910daa6 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Tue, 4 Aug 2020 14:51:36 -0700 Subject: [PATCH 009/100] fallback git-cache 1.0.0 -> 1.2.1 Specifying git-cache's dependencies here is unfortunate. --- default.nix | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/default.nix b/default.nix index 56f47de..e8b7128 100644 --- a/default.nix +++ b/default.nix @@ -1,15 +1,34 @@ { pkgs ? import { }, lint ? false }: let - git-cache-fallback = { buildPythonPackage, fetchgit, git, mypy, }: + + # Remove after https://github.com/NixOS/nixpkgs/pull/93377 reaches stable + backoff-fallback = { lib, buildPythonPackage, fetchFromGitHub, pytestCheckHook + , poetry, pytest-asyncio, }: + buildPythonPackage rec { + pname = "backoff"; + version = "1.10.0"; + src = fetchFromGitHub { + owner = "litl"; + repo = pname; + rev = "v${version}"; + sha256 = "1jj0l6pjx747d2yyvnzd3qbm4qr73sq6cc56dhvd8wqfbp5279x0"; + }; + format = "pyproject"; + nativeBuildInputs = [ poetry ]; + checkInputs = [ pytestCheckHook pytest-asyncio ]; + }; + + git-cache-fallback = { buildPythonPackage, fetchgit, git, backoff, mypy, }: buildPythonPackage rec { pname = "git-cache"; - version = "1.0.0"; + version = "1.2.1"; src = fetchgit { url = "https://scottworley.com/git-cache.git"; rev = "v${version}"; - sha256 = "06mzjc424988n2s1h25x2bi3mxbk2pnba31zkjljgw4cgw2p9036"; + sha256 = "16yh75176pnbzf48ak7q8lpfpr6digi130i5drxs6k2y9nf7g1jz"; }; + propagatedBuildInputs = [ backoff ]; checkInputs = [ git mypy ]; doCheck = true; checkPhase = "./test.sh"; @@ -28,5 +47,9 @@ in pkgs.python3Packages.callPackage }) { git-cache = pkgs.python3Packages.git-cache or (pkgs.python3Packages.callPackage - git-cache-fallback { }); + git-cache-fallback { + backoff = + pkgs.python3Packages.backoff or (pkgs.python3Packages.callPackage + backoff-fallback { }); + }); } -- 2.50.1 From 02c8290c2eb98e1fd6d7a0db1dcf11976ad2d85d Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Tue, 4 Aug 2020 14:53:48 -0700 Subject: [PATCH 010/100] Release 3.0.1 --- Changelog | 3 +++ default.nix | 2 +- setup.py | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index ecdc6db..3ffe9db 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,7 @@ ## [Unreleased] + + +## [3.0.1] - 2020-08-04 ### Changed - Make tests fast again when using recent git-cache with backoff diff --git a/default.nix b/default.nix index e8b7128..e94df96 100644 --- a/default.nix +++ b/default.nix @@ -38,7 +38,7 @@ in pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix, git, autopep8, mypy, pylint, git-cache, }: buildPythonPackage rec { pname = "pinch"; - version = "3.0.1-pre"; + version = "3.0.1"; src = lib.cleanSource ./.; propagatedBuildInputs = [ git-cache ]; checkInputs = [ nix git mypy ] ++ lib.optionals lint [ autopep8 pylint ]; diff --git a/setup.py b/setup.py index 381debd..76e2a21 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup setup( name='pinch', - version='3.0.1-pre', + version='3.0.1', py_modules=['pinch'], entry_points={'console_scripts': ['pinch = pinch:main']}, dependency_links=['https://scottworley.com/git/git-cache'], -- 2.50.1 From 448c7a49ab28e711e2f3c914525beb08591da8a8 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Tue, 16 Feb 2021 22:51:38 -0800 Subject: [PATCH 011/100] Start on 3.0.2 --- default.nix | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/default.nix b/default.nix index e94df96..cda5bb9 100644 --- a/default.nix +++ b/default.nix @@ -38,7 +38,7 @@ in pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix, git, autopep8, mypy, pylint, git-cache, }: buildPythonPackage rec { pname = "pinch"; - version = "3.0.1"; + version = "3.0.2-pre"; src = lib.cleanSource ./.; propagatedBuildInputs = [ git-cache ]; checkInputs = [ nix git mypy ] ++ lib.optionals lint [ autopep8 pylint ]; diff --git a/setup.py b/setup.py index 76e2a21..7ecb1bd 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup setup( name='pinch', - version='3.0.1', + version='3.0.2-pre', py_modules=['pinch'], entry_points={'console_scripts': ['pinch = pinch:main']}, dependency_links=['https://scottworley.com/git/git-cache'], -- 2.50.1 From 207c8e0d666bb54fb1c6001b4370e5c2229bb4ae Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Tue, 16 Feb 2021 22:52:20 -0800 Subject: [PATCH 012/100] Don't require experimental-features=nix-command in system nix.conf --- Changelog | 2 ++ pinch.py | 20 ++++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Changelog b/Changelog index 3ffe9db..cca3d8b 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,6 @@ ## [Unreleased] +### Changed +- Don't rely on experimental-features=nix-command in system nix.conf ## [3.0.1] - 2020-08-04 diff --git a/pinch.py b/pinch.py index 5eb7601..369dd56 100644 --- a/pinch.py +++ b/pinch.py @@ -304,16 +304,28 @@ def digest_file(filename: str) -> Digest16: def to_Digest16(v: Verification, digest32: Digest32) -> Digest16: v.status('Converting digest to base16') - process = subprocess.run( - ['nix', 'to-base16', '--type', 'sha256', digest32], stdout=subprocess.PIPE) + process = subprocess.run(['nix', + '--experimental-features', + 'nix-command', + 'to-base16', + '--type', + 'sha256', + digest32], + stdout=subprocess.PIPE) v.result(process.returncode == 0) return Digest16(process.stdout.decode().strip()) def to_Digest32(v: Verification, digest16: Digest16) -> Digest32: v.status('Converting digest to base32') - process = subprocess.run( - ['nix', 'to-base32', '--type', 'sha256', digest16], stdout=subprocess.PIPE) + process = subprocess.run(['nix', + '--experimental-features', + 'nix-command', + 'to-base32', + '--type', + 'sha256', + digest16], + stdout=subprocess.PIPE) v.result(process.returncode == 0) return Digest32(process.stdout.decode().strip()) -- 2.50.1 From 6c55232284274d9d8bcf9aa7db1f7a164c7301f9 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Tue, 16 Feb 2021 22:55:26 -0800 Subject: [PATCH 013/100] Release 3.0.2 --- Changelog | 2 ++ default.nix | 2 +- setup.py | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index cca3d8b..9c49595 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,6 @@ ## [Unreleased] + +## [3.0.2] - 2021-02-16 ### Changed - Don't rely on experimental-features=nix-command in system nix.conf diff --git a/default.nix b/default.nix index cda5bb9..20858fa 100644 --- a/default.nix +++ b/default.nix @@ -38,7 +38,7 @@ in pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix, git, autopep8, mypy, pylint, git-cache, }: buildPythonPackage rec { pname = "pinch"; - version = "3.0.2-pre"; + version = "3.0.2"; src = lib.cleanSource ./.; propagatedBuildInputs = [ git-cache ]; checkInputs = [ nix git mypy ] ++ lib.optionals lint [ autopep8 pylint ]; diff --git a/setup.py b/setup.py index 7ecb1bd..562494f 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup setup( name='pinch', - version='3.0.2-pre', + version='3.0.2', py_modules=['pinch'], entry_points={'console_scripts': ['pinch = pinch:main']}, dependency_links=['https://scottworley.com/git/git-cache'], -- 2.50.1 From 09e9efd3bbad1e4abdd4ede7c4dc821e630bacfd Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Wed, 19 May 2021 23:48:06 -0700 Subject: [PATCH 014/100] Start on 3.0.3 --- default.nix | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/default.nix b/default.nix index 20858fa..faf4742 100644 --- a/default.nix +++ b/default.nix @@ -38,7 +38,7 @@ in pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix, git, autopep8, mypy, pylint, git-cache, }: buildPythonPackage rec { pname = "pinch"; - version = "3.0.2"; + version = "3.0.3-pre"; src = lib.cleanSource ./.; propagatedBuildInputs = [ git-cache ]; checkInputs = [ nix git mypy ] ++ lib.optionals lint [ autopep8 pylint ]; diff --git a/setup.py b/setup.py index 562494f..127bd82 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup setup( name='pinch', - version='3.0.2', + version='3.0.3-pre', py_modules=['pinch'], entry_points={'console_scripts': ['pinch = pinch:main']}, dependency_links=['https://scottworley.com/git/git-cache'], -- 2.50.1 From 1d48f551985ae8b135e4e052338d2bf3d5774ef6 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Wed, 19 May 2021 23:57:08 -0700 Subject: [PATCH 015/100] Don't pass --experimental-features to old nix It complains: error: unrecognised flag '--experimental-features' --- Changelog | 1 + pinch.py | 42 ++++++++++++++++++++++++++---------------- 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/Changelog b/Changelog index 9c49595..557dab4 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ ## [Unreleased] +- Don't pass --experimental-features to old nix versions ## [3.0.2] - 2021-02-16 ### Changed diff --git a/pinch.py b/pinch.py index 369dd56..c26070b 100644 --- a/pinch.py +++ b/pinch.py @@ -302,30 +302,40 @@ def digest_file(filename: str) -> Digest16: return Digest16(hasher.hexdigest()) +_experimental_flag_needed = None + + +def _nix_command(v: Verification) -> List[str]: + global _experimental_flag_needed + if _experimental_flag_needed is None: + v.status('Checking Nix version') + process = subprocess.run(['nix', '--help'], stdout=subprocess.PIPE) + v.result(process.returncode == 0) + _experimental_flag_needed = b'--experimental-features' in process.stdout + return ['nix', '--experimental-features', + 'nix-command'] if _experimental_flag_needed else ['nix'] + + def to_Digest16(v: Verification, digest32: Digest32) -> Digest16: v.status('Converting digest to base16') - process = subprocess.run(['nix', - '--experimental-features', - 'nix-command', - 'to-base16', - '--type', - 'sha256', - digest32], - stdout=subprocess.PIPE) + process = subprocess.run(_nix_command(v) + [ + 'to-base16', + '--type', + 'sha256', + digest32], + stdout=subprocess.PIPE) v.result(process.returncode == 0) return Digest16(process.stdout.decode().strip()) def to_Digest32(v: Verification, digest16: Digest16) -> Digest32: v.status('Converting digest to base32') - process = subprocess.run(['nix', - '--experimental-features', - 'nix-command', - 'to-base32', - '--type', - 'sha256', - digest16], - stdout=subprocess.PIPE) + process = subprocess.run(_nix_command(v) + [ + 'to-base32', + '--type', + 'sha256', + digest16], + stdout=subprocess.PIPE) v.result(process.returncode == 0) return Digest32(process.stdout.decode().strip()) -- 2.50.1 From 175e0ccf87e154008e4a3f41576045070c83241a Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Thu, 20 May 2021 00:11:26 -0700 Subject: [PATCH 016/100] Release 3.0.3 --- Changelog | 5 +++++ default.nix | 2 +- setup.py | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index 557dab4..ed58b28 100644 --- a/Changelog +++ b/Changelog @@ -1,6 +1,11 @@ ## [Unreleased] + + +## [3.0.3] - 2021-05-20 +### Changed - Don't pass --experimental-features to old nix versions + ## [3.0.2] - 2021-02-16 ### Changed - Don't rely on experimental-features=nix-command in system nix.conf diff --git a/default.nix b/default.nix index faf4742..8397cb6 100644 --- a/default.nix +++ b/default.nix @@ -38,7 +38,7 @@ in pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix, git, autopep8, mypy, pylint, git-cache, }: buildPythonPackage rec { pname = "pinch"; - version = "3.0.3-pre"; + version = "3.0.3"; src = lib.cleanSource ./.; propagatedBuildInputs = [ git-cache ]; checkInputs = [ nix git mypy ] ++ lib.optionals lint [ autopep8 pylint ]; diff --git a/setup.py b/setup.py index 127bd82..70fca63 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup setup( name='pinch', - version='3.0.3-pre', + version='3.0.3', py_modules=['pinch'], entry_points={'console_scripts': ['pinch = pinch:main']}, dependency_links=['https://scottworley.com/git/git-cache'], -- 2.50.1 From 10adf165ad567b19f3a389d33788afa91b42425a Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Mon, 7 Jun 2021 12:13:31 -0700 Subject: [PATCH 017/100] Start on 3.0.4 --- default.nix | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/default.nix b/default.nix index 8397cb6..913f546 100644 --- a/default.nix +++ b/default.nix @@ -38,7 +38,7 @@ in pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix, git, autopep8, mypy, pylint, git-cache, }: buildPythonPackage rec { pname = "pinch"; - version = "3.0.3"; + version = "3.0.4-pre"; src = lib.cleanSource ./.; propagatedBuildInputs = [ git-cache ]; checkInputs = [ nix git mypy ] ++ lib.optionals lint [ autopep8 pylint ]; diff --git a/setup.py b/setup.py index 70fca63..cb272ae 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup setup( name='pinch', - version='3.0.3', + version='3.0.4-pre', py_modules=['pinch'], entry_points={'console_scripts': ['pinch = pinch:main']}, dependency_links=['https://scottworley.com/git/git-cache'], -- 2.50.1 From f2f22eb254be27577cde2c2ab7e6cda80c1229a5 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Mon, 7 Jun 2021 12:13:43 -0700 Subject: [PATCH 018/100] Use nix from nixpkgs (not from PATH) to avoid nixUnstable --- Changelog | 4 ++++ default.nix | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index ed58b28..7946d7b 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,8 @@ ## [Unreleased] +### Changed +- Use nix from nixpkgs rather than from PATH. This is needed when the nix in +PATH is nixUnstable-3.0pre20201020_e0ca98c or later because nix commit +787469c7b66aec12ab6847e7db2cdc8aef5c325e removed . ## [3.0.3] - 2021-05-20 diff --git a/default.nix b/default.nix index 913f546..8c8fbd3 100644 --- a/default.nix +++ b/default.nix @@ -34,14 +34,18 @@ let checkPhase = "./test.sh"; }; -in pkgs.python3Packages.callPackage -({ lib, buildPythonPackage, nix, git, autopep8, mypy, pylint, git-cache, }: +in pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix, git + , autopep8, makeWrapper, mypy, pylint, git-cache, }: buildPythonPackage rec { pname = "pinch"; version = "3.0.4-pre"; src = lib.cleanSource ./.; + buildInputs = [ makeWrapper ]; propagatedBuildInputs = [ git-cache ]; checkInputs = [ nix git mypy ] ++ lib.optionals lint [ autopep8 pylint ]; + postInstall = '' + wrapProgram "$out/bin/pinch" --prefix PATH : ${nix}/bin + ''; doCheck = true; checkPhase = "./test.sh"; }) { -- 2.50.1 From 815e366bb8a93f938f435a0e6a347ce29c2e16da Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Mon, 7 Jun 2021 12:15:42 -0700 Subject: [PATCH 019/100] Release 3.0.4 --- Changelog | 3 +++ default.nix | 2 +- setup.py | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index 7946d7b..04655b3 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,7 @@ ## [Unreleased] + + +## [3.0.4] - 2021-06-07 ### Changed - Use nix from nixpkgs rather than from PATH. This is needed when the nix in PATH is nixUnstable-3.0pre20201020_e0ca98c or later because nix commit diff --git a/default.nix b/default.nix index 8c8fbd3..f3816c5 100644 --- a/default.nix +++ b/default.nix @@ -38,7 +38,7 @@ in pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix, git , autopep8, makeWrapper, mypy, pylint, git-cache, }: buildPythonPackage rec { pname = "pinch"; - version = "3.0.4-pre"; + version = "3.0.4"; src = lib.cleanSource ./.; buildInputs = [ makeWrapper ]; propagatedBuildInputs = [ git-cache ]; diff --git a/setup.py b/setup.py index cb272ae..ab680db 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup setup( name='pinch', - version='3.0.4-pre', + version='3.0.4', py_modules=['pinch'], entry_points={'console_scripts': ['pinch = pinch:main']}, dependency_links=['https://scottworley.com/git/git-cache'], -- 2.50.1 From 382f6a2636a2d6630796bcfb03757df4f11bd3c3 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Mon, 7 Jun 2021 23:25:24 -0700 Subject: [PATCH 020/100] fallback git-cache 1.2.1 -> 1.3.1 --- default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/default.nix b/default.nix index f3816c5..dc7470b 100644 --- a/default.nix +++ b/default.nix @@ -22,11 +22,11 @@ let git-cache-fallback = { buildPythonPackage, fetchgit, git, backoff, mypy, }: buildPythonPackage rec { pname = "git-cache"; - version = "1.2.1"; + version = "1.3.1"; src = fetchgit { url = "https://scottworley.com/git-cache.git"; rev = "v${version}"; - sha256 = "16yh75176pnbzf48ak7q8lpfpr6digi130i5drxs6k2y9nf7g1jz"; + sha256 = "0awz7f6avzw9fk9gp1kadj0nbmf1s60qic9zb6ww92zig3khg12k"; }; propagatedBuildInputs = [ backoff ]; checkInputs = [ git mypy ]; -- 2.50.1 From ffe4974c09bb1fd7e559a0caf4109c260cb67a79 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Fri, 9 Jul 2021 15:10:12 -0700 Subject: [PATCH 021/100] Start on 3.0.5 --- default.nix | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/default.nix b/default.nix index dc7470b..071c428 100644 --- a/default.nix +++ b/default.nix @@ -38,7 +38,7 @@ in pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix, git , autopep8, makeWrapper, mypy, pylint, git-cache, }: buildPythonPackage rec { pname = "pinch"; - version = "3.0.4"; + version = "3.0.5-pre"; src = lib.cleanSource ./.; buildInputs = [ makeWrapper ]; propagatedBuildInputs = [ git-cache ]; diff --git a/setup.py b/setup.py index ab680db..7dff4ee 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup setup( name='pinch', - version='3.0.4', + version='3.0.5-pre', py_modules=['pinch'], entry_points={'console_scripts': ['pinch = pinch:main']}, dependency_links=['https://scottworley.com/git/git-cache'], -- 2.50.1 From b1e8c1b07e325426febd7e27030e4f8f6769bcde Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Fri, 9 Jul 2021 15:30:27 -0700 Subject: [PATCH 022/100] Appease linter: No global variables --- pinch.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/pinch.py b/pinch.py index c26070b..9555d74 100644 --- a/pinch.py +++ b/pinch.py @@ -302,18 +302,17 @@ def digest_file(filename: str) -> Digest16: return Digest16(hasher.hexdigest()) -_experimental_flag_needed = None +@functools.lru_cache +def _experimental_flag_needed(v: Verification) -> bool: + v.status('Checking Nix version') + process = subprocess.run(['nix', '--help'], stdout=subprocess.PIPE) + v.result(process.returncode == 0) + return b'--experimental-features' in process.stdout def _nix_command(v: Verification) -> List[str]: - global _experimental_flag_needed - if _experimental_flag_needed is None: - v.status('Checking Nix version') - process = subprocess.run(['nix', '--help'], stdout=subprocess.PIPE) - v.result(process.returncode == 0) - _experimental_flag_needed = b'--experimental-features' in process.stdout return ['nix', '--experimental-features', - 'nix-command'] if _experimental_flag_needed else ['nix'] + 'nix-command'] if _experimental_flag_needed(v) else ['nix'] def to_Digest16(v: Verification, digest32: Digest32) -> Digest16: -- 2.50.1 From ba23f9978a3e5f47051ad611a71996b26de4c02e Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Fri, 9 Jul 2021 15:12:58 -0700 Subject: [PATCH 023/100] Quiet git init.defaultBranch hints during test runs --- tests/lib/test-setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/lib/test-setup.sh b/tests/lib/test-setup.sh index 86c23a2..f3eb661 100644 --- a/tests/lib/test-setup.sh +++ b/tests/lib/test-setup.sh @@ -19,7 +19,7 @@ foo_setup() { repo_dir="`mktemp -d`" repo="$repo_dir/repo" - git init "$repo" + git -c init.defaultBranch=master init "$repo" ( cd "$repo" echo Contents > test-file -- 2.50.1 From 9eecb073aa16525d4a09c62178f32ba8b7788cc5 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Fri, 9 Jul 2021 16:06:34 -0700 Subject: [PATCH 024/100] fallback git-cache 1.3.1 -> 1.4.1 --- default.nix | 4 ++-- tests/lib/test-setup.sh | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/default.nix b/default.nix index 071c428..c69c03a 100644 --- a/default.nix +++ b/default.nix @@ -22,11 +22,11 @@ let git-cache-fallback = { buildPythonPackage, fetchgit, git, backoff, mypy, }: buildPythonPackage rec { pname = "git-cache"; - version = "1.3.1"; + version = "1.4.1"; src = fetchgit { url = "https://scottworley.com/git-cache.git"; rev = "v${version}"; - sha256 = "0awz7f6avzw9fk9gp1kadj0nbmf1s60qic9zb6ww92zig3khg12k"; + sha256 = "0ml1myhmd9mw1z5bwni9fhvx7h9dknhmqq4nyci9n5lvrhbmcdc9"; }; propagatedBuildInputs = [ backoff ]; checkInputs = [ git mypy ]; diff --git a/tests/lib/test-setup.sh b/tests/lib/test-setup.sh index f3eb661..e4260f4 100644 --- a/tests/lib/test-setup.sh +++ b/tests/lib/test-setup.sh @@ -8,7 +8,9 @@ export GIT_AUTHOR_EMAIL=auto@mati.on export GIT_COMMITTER_EMAIL=auto@mati.on cache_dir=$(mktemp -d) +data_dir=$(mktemp -d) export XDG_CACHE_HOME=$cache_dir +export XDG_DATA_HOME=$data_dir nix_store=$(mktemp -d) nix_state=$(mktemp -d) @@ -41,6 +43,7 @@ test_cleanup() { if [ "$repo_dir" ];then rm -rf "$repo_dir"; fi if [ "$conf" ];then rm "$conf"; fi if [ "$cache_dir" ];then rm -rf "$cache_dir"; fi + if [ "$data_dir" ];then rm -rf "$data_dir"; fi if [ "$nix_store" ];then rm -rf "$nix_store"; fi if [ "$nix_state" ];then rm -rf "$nix_state"; fi } -- 2.50.1 From d66db88a3054c3c02e7594dc231616d1b0e785b3 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Fri, 9 Jul 2021 15:31:47 -0700 Subject: [PATCH 025/100] Show filename being hashed This is handy for identifying which file is corrupt in the nix store. --- Changelog | 2 ++ pinch.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Changelog b/Changelog index 04655b3..0f0dc74 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,6 @@ ## [Unreleased] +### Changed +- Show filename being hashed. Helps find nix store corruption. ## [3.0.4] - 2021-06-07 diff --git a/pinch.py b/pinch.py index 9555d74..18055dc 100644 --- a/pinch.py +++ b/pinch.py @@ -351,7 +351,7 @@ def fetch_with_nix_prefetch_url( assert empty == '' v.check("Verifying nix-prefetch-url's digest", to_Digest16(v, Digest32(prefetch_digest)) == digest) - v.status("Verifying file digest") + v.status("Verifying digest of %s" % path) file_digest = digest_file(path) v.result(file_digest == digest) return path # type: ignore # (for old mypy) -- 2.50.1 From ff6f6673d8cc06004c43088ac37578eaa1e4667d Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Fri, 9 Jul 2021 15:36:43 -0700 Subject: [PATCH 026/100] Release 3.0.5 --- Changelog | 3 +++ default.nix | 2 +- setup.py | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index 0f0dc74..5724f4b 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,7 @@ ## [Unreleased] + + +## [3.0.5] - 2021-07-09 ### Changed - Show filename being hashed. Helps find nix store corruption. diff --git a/default.nix b/default.nix index c69c03a..920b108 100644 --- a/default.nix +++ b/default.nix @@ -38,7 +38,7 @@ in pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix, git , autopep8, makeWrapper, mypy, pylint, git-cache, }: buildPythonPackage rec { pname = "pinch"; - version = "3.0.5-pre"; + version = "3.0.5"; src = lib.cleanSource ./.; buildInputs = [ makeWrapper ]; propagatedBuildInputs = [ git-cache ]; diff --git a/setup.py b/setup.py index 7dff4ee..4611bb5 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup setup( name='pinch', - version='3.0.5-pre', + version='3.0.5', py_modules=['pinch'], entry_points={'console_scripts': ['pinch = pinch:main']}, dependency_links=['https://scottworley.com/git/git-cache'], -- 2.50.1 From 38fcf16a6146a8dcd4944debed9b3e0260a0dcaf Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Thu, 13 Jan 2022 16:05:27 -0800 Subject: [PATCH 027/100] Start on 3.0.6 --- default.nix | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/default.nix b/default.nix index 920b108..3c3f9ca 100644 --- a/default.nix +++ b/default.nix @@ -38,7 +38,7 @@ in pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix, git , autopep8, makeWrapper, mypy, pylint, git-cache, }: buildPythonPackage rec { pname = "pinch"; - version = "3.0.5"; + version = "3.0.6-pre"; src = lib.cleanSource ./.; buildInputs = [ makeWrapper ]; propagatedBuildInputs = [ git-cache ]; diff --git a/setup.py b/setup.py index 4611bb5..6bdc169 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup setup( name='pinch', - version='3.0.5', + version='3.0.6-pre', py_modules=['pinch'], entry_points={'console_scripts': ['pinch = pinch:main']}, dependency_links=['https://scottworley.com/git/git-cache'], -- 2.50.1 From b2bb38e6b9172072458ec1c8aed3e0b4c5f54a43 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Sun, 7 Nov 2021 11:49:19 -0800 Subject: [PATCH 028/100] Show channel fetch URL --- Changelog | 2 ++ pinch.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Changelog b/Changelog index 5724f4b..3733d0d 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,6 @@ ## [Unreleased] +### Changed +- Show the channel URL being fetched. ## [3.0.5] - 2021-07-09 diff --git a/pinch.py b/pinch.py index 18055dc..130f69a 100644 --- a/pinch.py +++ b/pinch.py @@ -247,7 +247,7 @@ def compare(a: str, b: str) -> Tuple[List[str], List[str], List[str]]: def fetch_channel( v: Verification, channel: ChannelSearchPath) -> Tuple[str, str]: - v.status('Fetching channel') + v.status('Fetching channel from %s' % channel.channel_url) request = urllib.request.urlopen(channel.channel_url, timeout=10) channel_html = request.read().decode() forwarded_url = request.geturl() -- 2.50.1 From fd9d5da1f21089d903d95d6386e0aefe2de4e219 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Thu, 13 Jan 2022 15:52:16 -0800 Subject: [PATCH 029/100] Deprecation notice --- Changelog | 1 + README | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Changelog b/Changelog index 3733d0d..152bb35 100644 --- a/Changelog +++ b/Changelog @@ -1,5 +1,6 @@ ## [Unreleased] ### Changed +- Deprecate pinch. - Show the channel URL being fetched. diff --git a/README b/README index 46b1d14..80dcdce 100644 --- a/README +++ b/README @@ -1,3 +1,9 @@ +# Deprecated + +Now that [flakes][https://nixos.wiki/wiki/Flakes] are more or less ready for +general use, this is mostly of historical interest. + + # Pinch PIN CHannels - a simple drop-in replacement for `nix-channel --update`. @@ -38,7 +44,7 @@ The second "update" command applies these changes to your nix channels, like `ni | command_not_found_handle | yes | ? | - | yes | yes | | Verifies tarball == git repo | - | - | - | - | yes | | Rejects force pushes | - | - | - | - | yes | -| Ready to use today | yes | - | yes | - | yes | +| Ready to use today | yes | - | yes | yes | yes | [require.nix]: https://www.youtube.com/watch?v=DHOLjsyXPtM [niv]: https://github.com/nmattia/niv -- 2.50.1 From 5144c1d383be505bef11f8191b41cbf3cf4a8e49 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Thu, 13 Jan 2022 16:01:09 -0800 Subject: [PATCH 030/100] Use nix 2.3 because 2.4 broke Nix commit 787469c7b66aec12ab6847e7db2cdc8aef5c325e removed . --- Changelog | 1 + default.nix | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Changelog b/Changelog index 152bb35..f6943ec 100644 --- a/Changelog +++ b/Changelog @@ -2,6 +2,7 @@ ### Changed - Deprecate pinch. - Show the channel URL being fetched. +- Use nix 2.3 because 2.4 broke . ## [3.0.5] - 2021-07-09 diff --git a/default.nix b/default.nix index 3c3f9ca..fae46cc 100644 --- a/default.nix +++ b/default.nix @@ -34,7 +34,7 @@ let checkPhase = "./test.sh"; }; -in pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix, git +in pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix_2_3, git , autopep8, makeWrapper, mypy, pylint, git-cache, }: buildPythonPackage rec { pname = "pinch"; @@ -42,9 +42,9 @@ in pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix, git src = lib.cleanSource ./.; buildInputs = [ makeWrapper ]; propagatedBuildInputs = [ git-cache ]; - checkInputs = [ nix git mypy ] ++ lib.optionals lint [ autopep8 pylint ]; + checkInputs = [ nix_2_3 git mypy ] ++ lib.optionals lint [ autopep8 pylint ]; postInstall = '' - wrapProgram "$out/bin/pinch" --prefix PATH : ${nix}/bin + wrapProgram "$out/bin/pinch" --prefix PATH : ${nix_2_3}/bin ''; doCheck = true; checkPhase = "./test.sh"; @@ -56,4 +56,5 @@ in pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix, git pkgs.python3Packages.backoff or (pkgs.python3Packages.callPackage backoff-fallback { }); }); + nix_2_3 = pkgs.nix_2_3 or pkgs.nix; } -- 2.50.1 From 436195f097c503546a7d1d80f4e82964bcdc7392 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Thu, 13 Jan 2022 21:55:09 -0800 Subject: [PATCH 031/100] Support restricted mode: Allow tarball access with search paths. 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.) --- Changelog | 1 + pinch.py | 8 ++++++-- tests/alias.sh | 2 +- tests/core.sh | 2 +- tests/multi-update.sh | 2 +- tests/pin-twice.sh | 2 +- tests/profile.sh | 2 +- tests/symlink.sh | 2 +- 8 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Changelog b/Changelog index f6943ec..1bd1d9c 100644 --- a/Changelog +++ b/Changelog @@ -3,6 +3,7 @@ - Deprecate pinch. - Show the channel URL being fetched. - Use nix 2.3 because 2.4 broke . +- Support restricted mode: Allow tarball access with search paths. ## [3.0.5] - 2021-07-09 diff --git a/pinch.py b/pinch.py index 130f69a..2ba47b2 100644 --- a/pinch.py +++ b/pinch.py @@ -644,6 +644,7 @@ def pinCommand(args: argparse.Namespace) -> None: 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( @@ -651,10 +652,12 @@ def updateCommand(args: argparse.Namespace) -> None: 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) + 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)) @@ -671,7 +674,8 @@ def updateCommand(args: argparse.Namespace) -> None: '--file', '', '--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: diff --git a/tests/alias.sh b/tests/alias.sh index dce5747..bf63baa 100755 --- a/tests/alias.sh +++ b/tests/alias.sh @@ -14,7 +14,7 @@ python3 ./pinch.py pin "$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 '\'''\'' --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 '\'''\'' --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 diff --git a/tests/core.sh b/tests/core.sh index 5d11707..60ac99f 100755 --- a/tests/core.sh +++ b/tests/core.sh @@ -8,7 +8,7 @@ python3 ./pinch.py pin "$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 '\'''\'' --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 '\'''\'' --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 diff --git a/tests/multi-update.sh b/tests/multi-update.sh index aa617c8..87bf636 100755 --- a/tests/multi-update.sh +++ b/tests/multi-update.sh @@ -18,7 +18,7 @@ actual_env_command=`python3 ./pinch.py update --dry-run "$conf" "$conf2"` rm -rf "$conf2" -expected_env_command_RE='^nix-env --profile /nix/var/nix/profiles/per-user/[^/]+/channels --show-trace --file '\'''\'' --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 '\'''\'' --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 diff --git a/tests/pin-twice.sh b/tests/pin-twice.sh index ee50174..12d4646 100755 --- a/tests/pin-twice.sh +++ b/tests/pin-twice.sh @@ -17,7 +17,7 @@ python3 ./pinch.py pin "$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 '\'''\'' --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 '\'''\'' --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 diff --git a/tests/profile.sh b/tests/profile.sh index 00ceb27..08cf5b3 100755 --- a/tests/profile.sh +++ b/tests/profile.sh @@ -8,7 +8,7 @@ python3 ./pinch.py pin "$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 '\'''\'' --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 '\'''\'' --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 diff --git a/tests/symlink.sh b/tests/symlink.sh index 7f4c354..e5ef8c3 100755 --- a/tests/symlink.sh +++ b/tests/symlink.sh @@ -14,7 +14,7 @@ python3 ./pinch.py pin "$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 '\'''\'' --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 '\'''\'' --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 -- 2.50.1 From e79a920cadeaacdf871e1a10ef48d33c4d97cb02 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Thu, 13 Jan 2022 22:00:08 -0800 Subject: [PATCH 032/100] Announce test names as they are run. This makes it easier to see which test is broken. --- Changelog | 1 + test.sh | 1 + 2 files changed, 2 insertions(+) diff --git a/Changelog b/Changelog index 1bd1d9c..de62e83 100644 --- a/Changelog +++ b/Changelog @@ -4,6 +4,7 @@ - Show the channel URL being fetched. - Use nix 2.3 because 2.4 broke . - Support restricted mode: Allow tarball access with search paths. +- Announce test names as they are run. ## [3.0.5] - 2021-07-09 diff --git a/test.sh b/test.sh index fed0065..81e0c66 100755 --- a/test.sh +++ b/test.sh @@ -9,6 +9,7 @@ find . -name build -prune -o -name dist -prune -o -name '*.py' -print0 | for test in tests/*;do if [ ! -d "$test" ];then + echo "### Running test $test" >&2 "$test" fi done -- 2.50.1 From 3b2117a3ff0c74c8cf3dc27bbe9a3105428d03d5 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Wed, 19 Jan 2022 11:25:41 -0800 Subject: [PATCH 033/100] Support restricted mode: Allow manifest access with search paths. --- Changelog | 2 +- pinch.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index de62e83..a0932a9 100644 --- a/Changelog +++ b/Changelog @@ -3,7 +3,7 @@ - Deprecate pinch. - Show the channel URL being fetched. - Use nix 2.3 because 2.4 broke . -- Support restricted mode: Allow tarball access with search paths. +- Support restricted mode: Allow tarball and manifest access with search paths. - Announce test names as they are run. diff --git a/pinch.py b/pinch.py index 2ba47b2..f95323f 100644 --- a/pinch.py +++ b/pinch.py @@ -644,7 +644,11 @@ def pinCommand(args: argparse.Namespace) -> None: def updateCommand(args: argparse.Namespace) -> None: v = Verification() exprs: Dict[str, str] = {} - search_paths: List[str] = [] + profile_manifest = os.path.join(args.profile, "manifest.nix") + search_paths: List[str] = [ + "-I", "pinch_profile=" + args.profile, + "-I", "pinch_profile_manifest=" + os.readlink(profile_manifest) + ] if os.path.exists(profile_manifest) else [] config = { section: read_pinned_config_section(section, conf) for section, conf in read_config_files( -- 2.50.1 From 9c3f57889fca4f7a089eed038bd54d27fe7a30e7 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Wed, 19 Jan 2022 11:28:42 -0800 Subject: [PATCH 034/100] Release 3.0.6 --- Changelog | 3 +++ default.nix | 2 +- setup.py | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index a0932a9..78de92f 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,7 @@ ## [Unreleased] + + +## [3.0.6] - 2022-01-19 ### Changed - Deprecate pinch. - Show the channel URL being fetched. diff --git a/default.nix b/default.nix index fae46cc..f35c152 100644 --- a/default.nix +++ b/default.nix @@ -38,7 +38,7 @@ in pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix_2_3, git , autopep8, makeWrapper, mypy, pylint, git-cache, }: buildPythonPackage rec { pname = "pinch"; - version = "3.0.6-pre"; + version = "3.0.6"; src = lib.cleanSource ./.; buildInputs = [ makeWrapper ]; propagatedBuildInputs = [ git-cache ]; diff --git a/setup.py b/setup.py index 6bdc169..a19f143 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup setup( name='pinch', - version='3.0.6-pre', + version='3.0.6', py_modules=['pinch'], entry_points={'console_scripts': ['pinch = pinch:main']}, dependency_links=['https://scottworley.com/git/git-cache'], -- 2.50.1 From b11f21b085df77bd26f1c0c41a78e3ca953267e5 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Tue, 1 Feb 2022 17:23:24 -0800 Subject: [PATCH 035/100] Start on 3.0.7 --- default.nix | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/default.nix b/default.nix index f35c152..ad9355e 100644 --- a/default.nix +++ b/default.nix @@ -38,7 +38,7 @@ in pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix_2_3, git , autopep8, makeWrapper, mypy, pylint, git-cache, }: buildPythonPackage rec { pname = "pinch"; - version = "3.0.6"; + version = "3.0.7-pre"; src = lib.cleanSource ./.; buildInputs = [ makeWrapper ]; propagatedBuildInputs = [ git-cache ]; diff --git a/setup.py b/setup.py index a19f143..d52e791 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup setup( name='pinch', - version='3.0.6', + version='3.0.7-pre', py_modules=['pinch'], entry_points={'console_scripts': ['pinch = pinch:main']}, dependency_links=['https://scottworley.com/git/git-cache'], -- 2.50.1 From fc168c346f74912eee2377a28c583fe63889b1de Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Tue, 1 Feb 2022 17:25:41 -0800 Subject: [PATCH 036/100] Don't leave old channels laying around * The channels present should be deterministic -- exactly those specified in the pins file. The history of which other channels have been installed should not affect this. * Before this change, when a channel changes names only slightly, the old channel could block installation of the new channel. --- Changelog | 2 ++ pinch.py | 1 + tests/alias.sh | 2 +- tests/core.sh | 2 +- tests/multi-update.sh | 2 +- tests/pin-twice.sh | 2 +- tests/profile.sh | 2 +- tests/symlink.sh | 2 +- 8 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Changelog b/Changelog index 78de92f..7d20475 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,6 @@ ## [Unreleased] +### Changed +- Don't leave old channels laying around ## [3.0.6] - 2022-01-19 diff --git a/pinch.py b/pinch.py index f95323f..332d130 100644 --- a/pinch.py +++ b/pinch.py @@ -678,6 +678,7 @@ def updateCommand(args: argparse.Namespace) -> None: '--file', '', '--install', + '--remove-all', ] + search_paths + ['--from-expression'] + [ exprs[name] % name for name in sorted(exprs.keys())] if args.dry_run: diff --git a/tests/alias.sh b/tests/alias.sh index bf63baa..dc6afa9 100755 --- a/tests/alias.sh +++ b/tests/alias.sh @@ -14,7 +14,7 @@ python3 ./pinch.py pin "$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 '\'''\'' --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"; \}'\''$' +expected_env_command_RE='^nix-env --profile /nix/var/nix/profiles/per-user/[^/]+/channels --show-trace --file '\'''\'' --install --remove-all -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 diff --git a/tests/core.sh b/tests/core.sh index 60ac99f..af59329 100755 --- a/tests/core.sh +++ b/tests/core.sh @@ -8,7 +8,7 @@ python3 ./pinch.py pin "$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 '\'''\'' --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"; \}'\''$' +expected_env_command_RE='^nix-env --profile /nix/var/nix/profiles/per-user/[^/]+/channels --show-trace --file '\'''\'' --install --remove-all -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 diff --git a/tests/multi-update.sh b/tests/multi-update.sh index 87bf636..ea749a2 100755 --- a/tests/multi-update.sh +++ b/tests/multi-update.sh @@ -18,7 +18,7 @@ actual_env_command=`python3 ./pinch.py update --dry-run "$conf" "$conf2"` rm -rf "$conf2" -expected_env_command_RE='^nix-env --profile /nix/var/nix/profiles/per-user/[^/]+/channels --show-trace --file '\'''\'' --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"; \}'\''$' +expected_env_command_RE='^nix-env --profile /nix/var/nix/profiles/per-user/[^/]+/channels --show-trace --file '\'''\'' --install --remove-all -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 diff --git a/tests/pin-twice.sh b/tests/pin-twice.sh index 12d4646..6563fb5 100755 --- a/tests/pin-twice.sh +++ b/tests/pin-twice.sh @@ -17,7 +17,7 @@ python3 ./pinch.py pin "$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 '\'''\'' --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"; \}'\''$' +expected_env_command_RE='^nix-env --profile /nix/var/nix/profiles/per-user/[^/]+/channels --show-trace --file '\'''\'' --install --remove-all -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 diff --git a/tests/profile.sh b/tests/profile.sh index 08cf5b3..085f2ce 100755 --- a/tests/profile.sh +++ b/tests/profile.sh @@ -8,7 +8,7 @@ python3 ./pinch.py pin "$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 '\'''\'' --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"; \}'\''$' +expected_env_command_RE='^nix-env --profile /path/to/profile --show-trace --file '\'''\'' --install --remove-all -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 diff --git a/tests/symlink.sh b/tests/symlink.sh index e5ef8c3..d3a7929 100755 --- a/tests/symlink.sh +++ b/tests/symlink.sh @@ -14,7 +14,7 @@ python3 ./pinch.py pin "$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 '\'''\'' --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"; \}'\''$' +expected_env_command_RE='^nix-env --profile /nix/var/nix/profiles/per-user/[^/]+/channels --show-trace --file '\'''\'' --install --remove-all -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 -- 2.50.1 From e2478492c622511a381058c04aeeeb3186c53073 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Tue, 1 Feb 2022 17:38:05 -0800 Subject: [PATCH 037/100] Release 3.0.7 --- Changelog | 3 +++ default.nix | 2 +- setup.py | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index 7d20475..cd39ea1 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,7 @@ ## [Unreleased] + + +## [3.0.7] - 2022-02-01 ### Changed - Don't leave old channels laying around diff --git a/default.nix b/default.nix index ad9355e..eb3dac2 100644 --- a/default.nix +++ b/default.nix @@ -38,7 +38,7 @@ in pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix_2_3, git , autopep8, makeWrapper, mypy, pylint, git-cache, }: buildPythonPackage rec { pname = "pinch"; - version = "3.0.7-pre"; + version = "3.0.7"; src = lib.cleanSource ./.; buildInputs = [ makeWrapper ]; propagatedBuildInputs = [ git-cache ]; diff --git a/setup.py b/setup.py index d52e791..ac3c305 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup setup( name='pinch', - version='3.0.7-pre', + version='3.0.7', py_modules=['pinch'], entry_points={'console_scripts': ['pinch = pinch:main']}, dependency_links=['https://scottworley.com/git/git-cache'], -- 2.50.1 From dc8e913eb5787c5d85038243b53cc4ba80b88fa5 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Fri, 15 Apr 2022 23:51:34 -0700 Subject: [PATCH 038/100] Start on 3.0.8 --- default.nix | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/default.nix b/default.nix index eb3dac2..a8f4de6 100644 --- a/default.nix +++ b/default.nix @@ -38,7 +38,7 @@ in pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix_2_3, git , autopep8, makeWrapper, mypy, pylint, git-cache, }: buildPythonPackage rec { pname = "pinch"; - version = "3.0.7"; + version = "3.0.8-pre"; src = lib.cleanSource ./.; buildInputs = [ makeWrapper ]; propagatedBuildInputs = [ git-cache ]; diff --git a/setup.py b/setup.py index ac3c305..ceb7706 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup setup( name='pinch', - version='3.0.7', + version='3.0.8-pre', py_modules=['pinch'], entry_points={'console_scripts': ['pinch = pinch:main']}, dependency_links=['https://scottworley.com/git/git-cache'], -- 2.50.1 From 0ed3a03e957a3159a31338ee445e22cc660846d2 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Fri, 15 Apr 2022 22:46:39 -0700 Subject: [PATCH 039/100] Fix tests after restricted mode support update --- Changelog | 2 ++ tests/alias.sh | 2 +- tests/core.sh | 2 +- tests/multi-update.sh | 2 +- tests/pin-twice.sh | 2 +- tests/symlink.sh | 2 +- 6 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Changelog b/Changelog index cd39ea1..8a85e24 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,6 @@ ## [Unreleased] +### Fixed +- Fix tests after restricted mode support update ## [3.0.7] - 2022-02-01 diff --git a/tests/alias.sh b/tests/alias.sh index dc6afa9..de54e3d 100755 --- a/tests/alias.sh +++ b/tests/alias.sh @@ -14,7 +14,7 @@ python3 ./pinch.py pin "$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 '\'''\'' --install --remove-all -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"; \}'\''$' +expected_env_command_RE='^nix-env --profile /nix/var/nix/profiles/per-user/[^/]+/channels --show-trace --file '\'''\'' --install --remove-all -I pinch_profile=/nix/var/nix/profiles/per-user/[^/]+/channels -I pinch_profile_manifest=/nix/store/.{32}-env-manifest.nix -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 diff --git a/tests/core.sh b/tests/core.sh index af59329..1c857f4 100755 --- a/tests/core.sh +++ b/tests/core.sh @@ -8,7 +8,7 @@ python3 ./pinch.py pin "$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 '\'''\'' --install --remove-all -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"; \}'\''$' +expected_env_command_RE='^nix-env --profile /nix/var/nix/profiles/per-user/[^/]+/channels --show-trace --file '\'''\'' --install --remove-all -I pinch_profile=/nix/var/nix/profiles/per-user/[^/]+/channels -I pinch_profile_manifest=/nix/store/.{32}-env-manifest.nix -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 diff --git a/tests/multi-update.sh b/tests/multi-update.sh index ea749a2..52c59c8 100755 --- a/tests/multi-update.sh +++ b/tests/multi-update.sh @@ -18,7 +18,7 @@ actual_env_command=`python3 ./pinch.py update --dry-run "$conf" "$conf2"` rm -rf "$conf2" -expected_env_command_RE='^nix-env --profile /nix/var/nix/profiles/per-user/[^/]+/channels --show-trace --file '\'''\'' --install --remove-all -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"; \}'\''$' +expected_env_command_RE='^nix-env --profile /nix/var/nix/profiles/per-user/[^/]+/channels --show-trace --file '\'''\'' --install --remove-all -I pinch_profile=/nix/var/nix/profiles/per-user/[^/]+/channels -I pinch_profile_manifest=/nix/store/.{32}-env-manifest.nix -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 diff --git a/tests/pin-twice.sh b/tests/pin-twice.sh index 6563fb5..7730bd6 100755 --- a/tests/pin-twice.sh +++ b/tests/pin-twice.sh @@ -17,7 +17,7 @@ python3 ./pinch.py pin "$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 '\'''\'' --install --remove-all -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"; \}'\''$' +expected_env_command_RE='^nix-env --profile /nix/var/nix/profiles/per-user/[^/]+/channels --show-trace --file '\'''\'' --install --remove-all -I pinch_profile=/nix/var/nix/profiles/per-user/[^/]+/channels -I pinch_profile_manifest=/nix/store/.{32}-env-manifest.nix -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 diff --git a/tests/symlink.sh b/tests/symlink.sh index d3a7929..36e9c24 100755 --- a/tests/symlink.sh +++ b/tests/symlink.sh @@ -14,7 +14,7 @@ python3 ./pinch.py pin "$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 '\'''\'' --install --remove-all -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"; \}'\''$' +expected_env_command_RE='^nix-env --profile /nix/var/nix/profiles/per-user/[^/]+/channels --show-trace --file '\'''\'' --install --remove-all -I pinch_profile=/nix/var/nix/profiles/per-user/[^/]+/channels -I pinch_profile_manifest=/nix/store/.{32}-env-manifest.nix -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 -- 2.50.1 From fb27ccc70e0a525aed5d03b2347a0b933ebc3053 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Fri, 15 Apr 2022 23:18:37 -0700 Subject: [PATCH 040/100] New pylint likes 'with' --- pinch.py | 86 +++++++++++++++++++++++++------------------------------- 1 file changed, 39 insertions(+), 47 deletions(-) diff --git a/pinch.py b/pinch.py index 332d130..79622f4 100644 --- a/pinch.py +++ b/pinch.py @@ -248,10 +248,10 @@ def compare(a: str, b: str) -> Tuple[List[str], List[str], List[str]]: def fetch_channel( v: Verification, channel: ChannelSearchPath) -> Tuple[str, str]: v.status('Fetching channel from %s' % channel.channel_url) - request = urllib.request.urlopen(channel.channel_url, timeout=10) - channel_html = request.read().decode() - forwarded_url = request.geturl() - v.result(request.status == 200) # type: ignore # (for old mypy) + with urllib.request.urlopen(channel.channel_url, timeout=10) as request: + channel_html = request.read().decode() + forwarded_url = request.geturl() + v.result(request.status == 200) v.check('Got forwarded', channel.channel_url != forwarded_url) return channel_html, forwarded_url @@ -368,7 +368,8 @@ def fetch_resources( fields.file = fetch_with_nix_prefetch_url( v, fields.absolute_url, fields.digest) v.status('Verifying git commit on main page matches git commit in table') - v.result(open(table['git-revision'].file).read(999) == pin.git_revision) + with open(table['git-revision'].file, encoding='utf-8') as rev_file: + v.result(rev_file.read(999) == pin.git_revision) def tarball_cache_file(channel: TarrableSearchPath, pin: GitPin) -> str: @@ -446,19 +447,15 @@ def git_checkout( pin: GitPin, dest: str) -> None: v.status('Checking out corresponding git revision') - git = subprocess.Popen(['git', - '-C', - git_cache.git_cachedir(channel.git_repo), - 'archive', - pin.git_revision], - stdout=subprocess.PIPE) - tar = subprocess.Popen( - ['tar', 'x', '-C', dest, '-f', '-'], stdin=git.stdout) - if git.stdout: - git.stdout.close() - tar.wait() - git.wait() - v.result(git.returncode == 0 and tar.returncode == 0) + with subprocess.Popen( + ['git', '-C', git_cache.git_cachedir(channel.git_repo), 'archive', pin.git_revision], + stdout=subprocess.PIPE) as git: + with subprocess.Popen(['tar', 'x', '-C', dest, '-f', '-'], stdin=git.stdout) as tar: + if git.stdout: + git.stdout.close() + tar.wait() + git.wait() + v.result(git.returncode == 0 and tar.returncode == 0) def git_get_tarball( @@ -467,33 +464,32 @@ def git_get_tarball( pin: GitPin) -> str: cache_file = tarball_cache_file(channel, pin) if os.path.exists(cache_file): - cached_tarball = open(cache_file).read(9999) - if os.path.exists(cached_tarball): - return cached_tarball + with open(cache_file, encoding='utf-8') as f: + cached_tarball = f.read(9999) + if os.path.exists(cached_tarball): + return cached_tarball with tempfile.TemporaryDirectory() as output_dir: output_filename = os.path.join( output_dir, pin.release_name + '.tar.xz') - with open(output_filename, 'w') as output_file: + with open(output_filename, 'w', encoding='utf-8') as output_file: v.status( 'Generating tarball for git revision %s' % pin.git_revision) - git = subprocess.Popen(['git', - '-C', - git_cache.git_cachedir(channel.git_repo), - 'archive', - '--prefix=%s/' % pin.release_name, - pin.git_revision], - stdout=subprocess.PIPE) - xz = subprocess.Popen(['xz'], stdin=git.stdout, stdout=output_file) - xz.wait() - git.wait() - v.result(git.returncode == 0 and xz.returncode == 0) + with subprocess.Popen( + ['git', '-C', git_cache.git_cachedir(channel.git_repo), + 'archive', '--prefix=%s/' % pin.release_name, pin.git_revision], + stdout=subprocess.PIPE) as git: + with subprocess.Popen(['xz'], stdin=git.stdout, stdout=output_file) as xz: + xz.wait() + git.wait() + v.result(git.returncode == 0 and xz.returncode == 0) store_tarball = copy_to_nix_store(v, output_filename) os.makedirs(os.path.dirname(cache_file), exist_ok=True) - open(cache_file, 'w').write(store_tarball) + with open(cache_file, 'w', encoding='utf-8') as f: + f.write(store_tarball) return store_tarball # type: ignore # (for old mypy) @@ -502,21 +498,16 @@ def check_channel_metadata( pin: GitPin, channel_contents: str) -> None: v.status('Verifying git commit in channel tarball') - v.result( - open( - os.path.join( - channel_contents, - pin.release_name, - '.git-revision')).read(999) == pin.git_revision) + with open(os.path.join(channel_contents, pin.release_name, '.git-revision'), + encoding='utf-8') as f: + v.result(f.read(999) == pin.git_revision) v.status( 'Verifying version-suffix is a suffix of release name %s:' % pin.release_name) - version_suffix = open( - os.path.join( - channel_contents, - pin.release_name, - '.version-suffix')).read(999) + with open(os.path.join(channel_contents, pin.release_name, '.version-suffix'), + encoding='utf-8') as f: + version_suffix = f.read(999) v.status(version_suffix) v.result(pin.release_name.endswith(version_suffix)) @@ -610,7 +601,8 @@ def read_pinned_config_section( def read_config(filename: str) -> configparser.ConfigParser: config = configparser.ConfigParser() - config.read_file(open(filename), filename) + with open(filename, encoding='utf-8') as f: + config.read_file(f, filename) return config @@ -637,7 +629,7 @@ def pinCommand(args: argparse.Namespace) -> None: config[section].update(sp.pin(v, old_pin)._asdict()) - with open(args.channels_file, 'w') as configfile: + with open(args.channels_file, 'w', encoding='utf-8') as configfile: config.write(configfile) -- 2.50.1 From cb28d8e509d0483fdfd69d4f51174127a8a56e84 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Fri, 15 Apr 2022 23:42:46 -0700 Subject: [PATCH 041/100] New pylint likes f-strings --- pinch.py | 57 ++++++++++++++++++++++---------------------------------- 1 file changed, 22 insertions(+), 35 deletions(-) diff --git a/pinch.py b/pinch.py index 79622f4..e3c7ca0 100644 --- a/pinch.py +++ b/pinch.py @@ -64,7 +64,7 @@ class Verification: @staticmethod def _color(s: str, c: int) -> str: - return '\033[%2dm%s\033[00m' % (c, s) + return f'\033[{c:2d}m{s}\033[00m' def result(self, r: bool) -> None: message, color = {True: ('OK ', 92), False: ('FAIL', 91)}[r] @@ -247,7 +247,7 @@ def compare(a: str, b: str) -> Tuple[List[str], List[str], List[str]]: def fetch_channel( v: Verification, channel: ChannelSearchPath) -> Tuple[str, str]: - v.status('Fetching channel from %s' % channel.channel_url) + v.status(f'Fetching channel from {channel.channel_url}') with urllib.request.urlopen(channel.channel_url, timeout=10) as request: channel_html = request.read().decode() forwarded_url = request.geturl() @@ -343,7 +343,7 @@ def fetch_with_nix_prefetch_url( v: Verification, url: str, digest: Digest16) -> str: - v.status('Fetching %s' % url) + v.status(f'Fetching {url}') process = subprocess.run( ['nix-prefetch-url', '--print-path', url, digest], stdout=subprocess.PIPE) v.result(process.returncode == 0) @@ -351,7 +351,7 @@ def fetch_with_nix_prefetch_url( assert empty == '' v.check("Verifying nix-prefetch-url's digest", to_Digest16(v, Digest32(prefetch_digest)) == digest) - v.status("Verifying digest of %s" % path) + v.status(f"Verifying digest of {path}") file_digest = digest_file(path) v.result(file_digest == digest) return path # type: ignore # (for old mypy) @@ -376,10 +376,7 @@ def tarball_cache_file(channel: TarrableSearchPath, pin: GitPin) -> str: return os.path.join( xdg.XDG_CACHE_HOME, 'pinch/git-tarball', - '%s-%s-%s' % - (digest_string(channel.git_repo.encode()), - pin.git_revision, - pin.release_name)) + f'{digest_string(channel.git_repo.encode())}-{pin.git_revision}-{pin.release_name}') def verify_git_ancestry( @@ -388,7 +385,7 @@ def verify_git_ancestry( old_revision: str, new_revision: str) -> None: cachedir = git_cache.git_cachedir(channel.git_repo) - v.status('Verifying rev is an ancestor of previous rev %s' % old_revision) + v.status(f'Verifying rev is an ancestor of previous rev {old_revision}') process = subprocess.run(['git', '-C', cachedir, @@ -408,8 +405,8 @@ def compare_tarball_and_git( match, mismatch, errors = compare(os.path.join( channel_contents, pin.release_name), git_contents) v.ok() - v.check('%d files match' % len(match), len(match) > 0) - v.check('%d files differ' % len(mismatch), len(mismatch) == 0) + v.check(f'{len(match)} files match', len(match) > 0) + v.check(f'{len(mismatch)} files differ', len(mismatch) == 0) expected_errors = [ '.git-revision', '.version-suffix', @@ -421,14 +418,9 @@ def compare_tarball_and_git( if ee in errors: errors.remove(ee) benign_errors.append(ee) + v.check(f'{len(errors)} unexpected incomparable files', len(errors) == 0) v.check( - '%d unexpected incomparable files' % - len(errors), - len(errors) == 0) - v.check( - '(%d of %d expected incomparable files)' % - (len(benign_errors), - len(expected_errors)), + f'({len(benign_errors)} of {len(expected_errors)} expected incomparable files)', len(benign_errors) == len(expected_errors)) @@ -436,7 +428,7 @@ def extract_tarball( v: Verification, table: Dict[str, ChannelTableEntry], dest: str) -> None: - v.status('Extracting tarball %s' % table['nixexprs.tar.xz'].file) + v.status(f"Extracting tarball {table['nixexprs.tar.xz'].file}") shutil.unpack_archive(table['nixexprs.tar.xz'].file, dest) v.ok() @@ -473,12 +465,10 @@ def git_get_tarball( output_filename = os.path.join( output_dir, pin.release_name + '.tar.xz') with open(output_filename, 'w', encoding='utf-8') as output_file: - v.status( - 'Generating tarball for git revision %s' % - pin.git_revision) + v.status(f'Generating tarball for git revision {pin.git_revision}') with subprocess.Popen( ['git', '-C', git_cache.git_cachedir(channel.git_repo), - 'archive', '--prefix=%s/' % pin.release_name, pin.git_revision], + 'archive', f'--prefix={pin.release_name}/', pin.git_revision], stdout=subprocess.PIPE) as git: with subprocess.Popen(['xz'], stdin=git.stdout, stdout=output_file) as xz: xz.wait() @@ -503,8 +493,7 @@ def check_channel_metadata( v.result(f.read(999) == pin.git_revision) v.status( - 'Verifying version-suffix is a suffix of release name %s:' % - pin.release_name) + f'Verifying version-suffix is a suffix of release name {pin.release_name}:') with open(os.path.join(channel_contents, pin.release_name, '.version-suffix'), encoding='utf-8') as f: version_suffix = f.read(999) @@ -547,8 +536,7 @@ def git_revision_name( git_revision], stdout=subprocess.PIPE) v.result(process.returncode == 0 and process.stdout != b'') - return '%s-%s' % (os.path.basename(channel.git_repo), - process.stdout.decode().strip()) + return f'{os.path.basename(channel.git_repo)}-{process.stdout.decode().strip()}' K = TypeVar('K') @@ -594,8 +582,7 @@ def read_pinned_config_section( sp, pin = read_config_section(conf) if pin is None: raise Exception( - 'Cannot update unpinned channel "%s" (Run "pin" before "update")' % - section) + f'Cannot update unpinned channel "{section}" (Run "pin" before "update")') return sp, pin @@ -613,7 +600,7 @@ def read_config_files( config = read_config(file) for section in config.sections(): if section in merged_config: - raise Exception('Duplicate channel "%s"' % section) + raise Exception('Duplicate channel "{section}"') merged_config[section] = config[section] return merged_config @@ -652,11 +639,11 @@ def updateCommand(args: argparse.Namespace) -> None: 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)]) + search_paths.extend( + ["-I", f"pinch_tarball_for_{pin.release_name}={tarball}"]) exprs[section] = ( - 'f: f { name = "%s"; channelName = "%%s"; src = builtins.storePath "%s"; }' % - (pin.release_name, tarball)) + f'f: f {{ name = "{pin.release_name}"; channelName = "%s"; ' + f'src = builtins.storePath "{tarball}"; }}') for section, (sp, pin) in alias.items(): assert isinstance(sp, AliasSearchPath) # For mypy @@ -691,7 +678,7 @@ def main() -> None: parser_update = subparsers.add_parser('update') parser_update.add_argument('--dry-run', action='store_true') parser_update.add_argument('--profile', default=( - '/nix/var/nix/profiles/per-user/%s/channels' % getpass.getuser())) + f'/nix/var/nix/profiles/per-user/{getpass.getuser()}/channels')) parser_update.add_argument('channels_file', type=str, nargs='+') parser_update.set_defaults(func=updateCommand) args = parser.parse_args() -- 2.50.1 From 9e4ad8905fad1963badf6e7ff46d299e2128058f Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Fri, 15 Apr 2022 23:48:02 -0700 Subject: [PATCH 042/100] Appease new pylint --- pinch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pinch.py b/pinch.py index e3c7ca0..a66a03a 100644 --- a/pinch.py +++ b/pinch.py @@ -572,7 +572,7 @@ def read_config_section( _, all_fields = filter_dict(dict(conf.items()), set(['type'])) pin_fields, remaining_fields = filter_dict(all_fields, set(P._fields)) # Error suppression works around https://github.com/python/mypy/issues/9007 - pin_present = pin_fields != {} or P._fields == () + pin_present = pin_fields or P._fields == () pin = P(**pin_fields) if pin_present else None # type: ignore return SP(**remaining_fields), pin -- 2.50.1 From efc59d864dcb496bc44e4e1830230ddd096f596f Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Fri, 15 Apr 2022 23:49:44 -0700 Subject: [PATCH 043/100] git-cache: New fetch URL --- Changelog | 1 + default.nix | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Changelog b/Changelog index 8a85e24..8b09b56 100644 --- a/Changelog +++ b/Changelog @@ -1,6 +1,7 @@ ## [Unreleased] ### Fixed - Fix tests after restricted mode support update +- Fix git-cache fetch URL ## [3.0.7] - 2022-02-01 diff --git a/default.nix b/default.nix index a8f4de6..2f0a689 100644 --- a/default.nix +++ b/default.nix @@ -24,7 +24,7 @@ let pname = "git-cache"; version = "1.4.1"; src = fetchgit { - url = "https://scottworley.com/git-cache.git"; + url = "https://git.scottworley.com/pub/git/git-cache"; rev = "v${version}"; sha256 = "0ml1myhmd9mw1z5bwni9fhvx7h9dknhmqq4nyci9n5lvrhbmcdc9"; }; -- 2.50.1 From ed0517bb28862e635f8526d4c08ef1e5e808d37d Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Fri, 15 Apr 2022 23:56:00 -0700 Subject: [PATCH 044/100] Release 3.0.8 --- Changelog | 3 +++ default.nix | 2 +- setup.py | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index 8b09b56..267914d 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,7 @@ ## [Unreleased] + + +## [3.0.8] - 2022-04-15 ### Fixed - Fix tests after restricted mode support update - Fix git-cache fetch URL diff --git a/default.nix b/default.nix index 2f0a689..5608be6 100644 --- a/default.nix +++ b/default.nix @@ -38,7 +38,7 @@ in pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix_2_3, git , autopep8, makeWrapper, mypy, pylint, git-cache, }: buildPythonPackage rec { pname = "pinch"; - version = "3.0.8-pre"; + version = "3.0.8"; src = lib.cleanSource ./.; buildInputs = [ makeWrapper ]; propagatedBuildInputs = [ git-cache ]; diff --git a/setup.py b/setup.py index ceb7706..6ed20b6 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup setup( name='pinch', - version='3.0.8-pre', + version='3.0.8', py_modules=['pinch'], entry_points={'console_scripts': ['pinch = pinch:main']}, dependency_links=['https://scottworley.com/git/git-cache'], -- 2.50.1 From 71848ed255ce6d76acb202186db811555b3a4b44 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Sat, 16 Apr 2022 00:23:15 -0700 Subject: [PATCH 045/100] Start on 3.0.9 --- default.nix | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/default.nix b/default.nix index 5608be6..0c56fe4 100644 --- a/default.nix +++ b/default.nix @@ -38,7 +38,7 @@ in pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix_2_3, git , autopep8, makeWrapper, mypy, pylint, git-cache, }: buildPythonPackage rec { pname = "pinch"; - version = "3.0.8"; + version = "3.0.9-pre"; src = lib.cleanSource ./.; buildInputs = [ makeWrapper ]; propagatedBuildInputs = [ git-cache ]; diff --git a/setup.py b/setup.py index 6ed20b6..8dc59a2 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup setup( name='pinch', - version='3.0.8', + version='3.0.9-pre', py_modules=['pinch'], entry_points={'console_scripts': ['pinch = pinch:main']}, dependency_links=['https://scottworley.com/git/git-cache'], -- 2.50.1 From 3111c7ce81572ff03d4dbfad7889d11d66541e27 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Sat, 16 Apr 2022 00:23:26 -0700 Subject: [PATCH 046/100] Make the tests indifferent about user channels --- Changelog | 4 +++- tests/alias.sh | 2 +- tests/core.sh | 2 +- tests/multi-update.sh | 2 +- tests/pin-twice.sh | 2 +- tests/symlink.sh | 2 +- 6 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Changelog b/Changelog index 267914d..a1a1fcc 100644 --- a/Changelog +++ b/Changelog @@ -1,9 +1,11 @@ ## [Unreleased] +### Fixed +- Really fix tests after restricted mode support update, whether or not the user has channels. ## [3.0.8] - 2022-04-15 ### Fixed -- Fix tests after restricted mode support update +- Fix tests after restricted mode support update (Actually: break them worse) - Fix git-cache fetch URL diff --git a/tests/alias.sh b/tests/alias.sh index de54e3d..bf83c18 100755 --- a/tests/alias.sh +++ b/tests/alias.sh @@ -14,7 +14,7 @@ python3 ./pinch.py pin "$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 '\'''\'' --install --remove-all -I pinch_profile=/nix/var/nix/profiles/per-user/[^/]+/channels -I pinch_profile_manifest=/nix/store/.{32}-env-manifest.nix -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"; \}'\''$' +expected_env_command_RE='^nix-env --profile /nix/var/nix/profiles/per-user/[^/]+/channels --show-trace --file '\'''\'' --install --remove-all (-I pinch_profile=/nix/var/nix/profiles/per-user/[^/]+/channels -I pinch_profile_manifest=/nix/store/.{32}-env-manifest.nix )?-I pinch_tarball_for_(repo-[0-9]{10}-[0-9a-f]{11})=('"$NIX_STORE_DIR"'/.{32}-\2.tar.xz) --from-expression '\''f: f \{ name = "\2"; channelName = "bar"; src = builtins.storePath "\3"; \}'\'' '\''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 diff --git a/tests/core.sh b/tests/core.sh index 1c857f4..b0721df 100755 --- a/tests/core.sh +++ b/tests/core.sh @@ -8,7 +8,7 @@ python3 ./pinch.py pin "$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 '\'''\'' --install --remove-all -I pinch_profile=/nix/var/nix/profiles/per-user/[^/]+/channels -I pinch_profile_manifest=/nix/store/.{32}-env-manifest.nix -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"; \}'\''$' +expected_env_command_RE='^nix-env --profile /nix/var/nix/profiles/per-user/[^/]+/channels --show-trace --file '\'''\'' --install --remove-all (-I pinch_profile=/nix/var/nix/profiles/per-user/[^/]+/channels -I pinch_profile_manifest=/nix/store/.{32}-env-manifest.nix )?-I pinch_tarball_for_(repo-[0-9]{10}-[0-9a-f]{11})=('"$NIX_STORE_DIR"'/.{32}-\2.tar.xz) --from-expression '\''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 diff --git a/tests/multi-update.sh b/tests/multi-update.sh index 52c59c8..5d191ec 100755 --- a/tests/multi-update.sh +++ b/tests/multi-update.sh @@ -18,7 +18,7 @@ actual_env_command=`python3 ./pinch.py update --dry-run "$conf" "$conf2"` rm -rf "$conf2" -expected_env_command_RE='^nix-env --profile /nix/var/nix/profiles/per-user/[^/]+/channels --show-trace --file '\'''\'' --install --remove-all -I pinch_profile=/nix/var/nix/profiles/per-user/[^/]+/channels -I pinch_profile_manifest=/nix/store/.{32}-env-manifest.nix -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"; \}'\''$' +expected_env_command_RE='^nix-env --profile /nix/var/nix/profiles/per-user/[^/]+/channels --show-trace --file '\'''\'' --install --remove-all (-I pinch_profile=/nix/var/nix/profiles/per-user/[^/]+/channels -I pinch_profile_manifest=/nix/store/.{32}-env-manifest.nix )?-I pinch_tarball_for_(repo-[0-9]{10}-[0-9a-f]{11})=('"$NIX_STORE_DIR"'/.{32}-\2.tar.xz) --from-expression '\''f: f \{ name = "\2"; channelName = "bar"; src = builtins.storePath "\3"; \}'\'' '\''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 diff --git a/tests/pin-twice.sh b/tests/pin-twice.sh index 7730bd6..fda548b 100755 --- a/tests/pin-twice.sh +++ b/tests/pin-twice.sh @@ -17,7 +17,7 @@ python3 ./pinch.py pin "$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 '\'''\'' --install --remove-all -I pinch_profile=/nix/var/nix/profiles/per-user/[^/]+/channels -I pinch_profile_manifest=/nix/store/.{32}-env-manifest.nix -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"; \}'\''$' +expected_env_command_RE='^nix-env --profile /nix/var/nix/profiles/per-user/[^/]+/channels --show-trace --file '\'''\'' --install --remove-all (-I pinch_profile=/nix/var/nix/profiles/per-user/[^/]+/channels -I pinch_profile_manifest=/nix/store/.{32}-env-manifest.nix )?-I pinch_tarball_for_(repo-[0-9]{10}-[0-9a-f]{11})=('"$NIX_STORE_DIR"'/.{32}-\2.tar.xz) --from-expression '\''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 diff --git a/tests/symlink.sh b/tests/symlink.sh index 36e9c24..8b59794 100755 --- a/tests/symlink.sh +++ b/tests/symlink.sh @@ -14,7 +14,7 @@ python3 ./pinch.py pin "$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 '\'''\'' --install --remove-all -I pinch_profile=/nix/var/nix/profiles/per-user/[^/]+/channels -I pinch_profile_manifest=/nix/store/.{32}-env-manifest.nix -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"; \}'\''$' +expected_env_command_RE='^nix-env --profile /nix/var/nix/profiles/per-user/[^/]+/channels --show-trace --file '\'''\'' --install --remove-all (-I pinch_profile=/nix/var/nix/profiles/per-user/[^/]+/channels -I pinch_profile_manifest=/nix/store/.{32}-env-manifest.nix )?-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}-\3.tar.xz) --from-expression '\''f: f \{ name = "link"; channelName = "bar"; src = builtins.storePath "\2"; \}'\'' '\''f: f \{ name = "\3"; channelName = "foo"; src = builtins.storePath "\4"; \}'\''$' if echo "$actual_env_command" | egrep "$expected_env_command_RE" > /dev/null;then echo PASS -- 2.50.1 From 86666a85eaeea98a38e0cbae449ddce1a8866225 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Sat, 16 Apr 2022 00:27:15 -0700 Subject: [PATCH 047/100] Release 3.0.9 --- Changelog | 3 +++ default.nix | 2 +- setup.py | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index a1a1fcc..c0c066a 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,7 @@ ## [Unreleased] + + +## [3.0.9] - 2022-04-16 ### Fixed - Really fix tests after restricted mode support update, whether or not the user has channels. diff --git a/default.nix b/default.nix index 0c56fe4..518a2dc 100644 --- a/default.nix +++ b/default.nix @@ -38,7 +38,7 @@ in pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix_2_3, git , autopep8, makeWrapper, mypy, pylint, git-cache, }: buildPythonPackage rec { pname = "pinch"; - version = "3.0.9-pre"; + version = "3.0.9"; src = lib.cleanSource ./.; buildInputs = [ makeWrapper ]; propagatedBuildInputs = [ git-cache ]; diff --git a/setup.py b/setup.py index 8dc59a2..61bebef 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup setup( name='pinch', - version='3.0.9-pre', + version='3.0.9', py_modules=['pinch'], entry_points={'console_scripts': ['pinch = pinch:main']}, dependency_links=['https://scottworley.com/git/git-cache'], -- 2.50.1 From 86917026d1c2fb545c7f438cbc31bb85e4a5d520 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Wed, 23 Nov 2022 01:12:53 -0800 Subject: [PATCH 048/100] Start on 3.0.10 --- default.nix | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/default.nix b/default.nix index 518a2dc..aae7f13 100644 --- a/default.nix +++ b/default.nix @@ -38,7 +38,7 @@ in pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix_2_3, git , autopep8, makeWrapper, mypy, pylint, git-cache, }: buildPythonPackage rec { pname = "pinch"; - version = "3.0.9"; + version = "3.0.10-pre"; src = lib.cleanSource ./.; buildInputs = [ makeWrapper ]; propagatedBuildInputs = [ git-cache ]; diff --git a/setup.py b/setup.py index 61bebef..7d28c68 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup setup( name='pinch', - version='3.0.9', + version='3.0.10-pre', py_modules=['pinch'], entry_points={'console_scripts': ['pinch = pinch:main']}, dependency_links=['https://scottworley.com/git/git-cache'], -- 2.50.1 From f8305e1d95d00d2fd62b577e9193c52da2230dc8 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Sun, 28 Aug 2022 09:44:28 -0700 Subject: [PATCH 049/100] Rely on nixpkgs' python3Packages.backoff --- default.nix | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/default.nix b/default.nix index aae7f13..cc6f858 100644 --- a/default.nix +++ b/default.nix @@ -2,23 +2,6 @@ let - # Remove after https://github.com/NixOS/nixpkgs/pull/93377 reaches stable - backoff-fallback = { lib, buildPythonPackage, fetchFromGitHub, pytestCheckHook - , poetry, pytest-asyncio, }: - buildPythonPackage rec { - pname = "backoff"; - version = "1.10.0"; - src = fetchFromGitHub { - owner = "litl"; - repo = pname; - rev = "v${version}"; - sha256 = "1jj0l6pjx747d2yyvnzd3qbm4qr73sq6cc56dhvd8wqfbp5279x0"; - }; - format = "pyproject"; - nativeBuildInputs = [ poetry ]; - checkInputs = [ pytestCheckHook pytest-asyncio ]; - }; - git-cache-fallback = { buildPythonPackage, fetchgit, git, backoff, mypy, }: buildPythonPackage rec { pname = "git-cache"; @@ -51,10 +34,6 @@ in pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix_2_3, git }) { git-cache = pkgs.python3Packages.git-cache or (pkgs.python3Packages.callPackage - git-cache-fallback { - backoff = - pkgs.python3Packages.backoff or (pkgs.python3Packages.callPackage - backoff-fallback { }); - }); + git-cache-fallback { }); nix_2_3 = pkgs.nix_2_3 or pkgs.nix; } -- 2.50.1 From 2ff7a17c1533ac49b6c55a13ad74bdd78d00649e Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Tue, 22 Nov 2022 23:38:40 -0800 Subject: [PATCH 050/100] README is markdown --- README => README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename README => README.md (97%) diff --git a/README b/README.md similarity index 97% rename from README rename to README.md index 80dcdce..acf6269 100644 --- a/README +++ b/README.md @@ -1,6 +1,6 @@ # Deprecated -Now that [flakes][https://nixos.wiki/wiki/Flakes] are more or less ready for +Now that [flakes](https://nixos.wiki/wiki/Flakes) are more or less ready for general use, this is mostly of historical interest. -- 2.50.1 From 75076e7da897635c486c47b1c741190e5e54656d Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Wed, 23 Nov 2022 01:16:00 -0800 Subject: [PATCH 051/100] fallback git-cache 1.4.1 -> 1.4.2 --- default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/default.nix b/default.nix index cc6f858..31a6398 100644 --- a/default.nix +++ b/default.nix @@ -5,11 +5,11 @@ let git-cache-fallback = { buildPythonPackage, fetchgit, git, backoff, mypy, }: buildPythonPackage rec { pname = "git-cache"; - version = "1.4.1"; + version = "1.4.2"; src = fetchgit { url = "https://git.scottworley.com/pub/git/git-cache"; rev = "v${version}"; - sha256 = "0ml1myhmd9mw1z5bwni9fhvx7h9dknhmqq4nyci9n5lvrhbmcdc9"; + hash = "sha256-Z9daNCmjzaVdeG3mITRWdNM+ewUEcKy5N4/Xpdotsg0="; }; propagatedBuildInputs = [ backoff ]; checkInputs = [ git mypy ]; -- 2.50.1 From df45b0111f016d06c4951c6df91359b6b9a15589 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Wed, 23 Nov 2022 01:18:27 -0800 Subject: [PATCH 052/100] Release 3.0.10 --- Changelog | 5 +++++ default.nix | 2 +- setup.py | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index c0c066a..dab8eb6 100644 --- a/Changelog +++ b/Changelog @@ -1,6 +1,11 @@ ## [Unreleased] +## [3.0.10] - 2022-11-23 +### Changed +- Small cleanups + + ## [3.0.9] - 2022-04-16 ### Fixed - Really fix tests after restricted mode support update, whether or not the user has channels. diff --git a/default.nix b/default.nix index 31a6398..7744281 100644 --- a/default.nix +++ b/default.nix @@ -21,7 +21,7 @@ in pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix_2_3, git , autopep8, makeWrapper, mypy, pylint, git-cache, }: buildPythonPackage rec { pname = "pinch"; - version = "3.0.10-pre"; + version = "3.0.10"; src = lib.cleanSource ./.; buildInputs = [ makeWrapper ]; propagatedBuildInputs = [ git-cache ]; diff --git a/setup.py b/setup.py index 7d28c68..57fc3b9 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup setup( name='pinch', - version='3.0.10-pre', + version='3.0.10', py_modules=['pinch'], entry_points={'console_scripts': ['pinch = pinch:main']}, dependency_links=['https://scottworley.com/git/git-cache'], -- 2.50.1 From 05a3d87bd6dfd31c10f42c04ccc57f2e480c47f3 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Wed, 23 Nov 2022 18:20:38 -0800 Subject: [PATCH 053/100] Specify license --- Changelog | 2 ++ default.nix | 6 ++++++ pinch.py | 7 +++++++ setup.py | 5 +++++ 4 files changed, 20 insertions(+) diff --git a/Changelog b/Changelog index dab8eb6..75e6be8 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,6 @@ ## [Unreleased] +### Changed +- Specify license ## [3.0.10] - 2022-11-23 diff --git a/default.nix b/default.nix index 7744281..e62e1d3 100644 --- a/default.nix +++ b/default.nix @@ -31,6 +31,12 @@ in pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix_2_3, git ''; doCheck = true; checkPhase = "./test.sh"; + meta = { + description = "A replacement for `nix-channel --update`"; + homepage = "https://git.scottworley.com/pinc"; + license = pkgs.lib.licenses.gpl3; + maintainers = with pkgs.lib.maintainers; [ chkno ]; + }; }) { git-cache = pkgs.python3Packages.git-cache or (pkgs.python3Packages.callPackage diff --git a/pinch.py b/pinch.py index a66a03a..89d6f61 100644 --- a/pinch.py +++ b/pinch.py @@ -1,3 +1,10 @@ +# pinch: PIN CHannels - a replacement for `nix-channel --update` +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation, version 3. + + import argparse import configparser import filecmp diff --git a/setup.py b/setup.py index 57fc3b9..baf4f03 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,12 @@ from setuptools import setup setup( name='pinch', version='3.0.10', + description="Cache git content locally", + author="Scott Worley", + author_email="scottworley@scottworley.com", + url="https://git.scottworley.com/git-cache", py_modules=['pinch'], + license="GPL-3.0", entry_points={'console_scripts': ['pinch = pinch:main']}, dependency_links=['https://scottworley.com/git/git-cache'], ) -- 2.50.1 From f10d09382c13b2510e3f723b6f05c3cf38d61a11 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Sat, 10 Dec 2022 00:02:11 -0800 Subject: [PATCH 054/100] Fix homepage URL --- default.nix | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/default.nix b/default.nix index e62e1d3..94f525b 100644 --- a/default.nix +++ b/default.nix @@ -33,7 +33,7 @@ in pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix_2_3, git checkPhase = "./test.sh"; meta = { description = "A replacement for `nix-channel --update`"; - homepage = "https://git.scottworley.com/pinc"; + homepage = "https://git.scottworley.com/pinch"; license = pkgs.lib.licenses.gpl3; maintainers = with pkgs.lib.maintainers; [ chkno ]; }; diff --git a/setup.py b/setup.py index baf4f03..88931dc 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ setup( description="Cache git content locally", author="Scott Worley", author_email="scottworley@scottworley.com", - url="https://git.scottworley.com/git-cache", + url="https://git.scottworley.com/pinch", py_modules=['pinch'], license="GPL-3.0", entry_points={'console_scripts': ['pinch = pinch:main']}, -- 2.50.1 From d5abffb3c868e3cf98e565a1e158eeaa333292d1 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Wed, 24 May 2023 18:56:11 -0700 Subject: [PATCH 055/100] pylint dropped 'no-self-use', so we don't need to / can't disable it anymore --- Changelog | 1 + pinch.py | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/Changelog b/Changelog index 75e6be8..04b4bd9 100644 --- a/Changelog +++ b/Changelog @@ -1,6 +1,7 @@ ## [Unreleased] ### Changed - Specify license +- Dropped "pylint: disable=no-self-use" ## [3.0.10] - 2022-11-23 diff --git a/pinch.py b/pinch.py index 89d6f61..bc9ba3b 100644 --- a/pinch.py +++ b/pinch.py @@ -148,7 +148,6 @@ def symlink_archive(v: Verification, path: str) -> str: class AliasSearchPath(NamedTuple): alias_of: str - # pylint: disable=no-self-use def pin(self, _: Verification, __: Optional[Pin]) -> AliasPin: return AliasPin() @@ -156,7 +155,6 @@ class AliasSearchPath(NamedTuple): class SymlinkSearchPath(NamedTuple): path: str - # pylint: disable=no-self-use def pin(self, _: Verification, __: Optional[Pin]) -> SymlinkPin: return SymlinkPin() @@ -209,7 +207,6 @@ class ChannelSearchPath(NamedTuple): tarball_sha256=table['nixexprs.tar.xz'].digest, git_revision=new_gitpin.git_revision) - # pylint: disable=no-self-use def fetch(self, v: Verification, pin: Pin) -> str: assert isinstance(pin, ChannelPin) -- 2.50.1 From ae63e97430175267f8177a7c7d4a5325eaea929e Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Wed, 24 May 2023 18:58:39 -0700 Subject: [PATCH 056/100] Adapt to nixpkgs' nativeCheckInputs change nixpkgs commit f39abbc3500451fc00c80fed71b0f6f7bba8b6a4, first released in 23.05, requires that everyone move their checkInputs to nativeCheckInputs. To build both before and after this change, we detect whether we're before or after this change by reading the manual & behave appropriately. :/ --- Changelog | 1 + default.nix | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index 04b4bd9..167f16f 100644 --- a/Changelog +++ b/Changelog @@ -2,6 +2,7 @@ ### Changed - Specify license - Dropped "pylint: disable=no-self-use" +- Adapt to nixpkgs nativeCheckInputs change ## [3.0.10] - 2022-11-23 diff --git a/default.nix b/default.nix index 94f525b..caebd9c 100644 --- a/default.nix +++ b/default.nix @@ -1,6 +1,10 @@ { pkgs ? import { }, lint ? false }: let + checkInputsAreNative = pkgs.lib.hasInfix "nativeCheckInputs" + (builtins.readFile ); + checkInputsName = + if checkInputsAreNative then "nativeCheckInputs" else "checkInputs"; git-cache-fallback = { buildPythonPackage, fetchgit, git, backoff, mypy, }: buildPythonPackage rec { @@ -12,7 +16,7 @@ let hash = "sha256-Z9daNCmjzaVdeG3mITRWdNM+ewUEcKy5N4/Xpdotsg0="; }; propagatedBuildInputs = [ backoff ]; - checkInputs = [ git mypy ]; + "${checkInputsName}" = [ git mypy ]; doCheck = true; checkPhase = "./test.sh"; }; @@ -25,7 +29,8 @@ in pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix_2_3, git src = lib.cleanSource ./.; buildInputs = [ makeWrapper ]; propagatedBuildInputs = [ git-cache ]; - checkInputs = [ nix_2_3 git mypy ] ++ lib.optionals lint [ autopep8 pylint ]; + "${checkInputsName}" = [ nix_2_3 git mypy ] + ++ lib.optionals lint [ autopep8 pylint ]; postInstall = '' wrapProgram "$out/bin/pinch" --prefix PATH : ${nix_2_3}/bin ''; -- 2.50.1 From 98da2ae68fd2cb6141eee23c0ecf401971036d56 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Wed, 24 May 2023 19:00:24 -0700 Subject: [PATCH 057/100] fallback git-cache 1.4.2 -> 1.4.3 --- default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/default.nix b/default.nix index caebd9c..8812eee 100644 --- a/default.nix +++ b/default.nix @@ -9,11 +9,11 @@ let git-cache-fallback = { buildPythonPackage, fetchgit, git, backoff, mypy, }: buildPythonPackage rec { pname = "git-cache"; - version = "1.4.2"; + version = "1.4.3"; src = fetchgit { url = "https://git.scottworley.com/pub/git/git-cache"; rev = "v${version}"; - hash = "sha256-Z9daNCmjzaVdeG3mITRWdNM+ewUEcKy5N4/Xpdotsg0="; + hash = "sha256-Qr62bGdlFFkzYTl6ot34UiOJxbP1Eeelx2OEd96vrqI="; }; propagatedBuildInputs = [ backoff ]; "${checkInputsName}" = [ git mypy ]; -- 2.50.1 From 5c37f57d00651bde2fa1d80e8eb1ecb2e76f50db Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Wed, 24 May 2023 19:02:16 -0700 Subject: [PATCH 058/100] Release 3.0.11 --- Changelog | 3 +++ default.nix | 2 +- setup.py | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index 167f16f..77564f3 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,7 @@ ## [Unreleased] + + +## [3.0.11] - 2023-05-24 ### Changed - Specify license - Dropped "pylint: disable=no-self-use" diff --git a/default.nix b/default.nix index 8812eee..e9cf252 100644 --- a/default.nix +++ b/default.nix @@ -25,7 +25,7 @@ in pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix_2_3, git , autopep8, makeWrapper, mypy, pylint, git-cache, }: buildPythonPackage rec { pname = "pinch"; - version = "3.0.10"; + version = "3.0.11"; src = lib.cleanSource ./.; buildInputs = [ makeWrapper ]; propagatedBuildInputs = [ git-cache ]; diff --git a/setup.py b/setup.py index 88931dc..5e71635 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup setup( name='pinch', - version='3.0.10', + version='3.0.11', description="Cache git content locally", author="Scott Worley", author_email="scottworley@scottworley.com", -- 2.50.1 From 1bbb7e2e23ccd9f34e0d1a52bdcda657b83f757a Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Thu, 7 Sep 2023 13:29:30 -0700 Subject: [PATCH 059/100] Start on 3.0.12 --- default.nix | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/default.nix b/default.nix index e9cf252..d397854 100644 --- a/default.nix +++ b/default.nix @@ -25,7 +25,7 @@ in pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix_2_3, git , autopep8, makeWrapper, mypy, pylint, git-cache, }: buildPythonPackage rec { pname = "pinch"; - version = "3.0.11"; + version = "3.0.12-pre"; src = lib.cleanSource ./.; buildInputs = [ makeWrapper ]; propagatedBuildInputs = [ git-cache ]; diff --git a/setup.py b/setup.py index 5e71635..a85a8fc 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup setup( name='pinch', - version='3.0.11', + version='3.0.12-pre', description="Cache git content locally", author="Scott Worley", author_email="scottworley@scottworley.com", -- 2.50.1 From 352cba96de3b4cd138ead4a765756fb169f40fe5 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Thu, 7 Sep 2023 13:36:18 -0700 Subject: [PATCH 060/100] Appease new pylint --- pinch.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pinch.py b/pinch.py index bc9ba3b..5eb107b 100644 --- a/pinch.py +++ b/pinch.py @@ -585,7 +585,7 @@ def read_pinned_config_section( section: str, conf: configparser.SectionProxy) -> Tuple[SearchPath, Pin]: sp, pin = read_config_section(conf) if pin is None: - raise Exception( + raise RuntimeError( f'Cannot update unpinned channel "{section}" (Run "pin" before "update")') return sp, pin @@ -604,7 +604,7 @@ def read_config_files( config = read_config(file) for section in config.sections(): if section in merged_config: - raise Exception('Duplicate channel "{section}"') + raise RuntimeError('Duplicate channel "{section}"') merged_config[section] = config[section] return merged_config -- 2.50.1 From ee11f936d4f2ce49965c18c2d9837fe98dd614b7 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Thu, 7 Sep 2023 13:36:46 -0700 Subject: [PATCH 061/100] Show which files are unexpectedly incomparable --- Changelog | 2 ++ pinch.py | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Changelog b/Changelog index 77564f3..0f13a44 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,6 @@ ## [Unreleased] +### Changed +- Show which files are unexpectedly incomparable ## [3.0.11] - 2023-05-24 diff --git a/pinch.py b/pinch.py index 5eb107b..6beb4e2 100644 --- a/pinch.py +++ b/pinch.py @@ -422,7 +422,9 @@ def compare_tarball_and_git( if ee in errors: errors.remove(ee) benign_errors.append(ee) - v.check(f'{len(errors)} unexpected incomparable files', len(errors) == 0) + v.check( + f'{len(errors)} unexpected incomparable files: {errors}', + len(errors) == 0) v.check( f'({len(benign_errors)} of {len(expected_errors)} expected incomparable files)', len(benign_errors) == len(expected_errors)) -- 2.50.1 From 5d0f42f73f77c1e64f11244dc7ddc5b75f08f038 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Thu, 7 Sep 2023 13:41:07 -0700 Subject: [PATCH 062/100] Allow nixpkgs' new intentionally-invalid symlink --- Changelog | 1 + pinch.py | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Changelog b/Changelog index 0f13a44..fdcf9b7 100644 --- a/Changelog +++ b/Changelog @@ -1,6 +1,7 @@ ## [Unreleased] ### Changed - Show which files are unexpectedly incomparable +- Allow nixpkgs' new intentionally-invalid symlink ## [3.0.11] - 2023-05-24 diff --git a/pinch.py b/pinch.py index 6beb4e2..33fd9bf 100644 --- a/pinch.py +++ b/pinch.py @@ -417,17 +417,28 @@ def compare_tarball_and_git( 'nixpkgs', 'programs.sqlite', 'svn-revision'] - benign_errors = [] + permitted_errors = [ + 'pkgs/test/nixpkgs-check-by-name/tests/symlink-invalid/pkgs/by-name/fo/foo/foo.nix', + ] + benign_expected_errors = [] + benign_permitted_errors = [] for ee in expected_errors: if ee in errors: errors.remove(ee) - benign_errors.append(ee) + benign_expected_errors.append(ee) + for pe in permitted_errors: + if pe in errors: + errors.remove(pe) + benign_permitted_errors.append(ee) v.check( f'{len(errors)} unexpected incomparable files: {errors}', len(errors) == 0) v.check( - f'({len(benign_errors)} of {len(expected_errors)} expected incomparable files)', - len(benign_errors) == len(expected_errors)) + f'({len(benign_expected_errors)} of {len(expected_errors)} expected incomparable files)', + len(benign_expected_errors) == len(expected_errors)) + v.check( + f'({len(benign_permitted_errors)} of {len(permitted_errors)} permitted incomparable files)', + len(benign_permitted_errors) <= len(permitted_errors)) def extract_tarball( -- 2.50.1 From cf837bc8ca10ada6ef814ce6f8eac7876b2c0a29 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Thu, 7 Sep 2023 13:54:43 -0700 Subject: [PATCH 063/100] Release 3.0.12 --- Changelog | 3 +++ default.nix | 2 +- setup.py | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index fdcf9b7..de8466d 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,7 @@ ## [Unreleased] + + +## [3.0.12] - 2023-09-07 ### Changed - Show which files are unexpectedly incomparable - Allow nixpkgs' new intentionally-invalid symlink diff --git a/default.nix b/default.nix index d397854..00ddac9 100644 --- a/default.nix +++ b/default.nix @@ -25,7 +25,7 @@ in pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix_2_3, git , autopep8, makeWrapper, mypy, pylint, git-cache, }: buildPythonPackage rec { pname = "pinch"; - version = "3.0.12-pre"; + version = "3.0.12"; src = lib.cleanSource ./.; buildInputs = [ makeWrapper ]; propagatedBuildInputs = [ git-cache ]; diff --git a/setup.py b/setup.py index a85a8fc..9466e35 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup setup( name='pinch', - version='3.0.12-pre', + version='3.0.12', description="Cache git content locally", author="Scott Worley", author_email="scottworley@scottworley.com", -- 2.50.1 From d8e3190241be14f3f6ef78b936386544157a2a2c Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Thu, 7 Dec 2023 19:25:30 -0800 Subject: [PATCH 064/100] Start on 3.0.13 --- default.nix | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/default.nix b/default.nix index 00ddac9..352bd1f 100644 --- a/default.nix +++ b/default.nix @@ -25,7 +25,7 @@ in pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix_2_3, git , autopep8, makeWrapper, mypy, pylint, git-cache, }: buildPythonPackage rec { pname = "pinch"; - version = "3.0.12"; + version = "3.0.13-pre"; src = lib.cleanSource ./.; buildInputs = [ makeWrapper ]; propagatedBuildInputs = [ git-cache ]; diff --git a/setup.py b/setup.py index 9466e35..08ad174 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup setup( name='pinch', - version='3.0.12', + version='3.0.13-pre', description="Cache git content locally", author="Scott Worley", author_email="scottworley@scottworley.com", -- 2.50.1 From b573564a47adba410749d11f28efd2a84d564bbf Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Thu, 7 Dec 2023 19:29:26 -0800 Subject: [PATCH 065/100] Tidy Changelog The Added/Changed/Fixed headers weren't helpful. --- Changelog | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/Changelog b/Changelog index de8466d..ca55e07 100644 --- a/Changelog +++ b/Changelog @@ -1,42 +1,36 @@ ## [Unreleased] +- Cleaned up changelog ## [3.0.12] - 2023-09-07 -### Changed - Show which files are unexpectedly incomparable - Allow nixpkgs' new intentionally-invalid symlink ## [3.0.11] - 2023-05-24 -### Changed - Specify license - Dropped "pylint: disable=no-self-use" - Adapt to nixpkgs nativeCheckInputs change ## [3.0.10] - 2022-11-23 -### Changed - Small cleanups ## [3.0.9] - 2022-04-16 -### Fixed - Really fix tests after restricted mode support update, whether or not the user has channels. ## [3.0.8] - 2022-04-15 -### Fixed - Fix tests after restricted mode support update (Actually: break them worse) - Fix git-cache fetch URL ## [3.0.7] - 2022-02-01 -### Changed - Don't leave old channels laying around ## [3.0.6] - 2022-01-19 -### Changed - Deprecate pinch. - Show the channel URL being fetched. - Use nix 2.3 because 2.4 broke . @@ -45,63 +39,50 @@ ## [3.0.5] - 2021-07-09 -### Changed - Show filename being hashed. Helps find nix store corruption. ## [3.0.4] - 2021-06-07 -### Changed - Use nix from nixpkgs rather than from PATH. This is needed when the nix in PATH is nixUnstable-3.0pre20201020_e0ca98c or later because nix commit 787469c7b66aec12ab6847e7db2cdc8aef5c325e removed . ## [3.0.3] - 2021-05-20 -### Changed - Don't pass --experimental-features to old nix versions ## [3.0.2] - 2021-02-16 -### Changed - Don't rely on experimental-features=nix-command in system nix.conf ## [3.0.1] - 2020-08-04 -### Changed - Make tests fast again when using recent git-cache with backoff ## [3.0.0] - 2020-07-10 -### Changed - Moved git cache out to a separate library ## [2.1.1] - 2020-07-01 -### Changed - Pin faster: Skip archive comparison if git rev is unchanged ## [2.1.0] - 2020-06-30 -### Added -- Specify profile path with --profile +- Allow specifying profile path with --profile ## [2.0.0] - 2020-06-17 -### Changed - Config sections must now specify their type explicitly - -### Added -- type=symlink search paths +- Added type=symlink search paths ## [1.5.1] - 2020-06-17 -### Fixed - Support old mypy version 0.701 (by working around its bugs) - Version numbers are now semver ## [1.5] - 2020-06-12 -### Fixed - Support log.showSignature -- 2.50.1 From e99a249b5598677db990e0943a214bb0bbd9b68e Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Thu, 7 Dec 2023 19:31:09 -0800 Subject: [PATCH 066/100] Fix nested-git issues in pre-commit hook This has been wonky before (eg: 'git add foo; git commit' would work while 'git commit foo' would not), but between 2.40.1 and 2.42.0 something about git changed such that the pre-commit completely stopped working. So now we properly clean the tests' git invocations' environment. --- Changelog | 1 + git-pre-commit-hook | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/Changelog b/Changelog index ca55e07..4dce10e 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ ## [Unreleased] +- Fixed nested-git issues in pre-commit hook - Cleaned up changelog diff --git a/git-pre-commit-hook b/git-pre-commit-hook index 85b4445..ce47614 100755 --- a/git-pre-commit-hook +++ b/git-pre-commit-hook @@ -17,6 +17,16 @@ D=$(mktemp -d) git checkout-index --prefix="$D/" -a pushd "$D" +# So we don't confuse the inner git invocations inside the tests with +# the outer git invocation that's trying to commit a change. +unset GIT_AUTHOR_DATE +unset GIT_AUTHOR_EMAIL +unset GIT_AUTHOR_NAME +unset GIT_CONFIG_PARAMETERS +unset GIT_EXEC_PATH +unset GIT_INDEX_FILE +unset GIT_PREFIX + nix-shell --arg lint true --run './test.sh lint' popd -- 2.50.1 From 7408d43db1bf63f41e705e5ea3fbed1275be01b8 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Thu, 7 Dec 2023 19:37:20 -0800 Subject: [PATCH 067/100] Appease new stricter minidom typechecks --- Changelog | 1 + pinch.py | 32 +++++++++++++++++++++++--------- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/Changelog b/Changelog index 4dce10e..94a5db5 100644 --- a/Changelog +++ b/Changelog @@ -1,5 +1,6 @@ ## [Unreleased] - Fixed nested-git issues in pre-commit hook +- Adapt to new, stricter minidom type checks - Cleaned up changelog diff --git a/pinch.py b/pinch.py index 33fd9bf..bda7633 100644 --- a/pinch.py +++ b/pinch.py @@ -266,15 +266,29 @@ def parse_channel(v: Verification, channel_html: str) \ d = xml.dom.minidom.parseString(channel_html) v.ok() - v.status('Extracting release name:') - title_name = d.getElementsByTagName( - 'title')[0].firstChild.nodeValue.split()[2] - h1_name = d.getElementsByTagName('h1')[0].firstChild.nodeValue.split()[2] - v.status(title_name) - v.result(title_name == h1_name) - - v.status('Extracting git commit:') + v.status('Finding release name (1)') + title = d.getElementsByTagName('title')[0].firstChild + v.result(isinstance(title, xml.dom.minidom.CharacterData)) + assert isinstance(title, xml.dom.minidom.CharacterData) + release_name = title.nodeValue.split()[2] + v.status('Finding release name (2)') + h1 = d.getElementsByTagName('h1')[0].firstChild + v.result(isinstance(h1, xml.dom.minidom.CharacterData)) + assert isinstance(h1, xml.dom.minidom.CharacterData) + v.status('Verifying release name:') + v.status(release_name) + v.result(release_name == h1.nodeValue.split()[2]) + + v.status('Finding git commit') git_commit_node = d.getElementsByTagName('tt')[0] + v.result( + isinstance( + git_commit_node.firstChild, + xml.dom.minidom.CharacterData)) + assert isinstance( + git_commit_node.firstChild, + xml.dom.minidom.CharacterData) + v.status('Extracting git commit:') git_revision = git_commit_node.firstChild.nodeValue v.status(git_revision) v.ok() @@ -290,7 +304,7 @@ def parse_channel(v: Verification, channel_html: str) \ digest = Digest16(row.childNodes[2].firstChild.firstChild.nodeValue) table[name] = ChannelTableEntry(url=url, digest=digest, size=size) v.ok() - return table, GitPin(release_name=title_name, git_revision=git_revision) + return table, GitPin(release_name=release_name, git_revision=git_revision) def digest_string(s: bytes) -> Digest16: -- 2.50.1 From 02f83340ee894eae5a661870c2af377abf8a195b Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Thu, 7 Dec 2023 19:41:36 -0800 Subject: [PATCH 068/100] Release 3.0.13 --- Changelog | 3 +++ default.nix | 2 +- setup.py | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index 94a5db5..b1f8cf1 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,7 @@ ## [Unreleased] + + +## [3.0.12] - 2023-12-07 - Fixed nested-git issues in pre-commit hook - Adapt to new, stricter minidom type checks - Cleaned up changelog diff --git a/default.nix b/default.nix index 352bd1f..655cd76 100644 --- a/default.nix +++ b/default.nix @@ -25,7 +25,7 @@ in pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix_2_3, git , autopep8, makeWrapper, mypy, pylint, git-cache, }: buildPythonPackage rec { pname = "pinch"; - version = "3.0.13-pre"; + version = "3.0.13"; src = lib.cleanSource ./.; buildInputs = [ makeWrapper ]; propagatedBuildInputs = [ git-cache ]; diff --git a/setup.py b/setup.py index 08ad174..0cf2019 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup setup( name='pinch', - version='3.0.13-pre', + version='3.0.13', description="Cache git content locally", author="Scott Worley", author_email="scottworley@scottworley.com", -- 2.50.1 From b6683b780a28c95043a8028c73a36dbceda56a8f Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Tue, 23 Jan 2024 12:59:24 -0800 Subject: [PATCH 069/100] Un-deprecate: This continues being useful --- README.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/README.md b/README.md index acf6269..181dec4 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,3 @@ -# Deprecated - -Now that [flakes](https://nixos.wiki/wiki/Flakes) are more or less ready for -general use, this is mostly of historical interest. - - # Pinch PIN CHannels - a simple drop-in replacement for `nix-channel --update`. -- 2.50.1 From 2fb219b96b7ebff700cc8ce92d4a4add16104b71 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Wed, 24 Jan 2024 18:41:17 -0800 Subject: [PATCH 070/100] Start on 3.0.14 --- default.nix | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/default.nix b/default.nix index 655cd76..9d4aa33 100644 --- a/default.nix +++ b/default.nix @@ -25,7 +25,7 @@ in pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix_2_3, git , autopep8, makeWrapper, mypy, pylint, git-cache, }: buildPythonPackage rec { pname = "pinch"; - version = "3.0.13"; + version = "3.0.14-pre"; src = lib.cleanSource ./.; buildInputs = [ makeWrapper ]; propagatedBuildInputs = [ git-cache ]; diff --git a/setup.py b/setup.py index 0cf2019..4a09ffd 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup setup( name='pinch', - version='3.0.13', + version='3.0.14-pre', description="Cache git content locally", author="Scott Worley", author_email="scottworley@scottworley.com", -- 2.50.1 From b7ef1dd6ddcede847ace6ab25fe05cf728cc6a44 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Wed, 24 Jan 2024 18:42:46 -0800 Subject: [PATCH 071/100] Allow more specific invalid symlinks At some point, we may want to just examine incomparable files & allow identically-broken symlinks, rather than explicitly list approved exceptions here. --- Changelog | 1 + pinch.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/Changelog b/Changelog index b1f8cf1..4507467 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ ## [Unreleased] +- Allow nixpkgs' additional new intentionally-invalid symlinks ## [3.0.12] - 2023-12-07 diff --git a/pinch.py b/pinch.py index bda7633..e20d5d1 100644 --- a/pinch.py +++ b/pinch.py @@ -432,6 +432,8 @@ def compare_tarball_and_git( 'programs.sqlite', 'svn-revision'] permitted_errors = [ + 'pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/pkgs/by-name/A/fo@/foo', + 'pkgs/test/nixpkgs-check-by-name/tests/symlink-invalid/pkgs/by-name/fo/foo/foo', 'pkgs/test/nixpkgs-check-by-name/tests/symlink-invalid/pkgs/by-name/fo/foo/foo.nix', ] benign_expected_errors = [] -- 2.50.1 From ac38f5a21500ad0e7fd8dac229a6dbadc9a14bfa Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Wed, 24 Jan 2024 19:18:18 -0800 Subject: [PATCH 072/100] Allow identically-broken symlinks --- Changelog | 2 +- pinch.py | 31 ++++++++++++++++--------------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/Changelog b/Changelog index 4507467..e4989b4 100644 --- a/Changelog +++ b/Changelog @@ -1,5 +1,5 @@ ## [Unreleased] -- Allow nixpkgs' additional new intentionally-invalid symlinks +- Allow identical broken symlinks ## [3.0.12] - 2023-12-07 diff --git a/pinch.py b/pinch.py index e20d5d1..9e80c01 100644 --- a/pinch.py +++ b/pinch.py @@ -414,14 +414,24 @@ def verify_git_ancestry( v.result(process.returncode == 0) +def broken_symlinks_are_identical(root1: str, root2: str, path: str) -> bool: + a = os.path.join(root1, path) + b = os.path.join(root2, path) + return (os.path.islink(a) + and os.path.islink(b) + and not os.path.exists(a) + and not os.path.exists(b) + and os.readlink(a) == os.readlink(b)) + + def compare_tarball_and_git( v: Verification, pin: GitPin, channel_contents: str, git_contents: str) -> None: v.status('Comparing channel tarball with git checkout') - match, mismatch, errors = compare(os.path.join( - channel_contents, pin.release_name), git_contents) + tarball_contents = os.path.join(channel_contents, pin.release_name) + match, mismatch, errors = compare(tarball_contents, git_contents) v.ok() v.check(f'{len(match)} files match', len(match) > 0) v.check(f'{len(mismatch)} files differ', len(mismatch) == 0) @@ -431,30 +441,21 @@ def compare_tarball_and_git( 'nixpkgs', 'programs.sqlite', 'svn-revision'] - permitted_errors = [ - 'pkgs/test/nixpkgs-check-by-name/tests/multiple-failures/pkgs/by-name/A/fo@/foo', - 'pkgs/test/nixpkgs-check-by-name/tests/symlink-invalid/pkgs/by-name/fo/foo/foo', - 'pkgs/test/nixpkgs-check-by-name/tests/symlink-invalid/pkgs/by-name/fo/foo/foo.nix', - ] benign_expected_errors = [] - benign_permitted_errors = [] for ee in expected_errors: if ee in errors: errors.remove(ee) benign_expected_errors.append(ee) - for pe in permitted_errors: - if pe in errors: - errors.remove(pe) - benign_permitted_errors.append(ee) + errors = [ + e for e in errors + if not broken_symlinks_are_identical(tarball_contents, git_contents, e) + ] v.check( f'{len(errors)} unexpected incomparable files: {errors}', len(errors) == 0) v.check( f'({len(benign_expected_errors)} of {len(expected_errors)} expected incomparable files)', len(benign_expected_errors) == len(expected_errors)) - v.check( - f'({len(benign_permitted_errors)} of {len(permitted_errors)} permitted incomparable files)', - len(benign_permitted_errors) <= len(permitted_errors)) def extract_tarball( -- 2.50.1 From f7e9e6aa43db8fb02e2c36888134205a21263493 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Wed, 24 Jan 2024 19:19:42 -0800 Subject: [PATCH 073/100] Release 3.0.14 --- default.nix | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/default.nix b/default.nix index 9d4aa33..60cf14a 100644 --- a/default.nix +++ b/default.nix @@ -25,7 +25,7 @@ in pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix_2_3, git , autopep8, makeWrapper, mypy, pylint, git-cache, }: buildPythonPackage rec { pname = "pinch"; - version = "3.0.14-pre"; + version = "3.0.14"; src = lib.cleanSource ./.; buildInputs = [ makeWrapper ]; propagatedBuildInputs = [ git-cache ]; diff --git a/setup.py b/setup.py index 4a09ffd..b105835 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup setup( name='pinch', - version='3.0.14-pre', + version='3.0.14', description="Cache git content locally", author="Scott Worley", author_email="scottworley@scottworley.com", -- 2.50.1 From 99c5963ad5694fd909688c3827db9e2f42956610 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Wed, 24 Jan 2024 19:25:36 -0800 Subject: [PATCH 074/100] Fix changelog --- Changelog | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Changelog b/Changelog index e4989b4..54935fb 100644 --- a/Changelog +++ b/Changelog @@ -1,8 +1,11 @@ ## [Unreleased] + + +## [3.0.14] - 2024-01-24 - Allow identical broken symlinks -## [3.0.12] - 2023-12-07 +## [3.0.13] - 2023-12-07 - Fixed nested-git issues in pre-commit hook - Adapt to new, stricter minidom type checks - Cleaned up changelog -- 2.50.1 From c731a81f97a68e00982ef54a0664dc6654a930aa Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Wed, 14 Feb 2024 21:26:53 -0800 Subject: [PATCH 075/100] Start on 3.0.15 --- default.nix | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/default.nix b/default.nix index 60cf14a..143e574 100644 --- a/default.nix +++ b/default.nix @@ -25,7 +25,7 @@ in pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix_2_3, git , autopep8, makeWrapper, mypy, pylint, git-cache, }: buildPythonPackage rec { pname = "pinch"; - version = "3.0.14"; + version = "3.0.15-pre"; src = lib.cleanSource ./.; buildInputs = [ makeWrapper ]; propagatedBuildInputs = [ git-cache ]; diff --git a/setup.py b/setup.py index b105835..309edbf 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup setup( name='pinch', - version='3.0.14', + version='3.0.15-pre', description="Cache git content locally", author="Scott Worley", author_email="scottworley@scottworley.com", -- 2.50.1 From 76fea05b57fcbb8c103a39299ba449d1d048fdb8 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Wed, 14 Feb 2024 21:27:21 -0800 Subject: [PATCH 076/100] Fix a bash-ism in test.sh, which is #!/bin/sh --- Changelog | 1 + test.sh | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Changelog b/Changelog index 54935fb..eb74b27 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ ## [Unreleased] +- Fix a bash-ism in test.sh, which is #!/bin/sh ## [3.0.14] - 2024-01-24 diff --git a/test.sh b/test.sh index 81e0c66..942c65c 100755 --- a/test.sh +++ b/test.sh @@ -24,7 +24,7 @@ if [ "$1" = lint ];then find . -name '*.py' -print0 | xargs -P "$PARALLELISM" -0 -n1 autopep8 --diff -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ) - if [[ "$formatting_needs_fixing" ]];then + if [ -n "$formatting_needs_fixing" ];then echo "Formatting needs fixing:" echo "$formatting_needs_fixing" exit 1 -- 2.50.1 From 235e32e3dbe58e9ea31f959a33f67f67c863e16c Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Wed, 14 Feb 2024 23:09:11 -0800 Subject: [PATCH 077/100] Fix package description in setup.py --- Changelog | 1 + setup.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Changelog b/Changelog index eb74b27..395803f 100644 --- a/Changelog +++ b/Changelog @@ -1,5 +1,6 @@ ## [Unreleased] - Fix a bash-ism in test.sh, which is #!/bin/sh +- Fix setup.py package description ## [3.0.14] - 2024-01-24 diff --git a/setup.py b/setup.py index 309edbf..50588f1 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ from setuptools import setup setup( name='pinch', version='3.0.15-pre', - description="Cache git content locally", + description='PIN CHannels - a replacement for `nix-channel --update`', author="Scott Worley", author_email="scottworley@scottworley.com", url="https://git.scottworley.com/pinch", -- 2.50.1 From 37f44333dcd4edce790e94809d6fed6cc1080e20 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Thu, 21 Mar 2024 15:47:57 -0700 Subject: [PATCH 078/100] Simplify example invocation in README When this is built/installed, you get a `pinch` binary in your $PATH; you don't actually have to say `python3 pinch.py ...` --- Changelog | 1 + README.md | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index 395803f..355d2b1 100644 --- a/Changelog +++ b/Changelog @@ -1,6 +1,7 @@ ## [Unreleased] - Fix a bash-ism in test.sh, which is #!/bin/sh - Fix setup.py package description +- Simplify example invocation in README ## [3.0.14] - 2024-01-24 diff --git a/README.md b/README.md index 181dec4..3443607 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,8 @@ PIN CHannels - a simple drop-in replacement for `nix-channel --update`. Example usage, being invoked on the example "channels" file included here: - $ python3 pinch.py pin channels - $ python3 pinch.py update channels + $ pinch pin channels + $ pinch update channels The first "pin" command will add these fields to the file: -- 2.50.1 From d3c5fb43ce904730019c6ab7806d367d928b2eb5 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Thu, 21 Mar 2024 15:50:59 -0700 Subject: [PATCH 079/100] .gitignore `result` --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index d7f7a42..1d26af3 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .mypy_cache +result -- 2.50.1 From a18858f8e34d8bd95be357e9516301ca8782233b Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Thu, 21 Mar 2024 15:51:31 -0700 Subject: [PATCH 080/100] Release 3.0.15 I won't sign the tag for this release this time because of nixpkgs bugs: https://github.com/NixOS/nixpkgs/issues/115145 https://github.com/NixOS/nixpkgs/issues/126848 I'll start signing tags again when a fix for this issue (such as https://github.com/NixOS/nixpkgs/pull/283663 ) is in all stable nixpkgs channels. --- Changelog | 3 +++ default.nix | 2 +- setup.py | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index 355d2b1..28c4400 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,7 @@ ## [Unreleased] + + +## [3.0.15] - 2024-03-21 - Fix a bash-ism in test.sh, which is #!/bin/sh - Fix setup.py package description - Simplify example invocation in README diff --git a/default.nix b/default.nix index 143e574..bd38eff 100644 --- a/default.nix +++ b/default.nix @@ -25,7 +25,7 @@ in pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix_2_3, git , autopep8, makeWrapper, mypy, pylint, git-cache, }: buildPythonPackage rec { pname = "pinch"; - version = "3.0.15-pre"; + version = "3.0.15"; src = lib.cleanSource ./.; buildInputs = [ makeWrapper ]; propagatedBuildInputs = [ git-cache ]; diff --git a/setup.py b/setup.py index 50588f1..5394f46 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup setup( name='pinch', - version='3.0.15-pre', + version='3.0.15', description='PIN CHannels - a replacement for `nix-channel --update`', author="Scott Worley", author_email="scottworley@scottworley.com", -- 2.50.1 From 82e0ab64d4d8c449f8239a66ad42b39734c5d351 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Fri, 28 Jun 2024 23:59:44 -0700 Subject: [PATCH 081/100] Start on 3.1.0 --- default.nix | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/default.nix b/default.nix index bd38eff..c11b3a9 100644 --- a/default.nix +++ b/default.nix @@ -25,7 +25,7 @@ in pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix_2_3, git , autopep8, makeWrapper, mypy, pylint, git-cache, }: buildPythonPackage rec { pname = "pinch"; - version = "3.0.15"; + version = "3.1.0-pre"; src = lib.cleanSource ./.; buildInputs = [ makeWrapper ]; propagatedBuildInputs = [ git-cache ]; diff --git a/setup.py b/setup.py index 5394f46..a6584d4 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup setup( name='pinch', - version='3.0.15', + version='3.1.0-pre', description='PIN CHannels - a replacement for `nix-channel --update`', author="Scott Worley", author_email="scottworley@scottworley.com", -- 2.50.1 From 3501ba8a2d15e354d6b200ccd50efd7e6dd9c360 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Sat, 29 Jun 2024 00:00:54 -0700 Subject: [PATCH 082/100] fallback git-cache 1.4.3 -> 1.5.0 for "git_ref = tag " support --- Changelog | 1 + default.nix | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index 28c4400..d4bf78c 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ ## [Unreleased] +- Bump git-cache dep to 1.5.0 for "git_ref = tag " support ## [3.0.15] - 2024-03-21 diff --git a/default.nix b/default.nix index c11b3a9..27b2dd9 100644 --- a/default.nix +++ b/default.nix @@ -9,11 +9,11 @@ let git-cache-fallback = { buildPythonPackage, fetchgit, git, backoff, mypy, }: buildPythonPackage rec { pname = "git-cache"; - version = "1.4.3"; + version = "1.5.0"; src = fetchgit { url = "https://git.scottworley.com/pub/git/git-cache"; rev = "v${version}"; - hash = "sha256-Qr62bGdlFFkzYTl6ot34UiOJxbP1Eeelx2OEd96vrqI="; + hash = "sha256-g4TS/zX3e29Q3ThsCAX2wLLlYbi8fdux5uqAc+b/Oww="; }; propagatedBuildInputs = [ backoff ]; "${checkInputsName}" = [ git mypy ]; -- 2.50.1 From c631c875b146d02059e7a9fe05185807ce011b5a Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Sat, 29 Jun 2024 00:05:32 -0700 Subject: [PATCH 083/100] Release 3.1.0 --- Changelog | 3 +++ default.nix | 2 +- setup.py | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index d4bf78c..f6df13b 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,7 @@ ## [Unreleased] + + +## [3.1.0] - 2024-06-29 - Bump git-cache dep to 1.5.0 for "git_ref = tag " support diff --git a/default.nix b/default.nix index 27b2dd9..fd2bccf 100644 --- a/default.nix +++ b/default.nix @@ -25,7 +25,7 @@ in pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix_2_3, git , autopep8, makeWrapper, mypy, pylint, git-cache, }: buildPythonPackage rec { pname = "pinch"; - version = "3.1.0-pre"; + version = "3.1.0"; src = lib.cleanSource ./.; buildInputs = [ makeWrapper ]; propagatedBuildInputs = [ git-cache ]; diff --git a/setup.py b/setup.py index a6584d4..bbcf250 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup setup( name='pinch', - version='3.1.0-pre', + version='3.1.0', description='PIN CHannels - a replacement for `nix-channel --update`', author="Scott Worley", author_email="scottworley@scottworley.com", -- 2.50.1 From 1f9fab63b0b38e77008272aa39fa6362c01e71b5 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Thu, 8 Aug 2024 11:11:39 -0700 Subject: [PATCH 084/100] README: Link auto-upgrade-with-pinch --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 3443607..b894304 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,8 @@ The second "update" command applies these changes to your nix channels, like `ni | Rejects force pushes | - | - | - | - | yes | | Ready to use today | yes | - | yes | yes | yes | +See also [auto-upgrade-with-pinch](https://git.scottworley.com/auto-upgrade-with-pinch). + [require.nix]: https://www.youtube.com/watch?v=DHOLjsyXPtM [niv]: https://github.com/nmattia/niv [flakes]: https://github.com/nixos/rfcs/pull/49 -- 2.50.1 From 1b183c2c1b3efc8ce94a42941e15f64be25db893 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Wed, 9 Jul 2025 16:12:34 -0700 Subject: [PATCH 085/100] Start on 3.2.0 --- default.nix | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/default.nix b/default.nix index fd2bccf..6f297e7 100644 --- a/default.nix +++ b/default.nix @@ -25,7 +25,7 @@ in pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix_2_3, git , autopep8, makeWrapper, mypy, pylint, git-cache, }: buildPythonPackage rec { pname = "pinch"; - version = "3.1.0"; + version = "3.2.0-pre"; src = lib.cleanSource ./.; buildInputs = [ makeWrapper ]; propagatedBuildInputs = [ git-cache ]; diff --git a/setup.py b/setup.py index bbcf250..65e7d58 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup setup( name='pinch', - version='3.1.0', + version='3.2.0-pre', description='PIN CHannels - a replacement for `nix-channel --update`', author="Scott Worley", author_email="scottworley@scottworley.com", -- 2.50.1 From 1b7ac5ff572bbdd96a5edc1768ab9192e4458db1 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Wed, 9 Jul 2025 16:14:07 -0700 Subject: [PATCH 086/100] Appease newer autopep8 --- pinch.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pinch.py b/pinch.py index 9e80c01..1a3a94b 100644 --- a/pinch.py +++ b/pinch.py @@ -570,7 +570,9 @@ def git_revision_name( git_revision], stdout=subprocess.PIPE) v.result(process.returncode == 0 and process.stdout != b'') - return f'{os.path.basename(channel.git_repo)}-{process.stdout.decode().strip()}' + return f'{ + os.path.basename(channel.git_repo)}-{ + process.stdout.decode().strip()}' K = TypeVar('K') -- 2.50.1 From 2a6cedfe22d12056af5240b983262e98cd5f131d Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Wed, 9 Jul 2025 16:17:27 -0700 Subject: [PATCH 087/100] Stop using ancient nix_2_3 Nix commit 787469c7b66aec12ab6847e7db2cdc8aef5c325e removed , preferring to stuff its contents into the nix binary & write it out to a temp file to use it. Pinch unpacks channels. So to retain access to unpack-channel.nix, pinch pinned its nix dependency to nix 2.3. This is no longer viable. The 2.3 branch is no longer maintained. It now has known security vulnerabilities, noted in knownVulnerabilities (which causes it to refuse to build). So now pinch does it the same way as nix, holding its own little unpack-channel.nix and writing it out to a temp file to use it. This lets us go back to not caring about the version of the nix dependency. --- Changelog | 1 + default.nix | 7 +++---- pinch.py | 46 +++++++++++++++++++++++++++---------------- tests/alias.sh | 2 +- tests/core.sh | 2 +- tests/multi-update.sh | 2 +- tests/pin-twice.sh | 2 +- tests/profile.sh | 2 +- tests/symlink.sh | 2 +- 9 files changed, 39 insertions(+), 27 deletions(-) diff --git a/Changelog b/Changelog index f6df13b..db6a06a 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ ## [Unreleased] +- Stop using ancient nix_2_3 ## [3.1.0] - 2024-06-29 diff --git a/default.nix b/default.nix index 6f297e7..2173f2a 100644 --- a/default.nix +++ b/default.nix @@ -21,7 +21,7 @@ let checkPhase = "./test.sh"; }; -in pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix_2_3, git +in pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix, git , autopep8, makeWrapper, mypy, pylint, git-cache, }: buildPythonPackage rec { pname = "pinch"; @@ -29,10 +29,10 @@ in pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix_2_3, git src = lib.cleanSource ./.; buildInputs = [ makeWrapper ]; propagatedBuildInputs = [ git-cache ]; - "${checkInputsName}" = [ nix_2_3 git mypy ] + "${checkInputsName}" = [ nix git mypy ] ++ lib.optionals lint [ autopep8 pylint ]; postInstall = '' - wrapProgram "$out/bin/pinch" --prefix PATH : ${nix_2_3}/bin + wrapProgram "$out/bin/pinch" --prefix PATH : ${nix}/bin ''; doCheck = true; checkPhase = "./test.sh"; @@ -46,5 +46,4 @@ in pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix_2_3, git git-cache = pkgs.python3Packages.git-cache or (pkgs.python3Packages.callPackage git-cache-fallback { }); - nix_2_3 = pkgs.nix_2_3 or pkgs.nix; } diff --git a/pinch.py b/pinch.py index 1a3a94b..bdd7a6e 100644 --- a/pinch.py +++ b/pinch.py @@ -685,23 +685,35 @@ def updateCommand(args: argparse.Namespace) -> None: assert isinstance(sp, AliasSearchPath) # For mypy exprs[section] = exprs[sp.alias_of] - command = [ - 'nix-env', - '--profile', - args.profile, - '--show-trace', - '--file', - '', - '--install', - '--remove-all', - ] + search_paths + ['--from-expression'] + [ - exprs[name] % name for name in sorted(exprs.keys())] - 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) + with tempfile.NamedTemporaryFile() as unpack_channel_nix: + unpack_channel_nix.write(b''' + { name, channelName, src, }: + derivation { + inherit name channelName src; + builder = "builtin:unpack-channel"; + system = "builtin"; + preferLocalBuild = true; + } + ''') + unpack_channel_nix.flush() + + command = [ + 'nix-env', + '--profile', + args.profile, + '--show-trace', + '--file', + unpack_channel_nix.name, + '--install', + '--remove-all', + ] + search_paths + ['--from-expression'] + [ + exprs[name] % name for name in sorted(exprs.keys())] + 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) def main() -> None: diff --git a/tests/alias.sh b/tests/alias.sh index bf83c18..470cb13 100755 --- a/tests/alias.sh +++ b/tests/alias.sh @@ -14,7 +14,7 @@ python3 ./pinch.py pin "$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 '\'''\'' --install --remove-all (-I pinch_profile=/nix/var/nix/profiles/per-user/[^/]+/channels -I pinch_profile_manifest=/nix/store/.{32}-env-manifest.nix )?-I pinch_tarball_for_(repo-[0-9]{10}-[0-9a-f]{11})=('"$NIX_STORE_DIR"'/.{32}-\2.tar.xz) --from-expression '\''f: f \{ name = "\2"; channelName = "bar"; src = builtins.storePath "\3"; \}'\'' '\''f: f \{ name = "\2"; channelName = "foo"; src = builtins.storePath "\3"; \}'\''$' +expected_env_command_RE='^nix-env --profile /nix/var/nix/profiles/per-user/[^/]+/channels --show-trace --file [^ ]+ --install --remove-all (-I pinch_profile=/nix/var/nix/profiles/per-user/[^/]+/channels -I pinch_profile_manifest=/nix/store/.{32}-env-manifest.nix )?-I pinch_tarball_for_(repo-[0-9]{10}-[0-9a-f]{11})=('"$NIX_STORE_DIR"'/.{32}-\2.tar.xz) --from-expression '\''f: f \{ name = "\2"; channelName = "bar"; src = builtins.storePath "\3"; \}'\'' '\''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 diff --git a/tests/core.sh b/tests/core.sh index b0721df..851525d 100755 --- a/tests/core.sh +++ b/tests/core.sh @@ -8,7 +8,7 @@ python3 ./pinch.py pin "$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 '\'''\'' --install --remove-all (-I pinch_profile=/nix/var/nix/profiles/per-user/[^/]+/channels -I pinch_profile_manifest=/nix/store/.{32}-env-manifest.nix )?-I pinch_tarball_for_(repo-[0-9]{10}-[0-9a-f]{11})=('"$NIX_STORE_DIR"'/.{32}-\2.tar.xz) --from-expression '\''f: f \{ name = "\2"; channelName = "foo"; src = builtins.storePath "\3"; \}'\''$' +expected_env_command_RE='^nix-env --profile /nix/var/nix/profiles/per-user/[^/]+/channels --show-trace --file [^ ]+ --install --remove-all (-I pinch_profile=/nix/var/nix/profiles/per-user/[^/]+/channels -I pinch_profile_manifest=/nix/store/.{32}-env-manifest.nix )?-I pinch_tarball_for_(repo-[0-9]{10}-[0-9a-f]{11})=('"$NIX_STORE_DIR"'/.{32}-\2.tar.xz) --from-expression '\''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 diff --git a/tests/multi-update.sh b/tests/multi-update.sh index 5d191ec..b87b7c6 100755 --- a/tests/multi-update.sh +++ b/tests/multi-update.sh @@ -18,7 +18,7 @@ actual_env_command=`python3 ./pinch.py update --dry-run "$conf" "$conf2"` rm -rf "$conf2" -expected_env_command_RE='^nix-env --profile /nix/var/nix/profiles/per-user/[^/]+/channels --show-trace --file '\'''\'' --install --remove-all (-I pinch_profile=/nix/var/nix/profiles/per-user/[^/]+/channels -I pinch_profile_manifest=/nix/store/.{32}-env-manifest.nix )?-I pinch_tarball_for_(repo-[0-9]{10}-[0-9a-f]{11})=('"$NIX_STORE_DIR"'/.{32}-\2.tar.xz) --from-expression '\''f: f \{ name = "\2"; channelName = "bar"; src = builtins.storePath "\3"; \}'\'' '\''f: f \{ name = "\2"; channelName = "foo"; src = builtins.storePath "\3"; \}'\''$' +expected_env_command_RE='^nix-env --profile /nix/var/nix/profiles/per-user/[^/]+/channels --show-trace --file [^ ]+ --install --remove-all (-I pinch_profile=/nix/var/nix/profiles/per-user/[^/]+/channels -I pinch_profile_manifest=/nix/store/.{32}-env-manifest.nix )?-I pinch_tarball_for_(repo-[0-9]{10}-[0-9a-f]{11})=('"$NIX_STORE_DIR"'/.{32}-\2.tar.xz) --from-expression '\''f: f \{ name = "\2"; channelName = "bar"; src = builtins.storePath "\3"; \}'\'' '\''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 diff --git a/tests/pin-twice.sh b/tests/pin-twice.sh index fda548b..0e651d2 100755 --- a/tests/pin-twice.sh +++ b/tests/pin-twice.sh @@ -17,7 +17,7 @@ python3 ./pinch.py pin "$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 '\'''\'' --install --remove-all (-I pinch_profile=/nix/var/nix/profiles/per-user/[^/]+/channels -I pinch_profile_manifest=/nix/store/.{32}-env-manifest.nix )?-I pinch_tarball_for_(repo-[0-9]{10}-[0-9a-f]{11})=('"$NIX_STORE_DIR"'/.{32}-\2.tar.xz) --from-expression '\''f: f \{ name = "\2"; channelName = "foo"; src = builtins.storePath "\3"; \}'\''$' +expected_env_command_RE='^nix-env --profile /nix/var/nix/profiles/per-user/[^/]+/channels --show-trace --file [^ ]+ --install --remove-all (-I pinch_profile=/nix/var/nix/profiles/per-user/[^/]+/channels -I pinch_profile_manifest=/nix/store/.{32}-env-manifest.nix )?-I pinch_tarball_for_(repo-[0-9]{10}-[0-9a-f]{11})=('"$NIX_STORE_DIR"'/.{32}-\2.tar.xz) --from-expression '\''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 diff --git a/tests/profile.sh b/tests/profile.sh index 085f2ce..dc1572b 100755 --- a/tests/profile.sh +++ b/tests/profile.sh @@ -8,7 +8,7 @@ python3 ./pinch.py pin "$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 '\'''\'' --install --remove-all -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"; \}'\''$' +expected_env_command_RE='^nix-env --profile /path/to/profile --show-trace --file [^ ]+ --install --remove-all -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 diff --git a/tests/symlink.sh b/tests/symlink.sh index 8b59794..e1fa69b 100755 --- a/tests/symlink.sh +++ b/tests/symlink.sh @@ -14,7 +14,7 @@ python3 ./pinch.py pin "$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 '\'''\'' --install --remove-all (-I pinch_profile=/nix/var/nix/profiles/per-user/[^/]+/channels -I pinch_profile_manifest=/nix/store/.{32}-env-manifest.nix )?-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}-\3.tar.xz) --from-expression '\''f: f \{ name = "link"; channelName = "bar"; src = builtins.storePath "\2"; \}'\'' '\''f: f \{ name = "\3"; channelName = "foo"; src = builtins.storePath "\4"; \}'\''$' +expected_env_command_RE='^nix-env --profile /nix/var/nix/profiles/per-user/[^/]+/channels --show-trace --file [^ ]+ --install --remove-all (-I pinch_profile=/nix/var/nix/profiles/per-user/[^/]+/channels -I pinch_profile_manifest=/nix/store/.{32}-env-manifest.nix )?-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}-\3.tar.xz) --from-expression '\''f: f \{ name = "link"; channelName = "bar"; src = builtins.storePath "\2"; \}'\'' '\''f: f \{ name = "\3"; channelName = "foo"; src = builtins.storePath "\4"; \}'\''$' if echo "$actual_env_command" | egrep "$expected_env_command_RE" > /dev/null;then echo PASS -- 2.50.1 From 34855dce8082683fab63da3da70323f0fe48d439 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Wed, 9 Jul 2025 17:07:40 -0700 Subject: [PATCH 088/100] Modern nix always needs --experimental-features --- pinch.py | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/pinch.py b/pinch.py index bdd7a6e..40ebf1b 100644 --- a/pinch.py +++ b/pinch.py @@ -320,22 +320,12 @@ def digest_file(filename: str) -> Digest16: return Digest16(hasher.hexdigest()) -@functools.lru_cache -def _experimental_flag_needed(v: Verification) -> bool: - v.status('Checking Nix version') - process = subprocess.run(['nix', '--help'], stdout=subprocess.PIPE) - v.result(process.returncode == 0) - return b'--experimental-features' in process.stdout - - -def _nix_command(v: Verification) -> List[str]: - return ['nix', '--experimental-features', - 'nix-command'] if _experimental_flag_needed(v) else ['nix'] +_NIX_COMMAND = ['nix', '--experimental-features', 'nix-command'] def to_Digest16(v: Verification, digest32: Digest32) -> Digest16: v.status('Converting digest to base16') - process = subprocess.run(_nix_command(v) + [ + process = subprocess.run(_NIX_COMMAND + [ 'to-base16', '--type', 'sha256', @@ -347,7 +337,7 @@ def to_Digest16(v: Verification, digest32: Digest32) -> Digest16: def to_Digest32(v: Verification, digest16: Digest16) -> Digest32: v.status('Converting digest to base32') - process = subprocess.run(_nix_command(v) + [ + process = subprocess.run(_NIX_COMMAND + [ 'to-base32', '--type', 'sha256', -- 2.50.1 From de3c28c2fb3d8fdbe1106d893c9b1e7b8be50406 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Wed, 9 Jul 2025 16:31:57 -0700 Subject: [PATCH 089/100] Release 3.2.0 --- Changelog | 3 +++ default.nix | 2 +- setup.py | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index db6a06a..3599b9e 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,7 @@ ## [Unreleased] + + +## [3.2.0] - 2025-07-09 - Stop using ancient nix_2_3 diff --git a/default.nix b/default.nix index 2173f2a..29096f8 100644 --- a/default.nix +++ b/default.nix @@ -25,7 +25,7 @@ in pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix, git , autopep8, makeWrapper, mypy, pylint, git-cache, }: buildPythonPackage rec { pname = "pinch"; - version = "3.2.0-pre"; + version = "3.2.0"; src = lib.cleanSource ./.; buildInputs = [ makeWrapper ]; propagatedBuildInputs = [ git-cache ]; diff --git a/setup.py b/setup.py index 65e7d58..6f348e7 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup setup( name='pinch', - version='3.2.0-pre', + version='3.2.0', description='PIN CHannels - a replacement for `nix-channel --update`', author="Scott Worley", author_email="scottworley@scottworley.com", -- 2.50.1 From 42dbaf9df4f644bf053e4a37847803283860ec18 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Wed, 9 Jul 2025 16:33:35 -0700 Subject: [PATCH 090/100] Start on 3.3.0 --- default.nix | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/default.nix b/default.nix index 29096f8..777a767 100644 --- a/default.nix +++ b/default.nix @@ -25,7 +25,7 @@ in pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix, git , autopep8, makeWrapper, mypy, pylint, git-cache, }: buildPythonPackage rec { pname = "pinch"; - version = "3.2.0"; + version = "3.3.0-pre"; src = lib.cleanSource ./.; buildInputs = [ makeWrapper ]; propagatedBuildInputs = [ git-cache ]; diff --git a/setup.py b/setup.py index 6f348e7..5f7cb65 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup setup( name='pinch', - version='3.2.0', + version='3.3.0-pre', description='PIN CHannels - a replacement for `nix-channel --update`', author="Scott Worley", author_email="scottworley@scottworley.com", -- 2.50.1 From fb819850734c2ca68640736444c4c86ba15ccd70 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Wed, 9 Jul 2025 16:34:55 -0700 Subject: [PATCH 091/100] Use nix executables in $PATH We started pinning the nix version back Jun 2021 over becoming private. As a side effect of pinning (overriding) the nix version, we bundled nix with pinch so that it could find nix even if it wasn't in $PATH. We're now unwinding that: We no longer need a specific (ancient) version of nix, so we're going back to using whatever is laying around in $PATH. This *could* be a breaking change if you were depending upon pinch's ability to find nix on its own. It seems unlikely that there are actually any users depending on this, so I'm not bumping the major version, but I am rolling rolling this out in two steps in case anyone is affected & would find it useful to have an intermediate version of pinch to pin to while they help newest pinch find nix stuff: pinch 3.1.0 - Uses ancient nix_2_3 that now no longer builds pinch 3.2.0 - Uses whatever nix is in pinch 3.3.0 - Uses whatever nix is in $PATH In case pinch's bundling of its own nix was giving anyone grief because it *wasn't* using the one in $PATH: Sorry. It's fixed now. You can unwind your hacks around this. :) --- Changelog | 1 + default.nix | 8 ++------ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Changelog b/Changelog index 3599b9e..e905bd1 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ ## [Unreleased] +- Use nix executables in $PATH ## [3.2.0] - 2025-07-09 diff --git a/default.nix b/default.nix index 777a767..1374022 100644 --- a/default.nix +++ b/default.nix @@ -21,19 +21,15 @@ let checkPhase = "./test.sh"; }; -in pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix, git - , autopep8, makeWrapper, mypy, pylint, git-cache, }: +in pkgs.python3Packages.callPackage +({ lib, buildPythonPackage, nix, git, autopep8, mypy, pylint, git-cache, }: buildPythonPackage rec { pname = "pinch"; version = "3.3.0-pre"; src = lib.cleanSource ./.; - buildInputs = [ makeWrapper ]; propagatedBuildInputs = [ git-cache ]; "${checkInputsName}" = [ nix git mypy ] ++ lib.optionals lint [ autopep8 pylint ]; - postInstall = '' - wrapProgram "$out/bin/pinch" --prefix PATH : ${nix}/bin - ''; doCheck = true; checkPhase = "./test.sh"; meta = { -- 2.50.1 From 9ee5c3ca5b5ae9fc3bd5eceb8ab546029d511b28 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Wed, 9 Jul 2025 16:54:29 -0700 Subject: [PATCH 092/100] Release 3.3.0 --- Changelog | 3 +++ default.nix | 2 +- setup.py | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index e905bd1..5b6158e 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,7 @@ ## [Unreleased] + + +## [3.3.0] - 2025-07-09 - Use nix executables in $PATH diff --git a/default.nix b/default.nix index 1374022..8025d4a 100644 --- a/default.nix +++ b/default.nix @@ -25,7 +25,7 @@ in pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix, git, autopep8, mypy, pylint, git-cache, }: buildPythonPackage rec { pname = "pinch"; - version = "3.3.0-pre"; + version = "3.3.0"; src = lib.cleanSource ./.; propagatedBuildInputs = [ git-cache ]; "${checkInputsName}" = [ nix git mypy ] diff --git a/setup.py b/setup.py index 5f7cb65..6db91c7 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup setup( name='pinch', - version='3.3.0-pre', + version='3.3.0', description='PIN CHannels - a replacement for `nix-channel --update`', author="Scott Worley", author_email="scottworley@scottworley.com", -- 2.50.1 From b407364e422fb34a5ca6313032bf87cbe1b14649 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Wed, 9 Jul 2025 17:19:02 -0700 Subject: [PATCH 093/100] Start on 3.3.1 --- default.nix | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/default.nix b/default.nix index 8025d4a..23bb053 100644 --- a/default.nix +++ b/default.nix @@ -25,7 +25,7 @@ in pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix, git, autopep8, mypy, pylint, git-cache, }: buildPythonPackage rec { pname = "pinch"; - version = "3.3.0"; + version = "3.3.1-pre"; src = lib.cleanSource ./.; propagatedBuildInputs = [ git-cache ]; "${checkInputsName}" = [ nix git mypy ] diff --git a/setup.py b/setup.py index 6db91c7..7b1cee3 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup setup( name='pinch', - version='3.3.0', + version='3.3.1-pre', description='PIN CHannels - a replacement for `nix-channel --update`', author="Scott Worley", author_email="scottworley@scottworley.com", -- 2.50.1 From a222b37dee8407750871aa71bedd21317d881e89 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Wed, 9 Jul 2025 17:17:56 -0700 Subject: [PATCH 094/100] Remove unused to_Digest32() --- pinch.py | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/pinch.py b/pinch.py index 40ebf1b..dcc972c 100644 --- a/pinch.py +++ b/pinch.py @@ -335,18 +335,6 @@ def to_Digest16(v: Verification, digest32: Digest32) -> Digest16: return Digest16(process.stdout.decode().strip()) -def to_Digest32(v: Verification, digest16: Digest16) -> Digest32: - v.status('Converting digest to base32') - process = subprocess.run(_NIX_COMMAND + [ - 'to-base32', - '--type', - 'sha256', - digest16], - stdout=subprocess.PIPE) - v.result(process.returncode == 0) - return Digest32(process.stdout.decode().strip()) - - def fetch_with_nix_prefetch_url( v: Verification, url: str, -- 2.50.1 From 6b7d6a8a278a8f1d1430ef15f4fbe74fb45e3fa7 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Wed, 9 Jul 2025 17:22:56 -0700 Subject: [PATCH 095/100] Use new 'nix hash convert' to quiet new nix's depreciation warnings --- Changelog | 1 + pinch.py | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index 5b6158e..8d0f9f8 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ ## [Unreleased] +- Use new 'nix hash convert' to quiet new nix's depreciation warnings ## [3.3.0] - 2025-07-09 diff --git a/pinch.py b/pinch.py index dcc972c..989e08f 100644 --- a/pinch.py +++ b/pinch.py @@ -326,9 +326,12 @@ _NIX_COMMAND = ['nix', '--experimental-features', 'nix-command'] def to_Digest16(v: Verification, digest32: Digest32) -> Digest16: v.status('Converting digest to base16') process = subprocess.run(_NIX_COMMAND + [ - 'to-base16', - '--type', + 'hash', + 'convert', + '--hash-algo', 'sha256', + '--to', + 'base16', digest32], stdout=subprocess.PIPE) v.result(process.returncode == 0) -- 2.50.1 From 3124c68298a70ebf6e553746ae2459ffacff1776 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Wed, 9 Jul 2025 17:25:24 -0700 Subject: [PATCH 096/100] Release 3.3.1 --- Changelog | 3 +++ default.nix | 2 +- setup.py | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index 8d0f9f8..702eefb 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,7 @@ ## [Unreleased] + + +## [3.3.1] - 2025-07-09 - Use new 'nix hash convert' to quiet new nix's depreciation warnings diff --git a/default.nix b/default.nix index 23bb053..6ba300a 100644 --- a/default.nix +++ b/default.nix @@ -25,7 +25,7 @@ in pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix, git, autopep8, mypy, pylint, git-cache, }: buildPythonPackage rec { pname = "pinch"; - version = "3.3.1-pre"; + version = "3.3.1"; src = lib.cleanSource ./.; propagatedBuildInputs = [ git-cache ]; "${checkInputsName}" = [ nix git mypy ] diff --git a/setup.py b/setup.py index 7b1cee3..c7e925f 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup setup( name='pinch', - version='3.3.1-pre', + version='3.3.1', description='PIN CHannels - a replacement for `nix-channel --update`', author="Scott Worley", author_email="scottworley@scottworley.com", -- 2.50.1 From ab114f1cf66dd3ba58f28b9541e0f23224cdcab6 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Sun, 14 Dec 2025 01:19:51 -0800 Subject: [PATCH 097/100] Start on 3.3.2 --- default.nix | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/default.nix b/default.nix index 6ba300a..c0903a1 100644 --- a/default.nix +++ b/default.nix @@ -25,7 +25,7 @@ in pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix, git, autopep8, mypy, pylint, git-cache, }: buildPythonPackage rec { pname = "pinch"; - version = "3.3.1"; + version = "3.3.2-pre"; src = lib.cleanSource ./.; propagatedBuildInputs = [ git-cache ]; "${checkInputsName}" = [ nix git mypy ] diff --git a/setup.py b/setup.py index c7e925f..f4d3e8a 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup setup( name='pinch', - version='3.3.1', + version='3.3.2-pre', description='PIN CHannels - a replacement for `nix-channel --update`', author="Scott Worley", author_email="scottworley@scottworley.com", -- 2.50.1 From 92b08b27dc0960e4d2f6e8305053149fb514f7e9 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Sun, 14 Dec 2025 01:24:46 -0800 Subject: [PATCH 098/100] Add new nixpkgs-25.11 pyproject boilerplate --- Changelog | 1 + default.nix | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Changelog b/Changelog index 702eefb..c36277a 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ ## [Unreleased] +- Keep up with nixpkgs 25.11 ## [3.3.1] - 2025-07-09 diff --git a/default.nix b/default.nix index c0903a1..6618324 100644 --- a/default.nix +++ b/default.nix @@ -6,7 +6,8 @@ let checkInputsName = if checkInputsAreNative then "nativeCheckInputs" else "checkInputs"; - git-cache-fallback = { buildPythonPackage, fetchgit, git, backoff, mypy, }: + git-cache-fallback = + { buildPythonPackage, setuptools, fetchgit, git, backoff, mypy, }: buildPythonPackage rec { pname = "git-cache"; version = "1.5.0"; @@ -15,18 +16,22 @@ let rev = "v${version}"; hash = "sha256-g4TS/zX3e29Q3ThsCAX2wLLlYbi8fdux5uqAc+b/Oww="; }; + pyproject = true; + build-system = [ setuptools ]; propagatedBuildInputs = [ backoff ]; "${checkInputsName}" = [ git mypy ]; doCheck = true; checkPhase = "./test.sh"; }; -in pkgs.python3Packages.callPackage -({ lib, buildPythonPackage, nix, git, autopep8, mypy, pylint, git-cache, }: +in pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, setuptools, nix + , git, autopep8, mypy, pylint, git-cache, }: buildPythonPackage rec { pname = "pinch"; version = "3.3.2-pre"; src = lib.cleanSource ./.; + pyproject = true; + build-system = [ setuptools ]; propagatedBuildInputs = [ git-cache ]; "${checkInputsName}" = [ nix git mypy ] ++ lib.optionals lint [ autopep8 pylint ]; -- 2.50.1 From ba536d80cbc447f80afe10d06e6545e6c31c592f Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Sun, 14 Dec 2025 02:12:20 -0800 Subject: [PATCH 099/100] Assert correct HTML document structure 25.11's typeshed has better dom type info. --- pinch.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pinch.py b/pinch.py index 989e08f..c101dc3 100644 --- a/pinch.py +++ b/pinch.py @@ -293,14 +293,25 @@ def parse_channel(v: Verification, channel_html: str) \ v.status(git_revision) v.ok() v.status('Verifying git commit label') + assert git_commit_node.previousSibling is not None v.result(git_commit_node.previousSibling.nodeValue == 'Git commit ') v.status('Parsing table') table: Dict[str, ChannelTableEntry] = {} for row in d.getElementsByTagName('tr')[1:]: + assert isinstance( + row.childNodes[0].firstChild, xml.dom.minidom.Element) + assert isinstance( + row.childNodes[0].firstChild.firstChild, xml.dom.minidom.Text) name = row.childNodes[0].firstChild.firstChild.nodeValue + assert name is not None url = row.childNodes[0].firstChild.getAttribute('href') + assert row.childNodes[1].firstChild is not None + assert row.childNodes[1].firstChild.nodeValue is not None size = int(row.childNodes[1].firstChild.nodeValue) + assert row.childNodes[2].firstChild is not None + assert row.childNodes[2].firstChild.firstChild is not None + assert row.childNodes[2].firstChild.firstChild.nodeValue is not None digest = Digest16(row.childNodes[2].firstChild.firstChild.nodeValue) table[name] = ChannelTableEntry(url=url, digest=digest, size=size) v.ok() -- 2.50.1 From 8ec8e7607393df1f7be14ab20e5dc1b3a8e1832d Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Sun, 14 Dec 2025 02:17:06 -0800 Subject: [PATCH 100/100] Release 3.3.2 --- Changelog | 2 ++ default.nix | 2 +- setup.py | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index c36277a..e087c30 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,6 @@ ## [Unreleased] + +## [3.3.2] - 2025-12-14 - Keep up with nixpkgs 25.11 diff --git a/default.nix b/default.nix index 6618324..43f4bef 100644 --- a/default.nix +++ b/default.nix @@ -28,7 +28,7 @@ in pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, setuptools, nix , git, autopep8, mypy, pylint, git-cache, }: buildPythonPackage rec { pname = "pinch"; - version = "3.3.2-pre"; + version = "3.3.2"; src = lib.cleanSource ./.; pyproject = true; build-system = [ setuptools ]; diff --git a/setup.py b/setup.py index f4d3e8a..0c852f4 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup setup( name='pinch', - version='3.3.2-pre', + version='3.3.2', description='PIN CHannels - a replacement for `nix-channel --update`', author="Scott Worley", author_email="scottworley@scottworley.com", -- 2.50.1