From ece61b7cc803d374e81b1094bd9c1f6d5a9ca5d0 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 22 Jul 2014 15:58:18 +0200 Subject: [PATCH] all-packages.nix: Provide a shorter way to specify packages 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 (https://github.com/NixOS/nix/pull/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. --- pkgs/auto-packages.nix | 16 ++++++++++++++++ pkgs/top-level/all-packages.nix | 34 ++++++++++++++++----------------- 2 files changed, 32 insertions(+), 18 deletions(-) create mode 100644 pkgs/auto-packages.nix diff --git a/pkgs/auto-packages.nix b/pkgs/auto-packages.nix new file mode 100644 index 00000000000000..c935f47295d38f --- /dev/null +++ b/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 +] diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 1dfc9416ebe58e..76e2ff275e6f0c 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -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; @@ -361,8 +369,6 @@ let inherit url; }; - libredirect = callPackage ../build-support/libredirect { }; - makeDesktopItem = import ../build-support/make-desktopitem { inherit stdenv; }; @@ -427,8 +433,6 @@ let ### TOOLS - acct = callPackage ../tools/system/acct { }; - acoustidFingerprinter = callPackage ../tools/audio/acoustid-fingerprinter { ffmpeg = ffmpeg_1; }; @@ -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 { }; @@ -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 { }; @@ -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 { }; @@ -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 { };