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,16 +9,18 @@
fzf,
mpv,
aria2,
}:
stdenvNoCC.mkDerivation rec {
pins,
}: let
pin = pins.ani-cli;
in
stdenvNoCC.mkDerivation {
pname = "ani-cli";
version = "4.6";
inherit (pin) version;
src = fetchFromGitHub {
owner = "pystardust";
repo = "${pname}";
rev = "v${version}";
hash = "sha256-ahyCD4QsYyb3xtNK03HITeF0+hJFIHZ+PAjisuS/Kdo=";
inherit (pin.repository) owner repo;
sha256 = pin.hash;
rev = pin.revision;
};
nativeBuildInputs = [makeWrapper];
@ -35,7 +37,7 @@ stdenvNoCC.mkDerivation rec {
homepage = "https://github.com/pystardust/ani-cli";
description = "A cli tool to browse and play anime";
license = licenses.gpl3Plus;
maintainers = with maintainers; [skykanin];
maintainers = with maintainers; [NotAShelf];
platforms = platforms.unix;
};
}

View file

@ -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 [])

View file

@ -1,20 +1,21 @@
{
lib,
pkgs,
python3Packages,
fetchFromGitHub,
fetchPypi,
}:
python3Packages.buildPythonPackage rec {
pname = "mov-cli";
version = "1.5.1";
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=";
inherit (pin.repository) owner repo;
sha256 = pin.hash;
rev = pin.revision;
};
propagatedBuildInputs = with python3Packages; [

View file

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