#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); } Path findOutput(const Derivation & drv, string id) { foreach (DerivationOutputs::const_iterator, i, drv.outputs) if (i->first == id) return i->second.path; throw Error(format("derivation has no output `%1%'") % id); } 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; } } 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
A big thanks to Eelco Dolstra, who designed and implemented Nix.
Transposing functional programming discipline to package management
proved to be inspiring and fruitful.
Thanks to the following people who contributed to GNU Guix through
suggestions, bug reports, patches, internationalization, or general
infrastructure help:
Lluís Batlle i Rossell <viric@viric.name>
Sylvain Beucler <beuc@beuc.net>
Carlos Carleos <carleos@uniovi.es>
Felipe Castro <fefcas@gmail.com>
Daniel Clark <dclark@pobox.com>
Alexandru Cojocaru <xojoc@gmx.com>
Aleix Conchillo Flaqué <aconchillo@gmail.com>
Malcolm Cook <MEC@stowers.org>
Thomas Danckaert <thomas.danckaert@gmail.com>
Rafael Ferreira <rafael.f.f1@gmail.com>
Christian Grothoff <christian@grothoff.org>
Eric Hanchrow <eric.hanchrow@gmail.com>
Konrad Hinsen <konrad.hinsen@fastmail.net>
Brandon Invergo <brandon@gnu.org>
Anders Jonsson <anders.jonsson@norsjovallen.se>
Jeffrin Jose <ahiliation@yahoo.co.in>
Kete <kete@ninthfloor.org>
Daniel Kochmański <dkochmanski@hellsgate.pl>
Matthew Lien <bluet@bluet.org>
Dave Love <fx@gnu.org>
Chris Marusich <cmmarusich@gmail.com>
Niels Möller <nisse@lysator.liu.se>
Cyprien Nicolas <cyprien@nicolas.tf>
Yutaka Niibe <gniibe@fsij.org>
Andrei Osipov <andrspv@gmail.com>
Petter <petter@mykolab.ch>
Adam Pribyl <pribyl@lowlevel.cz>
Pjotr Prins <pjotr.public12@thebird.nl>
Yakkala Yagnesh Raghava <hi@yagnesh.org>
Joshua Randall <jcrandall@alum.mit.edu>
Bruno Félix Rezende Ribeiro <oitofelix@gnu.org>
Benno Schulenberg <coordinator@translationproject.org>
Thomas Schwinge <thomas@codesourcery.com>
Alexander Shendi <Alexander.Shendi@web.de>
Alen Skondro <askondro@gmail.com>
Jan Synáček <jan.synacek@gmail.com>
Matthias Wachs <wachs@net.in.tum.de>
Christopher Allan Webber <cwebber@dustycloud.org>
Philip Woods <elzairthesorcerer@gmail.com>
GNU Guix also includes non-software works. Thanks to the following
people who contributed the logo and general artwork and themes:
Nikita Karetnikov <nikita@karetnikov.org>
Felipe López <felipe.lopez@openmailbox.org>