1
1
mirror of https://github.com/divnix/digga.git synced 2024-12-24 08:32:54 +03:00
digga/pkgs/README.md
Timothy DeHerrera 25180a5e6e
pkgs: use subflake to manage package sources
* Resolves #118
* Leverage flakes to manage package sources & hashes
* Update documentation with an example.
* Add `mkVersion` function to autogenerate a version string.
* Add srcs package via overlay containing all sources defined in
  _pkgs/flake.nix_
* Extend `flk update` with the ability to only update the given input
2021-02-26 00:15:45 -07:00

1.9 KiB

Packages

Similar to modules, the pkgs directory mirrors the upstream nixpkgs/pkgs, and for the same reason; if you ever want to upstream your package, it's as simple as dropping it into the nixpkgs/pkgs directory.

The only minor difference is that, instead of adding the callPackage call to all-packages.nix, you just add it the the default.nix in this directory, which is defined as a simple overlay.

This overlay is set as the default overlay output attribute for the flake. And all the packages are exported via packages.<system>.<pkg-name>, for all the supported systems listed in the package's meta.platforms attribute.

And, as usual, every package in the overlay is also available to any NixOS host.

Automatic Source Updates

There is the added, but optional, convenience of declaring your sources in pkgs/flake.nix as an input. This allows updates to be managed automatically by simply updating the lock file. No more manually entering sha256 hashes!

Example

pkgs/development/libraries/libinih/default.nix:

{ stdenv, meson, ninja, lib, srcs, ... }:
let version = "r53";
in
stdenv.mkDerivation {
  pname = "libinih";
  inherit version;

  src = srcs.libinih;

  buildInputs = [ meson ninja ];

  mesonFlags = ''
    -Ddefault_library=shared
    -Ddistro_install=true
  '';

  meta = with lib; {
    description = "Simple .INI file parser in C";
    homepage = "https://github.com/benhoyt/inih";
    maintainers = [ maintainers.divnix ];
    license = licenses.bsd3;
    platforms = platforms.all;
    inherit version;
  };
}

pkgs/default.nix:

final: prev: {
  libinih = prev.callPackage ./development/libraries/libinih { };
}

pkgs/flake.nix:

{
  description = "Package sources";

  inputs = {
    libinih.url = "github:benhoyt/inih/r53";
    libinih.flake = false;
  };
}