From 65f49835f6ab5af744d5ce18162b535818e5177a Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Fri, 3 Nov 2023 12:27:04 +0300 Subject: [PATCH] treewide: switch to npins --- npins/default.nix | 47 +++++++++++++++++++++ npins/sources.json | 53 ++++++++++++++++++++++++ pkgs/ani-cli/README.md | 4 ++ pkgs/ani-cli/default.nix | 54 ++++++++++++------------ pkgs/default.nix | 21 +++++++--- pkgs/mov-cli/default.nix | 89 ++++++++++++++++++++-------------------- pkgs/rat/default.nix | 1 + 7 files changed, 193 insertions(+), 76 deletions(-) create mode 100644 npins/default.nix create mode 100644 npins/sources.json create mode 100644 pkgs/ani-cli/README.md diff --git a/npins/default.nix b/npins/default.nix new file mode 100644 index 0000000..4a7c372 --- /dev/null +++ b/npins/default.nix @@ -0,0 +1,47 @@ +# Generated by npins. Do not modify; will be overwritten regularly +let + data = builtins.fromJSON (builtins.readFile ./sources.json); + version = data.version; + + mkSource = spec: + assert spec ? type; let + path = + if spec.type == "Git" then mkGitSource spec + else if spec.type == "GitRelease" then mkGitSource spec + else if spec.type == "PyPi" then mkPyPiSource spec + else if spec.type == "Channel" then mkChannelSource spec + else builtins.throw "Unknown source type ${spec.type}"; + in + spec // { outPath = path; }; + + mkGitSource = { repository, revision, url ? null, hash, ... }: + assert repository ? type; + # At the moment, either it is a plain git repository (which has an url), or it is a GitHub/GitLab repository + # In the latter case, there we will always be an url to the tarball + if url != null then + (builtins.fetchTarball { + inherit url; + sha256 = hash; # FIXME: check nix version & use SRI hashes + }) + else assert repository.type == "Git"; builtins.fetchGit { + url = repository.url; + rev = revision; + # hash = hash; + }; + + mkPyPiSource = { url, hash, ... }: + builtins.fetchurl { + inherit url; + sha256 = hash; + }; + + mkChannelSource = { url, hash, ... }: + builtins.fetchTarball { + inherit url; + sha256 = hash; + }; +in +if version == 3 then + builtins.mapAttrs (_: mkSource) data.pins +else + throw "Unsupported format version ${toString version} in sources.json. Try running `npins upgrade`" diff --git a/npins/sources.json b/npins/sources.json new file mode 100644 index 0000000..6e57fd0 --- /dev/null +++ b/npins/sources.json @@ -0,0 +1,53 @@ +{ + "pins": { + "ani-cli": { + "type": "GitRelease", + "repository": { + "type": "GitHub", + "owner": "pystardust", + "repo": "ani-cli" + }, + "pre_releases": false, + "version_upper_bound": null, + "version": "v4.6", + "revision": "c7e6838647b57411d791bd250417eb0925d74cca", + "url": "https://api.github.com/repos/pystardust/ani-cli/tarball/v4.6", + "hash": "1ni9pzjb5qh87iz7c8252bx79qadr1qx6jnkqvvjcqrchh7q473a" + }, + "cloneit": { + "type": "GitRelease", + "repository": { + "type": "GitHub", + "owner": "alok8bb", + "repo": "cloneit" + }, + "pre_releases": false, + "version_upper_bound": null, + "version": "0.1.0", + "revision": "44402e101b18be0764ddb0b49bf0393e2e83c9c3", + "url": "https://api.github.com/repos/alok8bb/cloneit/tarball/0.1.0", + "hash": "18z4vxrfvyp20kig2s9k5y3034nw39wkj8zzk9qskiisv2ypy90b" + }, + "mov-cli": { + "type": "GitRelease", + "repository": { + "type": "GitHub", + "owner": "mov-cli", + "repo": "mov-cli" + }, + "pre_releases": false, + "version_upper_bound": null, + "version": "1.5.4", + "revision": "5f0ec5a69d37b286966d39b6596b3b76d5302387", + "url": "https://api.github.com/repos/mov-cli/mov-cli/tarball/1.5.4", + "hash": "0n6k9vyq21r88x5zgidaafjlhia20dx0psdpys7dyfr8azh0y6js" + }, + "nixpkgs": { + "type": "Channel", + "name": "nixpkgs-unstable", + "url": "https://releases.nixos.org/nixpkgs/nixpkgs-23.11pre543441.b644d97bda6d/nixexprs.tar.xz", + "hash": "1xq7rz2bcb115xkahpvslsqpliisv2587z93izz81lna77r4na1d" + } + }, + "version": 3 +} \ No newline at end of file diff --git a/pkgs/ani-cli/README.md b/pkgs/ani-cli/README.md new file mode 100644 index 0000000..c6ea0b0 --- /dev/null +++ b/pkgs/ani-cli/README.md @@ -0,0 +1,4 @@ +# ani-cli + +ani-cli is already in nixpkgs. The sole reason it's been put in this overlay is so that +I can receive the updates _as they happen_ and not wait until a maintainer bumps it up. diff --git a/pkgs/ani-cli/default.nix b/pkgs/ani-cli/default.nix index e76c1f1..850e976 100644 --- a/pkgs/ani-cli/default.nix +++ b/pkgs/ani-cli/default.nix @@ -9,33 +9,35 @@ fzf, mpv, aria2, -}: -stdenvNoCC.mkDerivation rec { - pname = "ani-cli"; - version = "4.6"; + pins, +}: let + pin = pins.ani-cli; +in + stdenvNoCC.mkDerivation { + pname = "ani-cli"; + inherit (pin) version; - src = fetchFromGitHub { - owner = "pystardust"; - repo = "${pname}"; - rev = "v${version}"; - hash = "sha256-ahyCD4QsYyb3xtNK03HITeF0+hJFIHZ+PAjisuS/Kdo="; - }; + src = fetchFromGitHub { + inherit (pin.repository) owner repo; + sha256 = pin.hash; + rev = pin.revision; + }; - nativeBuildInputs = [makeWrapper]; + nativeBuildInputs = [makeWrapper]; - installPhase = '' - runHook preInstall - install -Dm755 ani-cli $out/bin/ani-cli - wrapProgram $out/bin/ani-cli \ - --prefix PATH : ${lib.makeBinPath [gnugrep gnused wget fzf mpv aria2]} - runHook postInstall - ''; + installPhase = '' + runHook preInstall + install -Dm755 ani-cli $out/bin/ani-cli + wrapProgram $out/bin/ani-cli \ + --prefix PATH : ${lib.makeBinPath [gnugrep gnused wget fzf mpv aria2]} + runHook postInstall + ''; - meta = with lib; { - homepage = "https://github.com/pystardust/ani-cli"; - description = "A cli tool to browse and play anime"; - license = licenses.gpl3Plus; - maintainers = with maintainers; [skykanin]; - platforms = platforms.unix; - }; -} + meta = with lib; { + homepage = "https://github.com/pystardust/ani-cli"; + description = "A cli tool to browse and play anime"; + license = licenses.gpl3Plus; + maintainers = with maintainers; [NotAShelf]; + platforms = platforms.unix; + }; + } diff --git a/pkgs/default.nix b/pkgs/default.nix index e491bda..23e8e6c 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -18,13 +18,22 @@ config.allowUnfree = true; }; - packages = { - ani-cli = pkgs.callPackage ./ani-cli {}; - rat = pkgs.callPackage ./rat {}; - mov-cli = pkgs.callPackage ./mov-cli {}; - reposilite-bin = pkgs.callPackage ./reposilite-bin {}; - cloneit = pkgs.callPackage ./cloneit {}; + packages = let + pins = import ../npins; + mkPackage = path: {__functor = self: self.override;} // (pkgs.callPackage path {inherit pins;}); + in { + # packages that follow npins entries + # they can be updated via npins + ani-cli = mkPackage ./ani-cli; + rat = mkPackage ./rat; + mov-cli = mkPackage ./mov-cli; + # static packages + # need manual intervention with each update + cloneit = pkgs.callPackage ./cloneit {}; + reposilite-bin = pkgs.callPackage ./reposilite-bin {}; + + # patched packages foot-transparent = pkgs.foot.overrideAttrs (old: { patches = (old.patches or []) diff --git a/pkgs/mov-cli/default.nix b/pkgs/mov-cli/default.nix index e634c83..dd41909 100644 --- a/pkgs/mov-cli/default.nix +++ b/pkgs/mov-cli/default.nix @@ -1,53 +1,54 @@ { lib, - pkgs, python3Packages, fetchFromGitHub, fetchPypi, -}: -python3Packages.buildPythonPackage rec { - pname = "mov-cli"; - version = "1.5.1"; - format = "pyproject"; + pins, +}: let + pin = pins.mov-cli; +in + python3Packages.buildPythonPackage { + format = "pyproject"; + pname = "mov-cli"; + inherit (pin) version; - src = fetchFromGitHub { - owner = "mov-cli"; - repo = "mov-cli"; - rev = "${version}"; - hash = "sha256-ixv9guHfXy1kQbpAWAVwPtpxX5IwAQ8CQ2hvhM7sewg="; - }; + src = fetchFromGitHub { + inherit (pin.repository) owner repo; + sha256 = pin.hash; + rev = pin.revision; + }; - propagatedBuildInputs = with python3Packages; [ - poetry-core - pycryptodome - lxml - six - beautifulsoup4 - tldextract - (python3Packages.httpx.overrideAttrs (_old: { - src = fetchFromGitHub { - owner = "encode"; - repo = "httpx"; - rev = "refs/tags/0.24.0"; - hash = "sha256-eLCqmYKfBZXCQvFFh5kGoO91rtsvjbydZhPNtjL3Zaw="; - }; - })) - ( - python3Packages.buildPythonPackage rec { - pname = "krfzf_py"; - version = "0.0.4"; - src = fetchPypi { - inherit pname version; - sha256 = "sha256-W0wpR1/HRrtYC3vqEwh+Jwkgwnfa49LCFIArOXaSPCE="; + propagatedBuildInputs = with python3Packages; [ + poetry-core + pycryptodome + lxml + six + beautifulsoup4 + tldextract + (python3Packages.httpx.overrideAttrs (_old: { + src = fetchFromGitHub { + owner = "encode"; + repo = "httpx"; + rev = "refs/tags/0.24.0"; + hash = "sha256-eLCqmYKfBZXCQvFFh5kGoO91rtsvjbydZhPNtjL3Zaw="; }; - } - ) - ]; + })) + ( + python3Packages.buildPythonPackage rec { + pname = "krfzf_py"; + version = "0.0.4"; + src = fetchPypi { + inherit pname version; + sha256 = "sha256-W0wpR1/HRrtYC3vqEwh+Jwkgwnfa49LCFIArOXaSPCE="; + }; + } + ) + ]; - meta = with lib; { - homepage = "https://github.com/mov-cli/mov-cli"; - description = "A cli tool to browse and watch movies"; - license = licenses.gpl3Only; - mainProgram = "mov-cli"; - }; -} + meta = with lib; { + homepage = "https://github.com/mov-cli/mov-cli"; + description = "A cli tool to browse and watch movies"; + license = licenses.gpl3Only; + mainProgram = "mov-cli"; + }; + } diff --git a/pkgs/rat/default.nix b/pkgs/rat/default.nix index 8993e72..2fb029b 100644 --- a/pkgs/rat/default.nix +++ b/pkgs/rat/default.nix @@ -5,6 +5,7 @@ makeWrapper, pkgs, lib, + pins, }: stdenv.mkDerivation rec { pname = "rat";