List of favorite Reference Packages/Modules

I loved the Nix Pills covering how to create builders and everything. Later when I started looking at real packages though I realized that the packages we really use are quite different, there are a ton of great tools in the std library that make things much simpler.

Ideally there would be a really nice documentation covering the use of those libraries, but for now I have learned the most by grepping around the pkgs and taking bits of pieces from existing ones.
Each time I set out to do this I always wind up spending a lot of time hunting around for some of the simpler packages that might be easier to learn from.

I thought it would be worthwhile to compile a list of packages that are useful for that purpose.

Good categories (for both pkgs and modules) might be :

Basic Applications:

  • An example with libraries
  • An example with Preloading
  • An example with patching

Basic Services :

  • User level
  • System level

I think you get the idea. Let me know what your favorite reference packages are :smile:


Packages :

  • pkgs/applications/audio/mopidy

    • Multiple good examples of wrapping python packages
    • Good examples of how to create packages with extensions
  • pkgs/applications/editors/ed/

    • Super super simple package, a great choice to practicing your first package.
  • pkgs/applications/editors/nano/

    • Simple package that has an easy intro into a common library/derivation functions :
      • fetchFromGithub
      • optional buildInputs
      • configureFlags
      • multiple outputs
      • a simple postInstall for a config file.
  • pkgs/build-support/

    • A huge collection of helpful build tools for common tasks that will save you hours.

Modules :

  • nixos/modules/services/audio/mopidy.nix

    • Good example of creating a service module
  • nixos/modules/services/window-managers/xmonad.nix

    • Nice example of handling Haskell optional packages (GHC needs extra love)
    • Nice example of turning a run of the mill application into a service with “waitPID”
  • nixos/modules/profiles/all-hardware.nix

    • Not super useful for designed new modules, but if you are looking for a full list of firmware kernel modules to pick and choose from, this is a great resource. Select the ones you actually need rather than installing everything.
  • nixos/modules/system/etc/

    • Great reference to see the order that /etc is built in, and how to extend it. This can solve a lot of the headaches that go along with setting up your system wideenvironment, and in some cases user environments.
  • nixos/modules/programs/environment.nix

    • More reference for how the system/user environments are set up. (This is in such a weird spot. Why “programs”?)
  • nixos/modules/programs/zsh/zsh.nix

    • Fantastic examples of creating files in /etc
    • This folder has great examples of how to add zsh-plugins as modules.
4 Likes

Good idea, good examples are a bit hard to find. In my imagined perfect list of introductory examples, I would also like to see an example of a dev package (with outputs to lib and include), changes to buildFlags and the other *Flags, and also buildStage - those are all fairly common things to do.