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;
}


}
* gnu/packages/gnome-xyz.scm (flat-remix-gtk-theme): New variable. Signed-off-by: Christopher Baines <mail@cbaines.net> Sughosha 2023-03-01gnu: Add flat-remix-icon-theme....* gnu/packages/gnome-xyz.scm (flat-remix-icon-theme): New variable. Signed-off-by: Christopher Baines <mail@cbaines.net> Sughosha 2023-02-25gnu: Add postmarketos-theme....* gnu/packages/gnome-xyz.scm (postmarketos-theme): New variable. Signed-off-by: Ludovic Courtès <ludo@gnu.org> conses 2023-02-12gnu: papirus-icon-theme: Harden links before cache generation....Output is identical. This just feels moar correct. * gnu/packages/gnome-xyz.scm (papirus-icon-theme)[arguments]: Run the 'halve-inode-consumption phase before the 'install one. Tobias Geerinckx-Rice 2023-02-12gnu: papirus-icon-theme: Recursively resolve symlinks....This follows up on commit aed385e18ec7b68a0bc1bb4b173aeadc9cd97245. * gnu/packages/gnome-xyz.scm (papirus-icon-theme)[arguments]: Replace READLINK with CANONICALIZE-PATH to resolve symlink chains. Tobias Geerinckx-Rice 2023-01-29gnu: papirus-icon-theme: Reduce inode consumption....* gnu/packages/gnome-xyz.scm (papirus-icon-theme)[arguments]: Add a new 'halve-inode-consumption phase. Tobias Geerinckx-Rice 2023-01-31gnu: arc-theme: Update to 20221218....* gnu/packages/gnome-xyz.scm (arc-theme): Update to 20221218. [arguments]: Add gtk4 to the list of themes. [inputs]: Add gtk-engines. Signed-off-by: Christopher Baines <mail@cbaines.net> Sughosha 2023-01-31gnu: materia-theme: Update to 20210322....* gnu/packages/gnome-xyz.scm (materia-theme): Update to 20210322. Signed-off-by: Christopher Baines <mail@cbaines.net> Sughosha 2023-01-28gnu: papirus-icon-theme: Update to 20230104....* gnu/packages/gnome-xyz.scm (papirus-icon-theme): Update to 20230104. Signed-off-by: 宋文武 <iyzsong@member.fsf.org> Sughosha 2023-01-22gnu: gnome-shell-extension-radio: Update to 20....* gnu/packages/gnome-xyz.scm (gnome-shell-extension-radio): Update to 20. Signed-off-by: Liliana Marie Prikler <liliana.prikler@gmail.com> Sughosha 2023-01-05gnu: Add yaru-theme...* gnu/packages/gnome-xyz (yaru-theme): New variable Signed-off-by: Ludovic Courtès <ludo@gnu.org> florhizome 2022-12-24gnu: gnome-shell-extension-burn-my-windows: Update to 22....* gnu/packages/gnome-xyz (gnome-shell-extension-burn-my-windows): Update to 22. Signed-off-by: Liliana Marie Prikler <liliana.prikler@gmail.com> Sughosha 2022-12-24gnu: gnome-shell-extension-vertical-overview: Update to 10....* gnu/packages/gnome-xyz.scm (gnome-shell-extension-vertical-overview): Update to 10. Signed-off-by: Liliana Marie Prikler <liliana.prikler@gmail.com> Sughosha 2022-12-24gnu: gnome-shell-extension-unite-shell: Update to 69....* gnu/packages/gnome-xyz.scm (gnome-shell-extension-unite-shell): Update to 69. Signed-off-by: Liliana Marie Prikler <liliana.prikler@gmail.com> Sughosha 2022-12-07gnu: gpaste: Update to 42.2....Fixes <https://issues.guix.gnu.org/58191>. Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com> Attila Lendvai 2022-12-07gnu: gpaste: Fix missing @gschemasCompiled@ substitute....* gnu/packages/gnome-xyz.scm (gpaste) [phases] {fix-introspection-install-dir}: Substitute @gschemasCompiled@ placeholder. Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com> Attila Lendvai