nix-super/src/libexpr/primops/flake.hh
Eelco Dolstra 154244adc6 nix: New installables syntax
The general syntax for an installable is now
<flakeref>:<attrpath>. The attrpath is relative to the flake's
'provides.packages' or 'provides' if the former doesn't yield a
result. E.g.

  $ nix build nixpkgs:hello

is equivalent to

  $ nix build nixpkgs:packages.hello

Also, '<flakeref>:' can be omitted, in which case it defaults to
'nixpkgs', e.g.

  $ nix build hello
2019-04-08 14:21:13 +02:00

53 lines
1.1 KiB
C++

#include "types.hh"
#include "flakeref.hh"
#include <variant>
namespace nix {
struct Value;
class EvalState;
struct FlakeRegistry
{
struct Entry
{
FlakeRef ref;
Entry(const FlakeRef & flakeRef) : ref(flakeRef) {};
Entry operator=(const Entry & entry) { return Entry(entry.ref); }
};
std::map<FlakeId, Entry> entries;
};
Path getUserRegistryPath();
Value * makeFlakeRegistryValue(EvalState & state);
Value * makeFlakeValue(EvalState & state, const FlakeRef & flakeRef, bool impureTopRef, Value & v);
std::shared_ptr<FlakeRegistry> readRegistry(const Path &);
void writeRegistry(FlakeRegistry, Path);
struct Flake
{
FlakeId id;
FlakeRef ref;
std::string description;
Path path;
std::vector<FlakeRef> requires;
std::shared_ptr<FlakeRegistry> lockFile;
Value * vProvides; // FIXME: gc
// commit hash
// date
// content hash
Flake(FlakeRef & flakeRef) : ref(flakeRef) {};
};
Flake getFlake(EvalState &, const FlakeRef &);
FlakeRegistry updateLockFile(EvalState &, Flake &);
void updateLockFile(EvalState &, std::string);
}