query
On this page

parseDrvName

lib.strings.parseDrvName

Primop
Docs pulled from | This Revision | about 23 hours ago


Nix manual

Takes 1 arguments

s

Split the string s into a package name and version. The package name is everything up to but not including the first dash not followed by a letter, and the version is everything following that dash. The result is returned in a set { name, version }. Thus, builtins.parseDrvName "nix-0.12pre12876" returns { name = "nix"; version = "0.12pre12876"; }.

Noogle detected

Aliases

Detected Type
parseDrvName :: String -> { name :: String; version :: String }

Implementation

This function is implemented in c++ and is part of the native nix runtime.

src/libexpr/primops.cc:5259

static void prim_parseDrvName(EvalState & state, const PosIdx pos, Value ** args, Value & v)
{
    auto name =
        state.forceStringNoCtx(*args[0], pos, "while evaluating the first argument passed to builtins.parseDrvName");
    DrvName parsed(name);
    auto attrs = state.buildBindings(2);
    attrs.alloc(state.s.name).mkString(parsed.name, state.mem);
    attrs.alloc("version").mkString(parsed.version, state.mem);
    v.mkAttrs(attrs);
}