Skip to content

Commit

Permalink
all-packages.nix: Provide a shorter way to specify packages
Browse files Browse the repository at this point in the history
There are zillions of lines of the form

  foo = callPackage ../bla/foo { };

in all-packages.nix. To get rid of this verbosity, you can now list
such packages in pkgs/auto-packages.nix. This is just a list of
package file names, e.g.

  development/libraries/libogg
  development/libraries/libvorbis
  tools/archivers/gnutar

If the package needs non-default function arguments, or if its
intended attribute name is different from its file name, then you
cannot put it in auto-packages.nix and instead need to specify it in
all-packages.nix.

If Nix had a glob function (NixOS/nix#235), we
could even get rid of auto-packages.nix and have package expressions
be discovered automatically. However, that might not be desirable
because of the need to traverse the file system to find packages we
may not even use.
  • Loading branch information
edolstra committed Jul 22, 2014
1 parent beb47fa commit ece61b7
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 18 deletions.
16 changes: 16 additions & 0 deletions pkgs/auto-packages.nix
@@ -0,0 +1,16 @@
/* A list of file names of package Nix expressions, whose base names
match the intended attribute names, and that do not need to be
called with any overrides. Thus, listing ‘./foo.nix’ here is
equivalent to defining the attribute
foo = callPackage ./foo.nix { };
in all-packages.nix. */

[
build-support/libredirect
development/libraries/libogg
development/libraries/libvorbis
tools/archivers/gnutar
tools/system/acct
]
34 changes: 16 additions & 18 deletions pkgs/top-level/all-packages.nix
Expand Up @@ -130,11 +130,19 @@ let
in pkgs;


# The package compositions. Yes, this isn't properly indented.
# The package compositions.
pkgsFun = pkgs: overrides:
with helperFunctions;
let defaultScope = pkgs // pkgs.xorg; self = self_ // overrides;
self_ = with self; helperFunctions // {
let
defaultScope = pkgs // pkgs.xorg;
autoPackages = lib.listToAttrs
(map (fn: { name = baseNameOf (toString fn); value = pkgs.callPackage fn { }; })
(import ../auto-packages.nix));
self = self_ // autoPackages // overrides;
self_ = with self; helperFunctions //


# Yes, this isn't properly indented.
{

# Make some arguments passed to all-packages.nix available
inherit system stdenvType platform;
Expand Down Expand Up @@ -361,8 +369,6 @@ let
inherit url;
};

libredirect = callPackage ../build-support/libredirect { };

makeDesktopItem = import ../build-support/make-desktopitem {
inherit stdenv;
};
Expand Down Expand Up @@ -427,8 +433,6 @@ let

### TOOLS

acct = callPackage ../tools/system/acct { };

acoustidFingerprinter = callPackage ../tools/audio/acoustid-fingerprinter {
ffmpeg = ffmpeg_1;
};
Expand Down Expand Up @@ -1159,8 +1163,6 @@ let

gnused = callPackage ../tools/text/gnused { };

gnutar = callPackage ../tools/archivers/gnutar { };

gnuvd = callPackage ../tools/misc/gnuvd { };

goaccess = callPackage ../tools/misc/goaccess { };
Expand Down Expand Up @@ -5366,8 +5368,6 @@ let

libofx = callPackage ../development/libraries/libofx { };

libogg = callPackage ../development/libraries/libogg { };

liboggz = callPackage ../development/libraries/liboggz { };

liboil = callPackage ../development/libraries/liboil { };
Expand Down Expand Up @@ -5534,8 +5534,6 @@ let

libvterm = callPackage ../development/libraries/libvterm { };

libvorbis = callPackage ../development/libraries/libvorbis { };

libwebp = callPackage ../development/libraries/libwebp { };

libwmf = callPackage ../development/libraries/libwmf { };
Expand Down Expand Up @@ -10417,13 +10415,13 @@ let
callPackage = newScope pkgs.cinnamon;
inherit (gnome3) gnome_common libgnomekbd gnome-menus zenity;

muffin = callPackage ../desktops/cinnamon/muffin.nix { } ;
muffin = callPackage ../desktops/cinnamon/muffin.nix { };

cinnamon-control-center = callPackage ../desktops/cinnamon/cinnamon-control-center.nix{ };
cinnamon-control-center = callPackage ../desktops/cinnamon/cinnamon-control-center.nix { };

cinnamon-settings-daemon = callPackage ../desktops/cinnamon/cinnamon-settings-daemon.nix{ };
cinnamon-settings-daemon = callPackage ../desktops/cinnamon/cinnamon-settings-daemon.nix { };

cinnamon-session = callPackage ../desktops/cinnamon/cinnamon-session.nix{ } ;
cinnamon-session = callPackage ../desktops/cinnamon/cinnamon-session.nix { };

cinnamon-desktop = callPackage ../desktops/cinnamon/cinnamon-desktop.nix { };

Expand Down

3 comments on commit ece61b7

@vcunat
Copy link
Member

@vcunat vcunat commented on ece61b7 Jul 22, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know... I quite utilized the fact that all top-level attributes were easy to find in all-packages.nix, but moving auto-packages into all-packages might be confusing.

@tailhook
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If Nix had a glob function (NixOS/nix#235), we
could even get rid of auto-packages.nix and have package expressions
be discovered automatically. However, that might not be desirable
because of the need to traverse the file system to find packages we
may not even use.

Kinda weird motivation. If there are packages that "we may not even use" why they are in the git repository in the first place?

Also if nix had glob function the files that are not used may probably be never read, by using lazy evaluation (unless a list of packages is required).

@edolstra
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not being used meaning "not used by the current evaluation". For instance, a NixOS evaluation typically only accesses a small subset of Nixpkgs.

Please sign in to comment.