• Stars
    star
    150
  • Rank 240,073 (Top 5 %)
  • Language
    Nix
  • License
    MIT License
  • Created over 1 year ago
  • Updated 10 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Configure packages like NixOS systems

drv-parts

This is experimental, use with care!

drv-parts replaces callPackage, override, overrideAttrs, ... as a mechanism for configuring packages. It makes package configuration feel similar to NixOS system configuration.

This is an implementation of ideas first drafted at DavHau/pkgs-modules.

It is recommended to use drv-parts through flake-parts (see examples/flake-parts).

There is also support for flake-less usage (see examples/no-flake).

Funding by NLNet

drv-parts was funded as part of the dream2nix project through the NGI Assure Fund, a fund established by NLnet with financial support from the European Commission's Next Generation Internet programme, under the aegis of DG Communications Networks, Content and Technology under grant agreement No 957073. Applications are still open, you can apply today.

Why Modules?

Declaring derivations as modules solves a number of issues. For more details on the problems, visit DavHau/pkgs-modules. Also I recommend watching @edolstra 's talk about this topic.

Benefits

No more override functions

Changing options of packages in nixpkgs can require chaining different override functions like this:

{
  htop-mod = let
    htop-overridden = pkgs.htop.overrideAttrs (old: {
      pname = "htop-mod";
    });
  in
    htop-overridden.override (old: {
      sensorsSupport = false;
    });
}

... while doing the same using drv-parts looks like this:

{
  htop-mod = {
    imports = [./htop.nix];
    name = lib.mkForce "htop-mod";
    flags.sensorsSupport = false;
  };
}

See htop module definition here.

Type safety

The following code in nixpkgs mkDerivation mysteriously skips the patches:

mkDerivation {
  # ...
  dontPatch = "false";
}

... while doing the same using drv-parts raises an informative type error:

A definition for option `[...].dontPatch' is not of type `boolean' [...]

Catch typos

The following code in nixpkgs mkDerivation builds without openssl_3.

mkDerivation {
  # ...
  nativBuildInputs = [openssl_3];
}

... while doing the same using drv-parts raises an informative error:

The option `[...].nativBuildInputs' does not exist

Environment variables clearly defined

drv-parts requires a clear distinction between known parameters and user-defined variables. Defining SOME_VARIABLE at the top-level, would raise:

The option `[...].SOME_VARIABLE' does not exist

Instead it has to be defined under env.:

{
  my-package = {
    # ...
    env.SOME_VARIABLE = "example";
  };
}

Package options documentation

Documentation similar to search.nixos.org can be generated for packages declared via drv-parts.

This is not yet implemented.

Package blueprints

With drv-parts, packages don't need to be fully declared. Options can be left without defaults, requiring the consumer to complete the definition.

For example, this can be useful for lang2nix tools, where src and version are dynamically provided by a lock file parser.

Freedom of abstraction

The nixos module system gives maintainers more freedom over how packages are split into modules. Separation of concerns can be implemented more easily. For example, the dependency tree of a package set can be factored out into a separate module, allowing for simpler modification.

More Repositories

1

mach-nix

Create highly reproducible python environments
Python
834
star
2

nix-portable

Nix - Static, Permissionless, Installation-free, Pre-configured
Nix
726
star
3

pypi-deps-db

Dependency DB for python packages on pypi
Python
65
star
4

django-nixos

NixOS/NixOps configuration for Django
Nix
32
star
5

systemd2nix

Convert systemd service files to Nix syntax
Python
28
star
6

pkgs-modules

The Ideal interface for configuring packages
Nix
22
star
7

nix-on-armv7l

Nix without NixOS on arm32v7 / armv7l / Raspberry Pi OS / Raspbian
Dockerfile
18
star
8

nix-pypi-fetcher

Pypi Fetcher for Nix with simplified interface. (contains hashes for all packages)
Python
13
star
9

motioneye-loop-record

Addon for motion / motioneye / motionEyeOs to enable the missing loop recoding functionality
Python
11
star
10

nixos-steam-box

A linux based gaming console based on NixOS + Steam Big Picture
Nix
10
star
11

nix-eval-cache

Cache evaluation of nix functions
Nix
10
star
12

build-modules

low level module system for nix builds / alternative stdenv
Nix
9
star
13

edict

Run nix commands on remote machines
9
star
14

fromYaml

yaml parser in pure nix
Nix
7
star
15

nix-pypi-fetcher-2

DB of pypi URLs and hashes
Python
4
star
16

nix-toolbox

Nix
4
star
17

cabal2json

zurihack experiment
Haskell
4
star
18

nix-early-cutoff

Prevent re-builds of derivations depending on source
Nix
3
star
19

conda-channels

regular snapshots of multiple conda channels
Nix
2
star
20

flake-templates

Collection of flake templates
Nix
2
star
21

zfs-enc-automount

Simple tool to automount encrypted zfs datasets on boot while storing the password on a remote host
Shell
2
star
22

nixops-vbox-base-image

Declarative definition of an up-to-date virtualbox base image for your nixops project
Nix
2
star
23

dream2nix-auto-test

test repo for dream2nix auto-generated package sets
Nix
2
star
24

flake-parts-auto

Auto import and expose modules in your flake
Nix
2
star
25

dump

Mono repo of DavHau
Nix
1
star
26

betfair-csv-downloader

Tool to mass download csv files from https://promo.betfair.com/betfairsp/prices.
Python
1
star
27

octodns-nix

octodns packaged for the nix package manager
Nix
1
star
28

hyperconfig

NixOS configs of DavHau
Nix
1
star
29

heroku-nix-notes

Notes on heroku deployments with nix
1
star
30

nix-bootstrap-binaries

bootstrap binaries for an alternative stdenv
Nix
1
star
31

nix-parallel-ifd

Demonstration of performance opportunities in IFD evaluation
Nix
1
star
32

DavHau.github.io

HTML
1
star