treewide: switch to npins

This commit is contained in:
raf 2023-11-03 12:27:04 +03:00
parent 0eef5abf3f
commit 65f49835f6
No known key found for this signature in database
GPG key ID: 02D1DD3FA08B6B29
7 changed files with 193 additions and 76 deletions

47
npins/default.nix Normal file
View file

@ -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`"

53
npins/sources.json Normal file
View file

@ -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
}

4
pkgs/ani-cli/README.md Normal file
View file

@ -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.

View file

@ -9,33 +9,35 @@
fzf, fzf,
mpv, mpv,
aria2, aria2,
}: pins,
stdenvNoCC.mkDerivation rec { }: let
pname = "ani-cli"; pin = pins.ani-cli;
version = "4.6"; in
stdenvNoCC.mkDerivation {
pname = "ani-cli";
inherit (pin) version;
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "pystardust"; inherit (pin.repository) owner repo;
repo = "${pname}"; sha256 = pin.hash;
rev = "v${version}"; rev = pin.revision;
hash = "sha256-ahyCD4QsYyb3xtNK03HITeF0+hJFIHZ+PAjisuS/Kdo="; };
};
nativeBuildInputs = [makeWrapper]; nativeBuildInputs = [makeWrapper];
installPhase = '' installPhase = ''
runHook preInstall runHook preInstall
install -Dm755 ani-cli $out/bin/ani-cli install -Dm755 ani-cli $out/bin/ani-cli
wrapProgram $out/bin/ani-cli \ wrapProgram $out/bin/ani-cli \
--prefix PATH : ${lib.makeBinPath [gnugrep gnused wget fzf mpv aria2]} --prefix PATH : ${lib.makeBinPath [gnugrep gnused wget fzf mpv aria2]}
runHook postInstall runHook postInstall
''; '';
meta = with lib; { meta = with lib; {
homepage = "https://github.com/pystardust/ani-cli"; homepage = "https://github.com/pystardust/ani-cli";
description = "A cli tool to browse and play anime"; description = "A cli tool to browse and play anime";
license = licenses.gpl3Plus; license = licenses.gpl3Plus;
maintainers = with maintainers; [skykanin]; maintainers = with maintainers; [NotAShelf];
platforms = platforms.unix; platforms = platforms.unix;
}; };
} }

View file

@ -18,13 +18,22 @@
config.allowUnfree = true; config.allowUnfree = true;
}; };
packages = { packages = let
ani-cli = pkgs.callPackage ./ani-cli {}; pins = import ../npins;
rat = pkgs.callPackage ./rat {}; mkPackage = path: {__functor = self: self.override;} // (pkgs.callPackage path {inherit pins;});
mov-cli = pkgs.callPackage ./mov-cli {}; in {
reposilite-bin = pkgs.callPackage ./reposilite-bin {}; # packages that follow npins entries
cloneit = pkgs.callPackage ./cloneit {}; # 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: { foot-transparent = pkgs.foot.overrideAttrs (old: {
patches = patches =
(old.patches or []) (old.patches or [])

View file

@ -1,53 +1,54 @@
{ {
lib, lib,
pkgs,
python3Packages, python3Packages,
fetchFromGitHub, fetchFromGitHub,
fetchPypi, fetchPypi,
}: pins,
python3Packages.buildPythonPackage rec { }: let
pname = "mov-cli"; pin = pins.mov-cli;
version = "1.5.1"; in
format = "pyproject"; python3Packages.buildPythonPackage {
format = "pyproject";
pname = "mov-cli";
inherit (pin) version;
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "mov-cli"; inherit (pin.repository) owner repo;
repo = "mov-cli"; sha256 = pin.hash;
rev = "${version}"; rev = pin.revision;
hash = "sha256-ixv9guHfXy1kQbpAWAVwPtpxX5IwAQ8CQ2hvhM7sewg="; };
};
propagatedBuildInputs = with python3Packages; [ propagatedBuildInputs = with python3Packages; [
poetry-core poetry-core
pycryptodome pycryptodome
lxml lxml
six six
beautifulsoup4 beautifulsoup4
tldextract tldextract
(python3Packages.httpx.overrideAttrs (_old: { (python3Packages.httpx.overrideAttrs (_old: {
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "encode"; owner = "encode";
repo = "httpx"; repo = "httpx";
rev = "refs/tags/0.24.0"; rev = "refs/tags/0.24.0";
hash = "sha256-eLCqmYKfBZXCQvFFh5kGoO91rtsvjbydZhPNtjL3Zaw="; hash = "sha256-eLCqmYKfBZXCQvFFh5kGoO91rtsvjbydZhPNtjL3Zaw=";
};
}))
(
python3Packages.buildPythonPackage rec {
pname = "krfzf_py";
version = "0.0.4";
src = fetchPypi {
inherit pname version;
sha256 = "sha256-W0wpR1/HRrtYC3vqEwh+Jwkgwnfa49LCFIArOXaSPCE=";
}; };
} }))
) (
]; python3Packages.buildPythonPackage rec {
pname = "krfzf_py";
version = "0.0.4";
src = fetchPypi {
inherit pname version;
sha256 = "sha256-W0wpR1/HRrtYC3vqEwh+Jwkgwnfa49LCFIArOXaSPCE=";
};
}
)
];
meta = with lib; { meta = with lib; {
homepage = "https://github.com/mov-cli/mov-cli"; homepage = "https://github.com/mov-cli/mov-cli";
description = "A cli tool to browse and watch movies"; description = "A cli tool to browse and watch movies";
license = licenses.gpl3Only; license = licenses.gpl3Only;
mainProgram = "mov-cli"; mainProgram = "mov-cli";
}; };
} }

View file

@ -5,6 +5,7 @@
makeWrapper, makeWrapper,
pkgs, pkgs,
lib, lib,
pins,
}: }:
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
pname = "rat"; pname = "rat";