nvfetcher: Generate nix sources expr for the latest version of packages

[ library, mit, nix, program ] [ Propose Tags ]

Please see README


[Skip to Readme]

Flags

Manual Flags

NameDescriptionDefault
build-example

Build example executable

Disabled

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.2.0.0, 0.3.0.0, 0.4.0.0, 0.5.0.0, 0.6.0.0, 0.6.1.0, 0.6.2.0
Change log CHANGELOG.md
Dependencies aeson (>=1.5.6 && <1.6), base (>=4.8 && <5), binary, bytestring, extra (>=1.7.9 && <1.8), free (>=5.1.5 && <5.2), neat-interpolation (>=0.5.1 && <0.6), nvfetcher, shake (>=0.19.4 && <0.20), text, tomland (>=1.3.2 && <1.4), transformers, unordered-containers, validation-selective [details]
License MIT
Copyright 2021 berberman
Author berberman
Maintainer berberman <berberman.yandex.com>
Category Nix
Home page https://github.com/berberman/nvfetcher
Bug tracker https://github.com/berberman/nvfetcher/issues
Source repo head: git clone https://github.com/berberman/nvfetcher.git
Uploaded by berberman at 2021-05-10T12:04:39Z
Distributions NixOS:0.6.2.0
Executables example, nvfetcher
Downloads 706 total (28 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user [build log]
All reported builds failed as of 2021-05-10 [all 3 reports]

Readme for nvfetcher-0.1.0.0

[back to package description]

nvfetcher

Hackage MIT license nix

nvfetcher is a tool to automate packages updates in flakes repos. It's built on top of shake, integrating nvchecker. It's very simple -- most complicated works are done by nvchecker, nvfetcher just wires it with prefetch tools, producing only one artifact as the result of build. nvfetcher cli program accepts a TOML file as config, which defines a set of package sources to run.

Overview

For example, given the following configuration file:

# nvfetcher.toml
[feeluown-core]
src.pypi = "feeluown"
fetch.pypi = "feeluown"

[qliveplayer]
src.github = "IsoaSFlus/QLivePlayer"
fetch.github = "IsoaSFlus/QLivePlayer"

running nvfetcher build will create sources.nix like:

# sources.nix
{ fetchgit, fetchurl }:
{
  feeluown-core = {
    pname = "feeluown-core";
    version = "3.7.6";
    src = fetchurl {
      sha256 = "1bsz149dv3j5sfbynjrqsqbkkxdxkdlq4sdx2vi8whvfwfg0j2f0";
      url = "https://pypi.io/packages/source/f/feeluown/feeluown-3.7.6.tar.gz";
    };
  };
  qliveplayer = {
    pname = "qliveplayer";
    version = "3.22.0";
    src = fetchgit {
      url = "https://github.com/IsoaSFlus/QLivePlayer";
      rev = "3.22.0";
      fetchSubmodules = false;
      deepClone = false;
      leaveDotGit = false;
      sha256 = "192g42pvibms2rsjh68fck4bj59b10ay9zqcf2hqhcka0xmnyb09";
    };
  };
}

We tell nvfetcher how to get the latest version number of packages and how to fetch their sources given version numbers, and nvfetcher will help us keep their version and prefetched SHA256 sums up-to-date, stored in sources.nix. Shake will help us handle necessary rebuilds -- we check versions of packages during each run, but only prefetch them when needed.

Live examples

How to use the generated sources file? Here are some examples:

Usage

Basically, there are two ways to use nvfetcher, where the difference is how we provide package sources definitions to it. No matter which way you use it in, CLI options are inherited from shake with two targets, typically used as:

  • nvfetcher build - our main purpose, creating sources.nix
  • nvfetcher clean - clean up cache and remove sources.nix

nvfetcher uses build as the target if no specified

You can specify -j to enable parallelism

CLI

To run nvfetcher as a CLI program, you'll need to provide package sources defined in TOML.

Aavailable CLI options:

  • -c (--config) - path to the TOML configuration file
  • -o (--output) - path to the output nix file
  • -v (--version) - print nvfetcher version
  • -l (--log) - path to log file, where nvfetcher dumps the version changes

Each package corresponds to a TOML table, whose name is encoded as table key; there are two pairs in each table:

  • a nvchecker configuration, how to track version updates
    • src.github = owner/repo - the latest gituhb release
    • src.pypi = pypi_name - the latest pypi release
    • src.git = git_url - the latest commit of a repo
    • src.archpkg = archlinux_pkg_name -- the latest version of an archlinux package
    • src.aur = aur_pkg_name -- the latest version of an aur package
    • src.manual = v -- a fixed version, which never updates
    • src.repology = project:repo -- the latest version from repology
  • a nix fetcher function, how to fetch the package given the version number. $ver is available, which will be set to the result of nvchecker.
    • fetch.github = owner/repo or owner/repo:rev (default to $ver if no rev specified)
    • fetch.pypi = pypi_name or pypi_name:ver (default to $ver if no ver specified)
    • fetch.git = git_url or git_url:rev (default to $ver if no rev specified)
    • fetch.url = url

You can find an example of the configuration file, see nvfetcher_example.toml.

Haskell library

nvfetcher itsetlf is a Haskell library as well, whereas the CLI program is just a trivial wrapper of the library. You can create a Haskell program depending on it directly, creating an entry point. In this case, we can define packages in Haskell language, getting rid of TOML constraints.

You can find an example of using nvfetcher in the library way, see Main_example.hs.

Documentation

For details of the library, documentation of released versions is available on Hackage, and of master is on our github pages.

Limitations

There is no way to check the equality over version sources and fetchers, so If you change either of them in a package, you will need to rebuild everything, i.e. run nvfetcher clean to remove shake databsae, to make sure that our build system works correctly. We could automate this process, for example, calculate the hash of the configuration file and bump shakeVersion to trigger the rebuild. However, this shouldn't happen frequently and we want to minimize the changes, so it's left for you to do manually.

Adding or removing a package doesn't require such rebuild

Contributing

Issues and PRs are always welcome. _(:з」∠)_