aboutsummaryrefslogtreecommitdiff
#include "misc.hh"
#include "store-api.hh"
#include "local-store.hh"
#include "globals.hh"


namespace nix {


Derivation derivationFromPath(StoreAPI & store, const Path & drvPath)
{
    assertStorePath(drvPath);
    store.ensurePath(drvPath);
    return readDerivation(drvPath);
}


void computeFSClosure(StoreAPI & store, const Path & path,
    PathSet & paths, bool flipDirection, bool includeOutputs, bool includeDerivers)
{
    if (paths.find(path) != paths.end()) return;
    paths.insert(path);

    PathSet edges;

    if (flipDirection) {
        store.queryReferrers(path, edges);

        if (includeOutputs) {
            PathSet derivers = store.queryValidDerivers(path);
            foreach (PathSet::iterator, i, derivers)
                edges.insert(*i);
        }

        if (includeDerivers && isDerivation(path)) {
            PathSet outputs = store.queryDerivationOutputs(path);
            foreach (PathSet::iterator, i, outputs)
                if (store.isValidPath(*i) && store.queryDeriver(*i) == path)
                    edges.insert(*i);
        }

    } else {
        store.queryReferences(path, edges);

        if (includeOutputs && isDerivation(path)) {
            PathSet outputs = store.queryDerivationOutputs(path);
            foreach (PathSet::iterator, i, outputs)
                if (store.isValidPath(*i)) edges.insert(*i);
        }

        if (includeDerivers) {
            Path deriver = store.queryDeriver(path);
            if (store.isValidPath(deriver)) edges.insert(deriver);
        }
    }

    foreach (PathSet::iterator, i, edges)
        computeFSClosure(store, *i, paths, flipDirection, includeOutputs, includeDerivers);
}


static void dfsVisit(StoreAPI & store, const PathSet & paths,
    const Path & path, PathSet & visited, Paths & sorted,
    PathSet & parents)
{
    if (parents.find(path) != parents.end())
        throw BuildError(format("cycle detected in the references of `%1%'") % path);

    if (visited.find(path) != visited.end()) return;
    visited.insert(path);
    parents.insert(path);

    PathSet references;
    if (store.isValidPath(path))
        store.queryReferences(path, references);

    foreach (PathSet::iterator, i, references)
        /* Don't traverse into paths that don't exist.  That can
           happen due to substitutes for non-existent paths. */
        if (*i != path && paths.find(*i) != paths.end())
            dfsVisit(store, paths, *i, visited, sorted, parents);

    sorted.push_front(path);
    parents.erase(path);
}


Paths topoSortPaths(StoreAPI & store, const PathSet & paths)
{
    Paths sorted;
    PathSet visited, parents;
    foreach (PathSet::const_iterator, i, paths)
        dfsVisit(store, paths, *i, visited, sorted, parents);
    return sorted;
}


}
ic): New variable. Nicolas Goaziou 2019-03-12gnu: gcompris-qt: Update to 0.96....* gnu/packages/education.scm (gcompris-qt): Update to 0.96. [inputs]: Add openssl. Tobias Geerinckx-Rice 2019-01-16gnu: Move sqlite to separate module....* gnu/packages/databases.scm (sqlite, sqlite-3.26.0, sqlite-with-fts5, sqlite-with-column-metadata): Move variables from here... * gnu/packages/sqlite.scm: ...to this new module. * gnu/local.mk (GNU_SYSTEM_MODULES): Add it. * gnu/packages/apl.scm, gnu/packages/bittorrent.scm, gnu/packages/calendar.scm, gnu/packages/code.scm, gnu/packages/crypto.scm, gnu/packages/databases.scm, gnu/packages/dc.scm, gnu/packages/disk.scm, gnu/packages/ebook.scm, gnu/packages/education.scm, gnu/packages/emacs.scm, gnu/packages/emulators.scm, gnu/packages/file-systems.scm, gnu/packages/freedesktop.scm, gnu/packages/ftp.scm, gnu/packages/games.scm, gnu/packages/geo.scm, gnu/packages/gnome.scm, gnu/packages/gnunet.scm, gnu/packages/gnupg.scm, gnu/packages/gnuzilla.scm, gnu/packages/gps.scm, gnu/packages/guile.scm, gnu/packages/ibus.scm, gnu/packages/kerberos.scm, gnu/packages/kodi.scm, gnu/packages/lisp.scm, gnu/packages/mail.scm, gnu/packages/messaging.scm, gnu/packages/mpd.scm, gnu/packages/music.scm, gnu/packages/networking.scm, gnu/packages/nfs.scm, gnu/packages/ocaml.scm, gnu/packages/package-management.scm, gnu/packages/pdf.scm, gnu/packages/photo.scm, gnu/packages/php.scm, gnu/packages/python.scm, gnu/packages/qt.scm, gnu/packages/ruby.scm, gnu/packages/scheme.scm, gnu/packages/sync.scm, gnu/packages/syndication.scm, gnu/packages/version-control.scm, gnu/packages/video.scm, gnu/packages/web-browsers.scm, gnu/packages/webkit.scm: Adjust module references. Ricardo Wurmus 2018-12-24gnu: gcompris-qt: Enable tests....* gnu/packages/education.scm (gcompris-qt)[arguments]: Add custom phase to start X server before tests. Add configure flag to build tests. Enable tests. [native-inputs]: Add xorg-server. Efraim Flashner 2018-12-24gnu: gcompris-qt: Update to 0.95....* gnu/packages/education.scm (gcompris-qt): Update to 0.95. [arguments]: Remove custom phase to patch for qt@5.11. Efraim Flashner 2018-12-14gnu: snap: Update to 4.2.2.9....* gnu/packages/education.scm (snap): Update to 4.2.2.9. Nicolas Goaziou 2018-10-22gnu: snap: Update to 4.2.2.2....* gnu/packages/education.scm (snap): Update to 4.2.2.2. Update source URL. Nicolas Goaziou 2018-09-21gnu: snap: Update to 4.2.1.4....* gnu/packages/education.scm (snap): Update to 4.2.1.4. Nicolas Goaziou 2018-08-10gnu: snap: Update to 4.2.1.3....* gnu/packages/education.scm (snap): Update to 4.2.1.3. Nicolas Goaziou 2018-06-03gnu: gcompris-qt: Update to 0.91....* gnu/packages/education.scm (gcompris-qt): Update to 0.91. [arguments]: Add custom phase to fix building with Qt 5.11. Efraim Flashner 2018-05-31gnu: tipp10: Use INVOKE....* gnu/packages/education.scm (tipp10)[arguments]: Substitute INVOKE for SYSTEM*. Tobias Geerinckx-Rice 2018-05-11gnu: Add snap....* gnu/packages/education.scm (snap): New variable. Nicolas Goaziou 2018-04-22gnu: gcompris-qt: Update to 0.90....* gnu/packages/education.scm (gcompris-qt): Update to 0.90. [source, home-page]: Use https. [arguments]: Add 'wrap-executable phase to declare the QT_PLUGIN_PATH and QML2_IMPORT_PATH without needing propagated inputs. [native-inputs]: Add qttools. [inputs]: Remove qt, add qtbase, qtdeclarative, qtgraphicaleffects, qtmultimedia, qtquickcontrols, qtsensors, qtsvg, qtxmlpatterns. Efraim Flashner 2017-07-05gnu: gcompris: Update to 17.05....* gnu/packages/education.scm (gcompris): Update to 17.05. Efraim Flashner 2017-04-26gnu: Add gcompris-qt....* gnu/packages/education.scm (gcompris-qt): New variable. Efraim Flashner 2017-03-02gnu: Merge the two stellaria into one....* gnu/packages/astronomy.scm (stellaruim): Merge details from stellarium-0.14. * gnu/packages/education.scm (stellarium): Remove variable. John Darrington 2017-01-15gnu: tipp10: Adjust phases....* gnu/packages/education.scm (tipp10)[arguments]: Return #t for "disable-new-version-check"; fix indentation. Ricardo Wurmus 2017-01-15gnu: tipp10: Fix description....* gnu/packages/education.scm (tipp10)[description]: Do not mention operating systems; remove hint about language settings. Ricardo Wurmus 2017-01-14gnu: Add tipp10 touch typing tutor....* gnu/packages/education.scm (touch10): New variable. * gnu/packages/patches/tipp10-fix-compiling.patch, gnu/packages/patches/tipp10-remove-license-code.patch: New files. * gnu/local.mk (dist_patch_DATA): Register them. Hartmut Goebel 2016-09-28gnu: Add and use gettext-minimal....* gnu/packages/gettext.scm (gnu-gettext): Rename to... (gettext-minimal): ... this. Adjust synopsis and description. (gnu-gettext): Inherit from it. (po4a): Use 'gettext-minimal' instead of 'gnu-gettext'. * gnu/packages/acl.scm: Likewise. * gnu/packages/admin.scm: Likewise. * gnu/packages/apl.scm: Likewise. * gnu/packages/attr.scm: Likewise. * gnu/packages/audio.scm: Likewise. * gnu/packages/base.scm: Likewise. * gnu/packages/cdrom.scm: Likewise. * gnu/packages/commencement.scm: Likewise. * gnu/packages/crypto.scm: Likewise. * gnu/packages/databases.scm: Likewise. * gnu/packages/disk.scm: Likewise. * gnu/packages/documentation.scm: Likewise. * gnu/packages/education.scm: Likewise. * gnu/packages/engineering.scm: Likewise. * gnu/packages/enlightenment.scm: Likewise. * gnu/packages/fcitx.scm: Likewise. * gnu/packages/fontutils.scm: Likewise. * gnu/packages/freedesktop.scm: Likewise. * gnu/packages/games.scm: Likewise. * gnu/packages/gkrellm.scm: Likewise. * gnu/packages/glib.scm: Likewise. * gnu/packages/gnome.scm: Likewise. * gnu/packages/grub.scm: Likewise. * gnu/packages/gtk.scm: Likewise. * gnu/packages/guile.scm: Likewise. * gnu/packages/ibus.scm: Likewise. * gnu/packages/irc.scm: Likewise. * gnu/packages/iso-codes.scm: Likewise. * gnu/packages/kde-frameworks.scm: Likewise. * gnu/packages/kodi.scm: Likewise. * gnu/packages/linux.scm: Likewise. * gnu/packages/man.scm: Likewise. * gnu/packages/maths.scm: Likewise. * gnu/packages/mono.scm: Likewise. * gnu/packages/mp3.scm: Likewise. * gnu/packages/music.scm: Likewise. * gnu/packages/nano.scm: Likewise. * gnu/packages/networking.scm: Likewise. * gnu/packages/package-management.scm: Likewise. * gnu/packages/pdf.scm: Likewise. * gnu/packages/sawfish.scm: Likewise. * gnu/packages/statistics.scm: Likewise. * gnu/packages/terminals.scm: Likewise. * gnu/packages/version-control.scm: Likewise. * gnu/packages/vpn.scm: Likewise. * gnu/packages/w3m.scm: Likewise. * gnu/packages/webkit.scm: Likewise. * gnu/packages/wicd.scm: Likewise. * gnu/packages/wine.scm: Likewise. * gnu/packages/xdisorg.scm: Likewise. * gnu/packages/xorg.scm: Likewise. Alex Kost 2016-08-03gnu: Add GCompris....* gnu/packages/education.scm (gcompris): New variable. Ricardo Wurmus 2016-07-30gnu: stellarium: Improve description....Suggested by Danny Milosavljevic <dannym@scratchpost.org>. * gnu/packages/education.scm (stellarium)[description]: Mention telescope tracking. Leo Famulari 2016-07-29gnu: Add stellarium....* gnu/local.mk: Include gnu/packages/education.scm . * gnu/packages/education.scm: Add new file. * gnu/packages/education.scm (stellarium): New variable. Signed-off-by: Ludovic Courtès <ludo@gnu.org> Danny Milosavljevic