BinaryCacheStore: Implement addToStore()
So now you can do $ NIX_REMOTE=file:///tmp/binary-cache nix-instantiate '<nixpkgs>' -A hello and lots of other operations.
This commit is contained in:
		
							parent
							
								
									30e9d01516
								
							
						
					
					
						commit
						9ccbd55c5b
					
				
					 4 changed files with 74 additions and 12 deletions
				
			
		| 
						 | 
				
			
			@ -29,7 +29,7 @@ bool useCaseHack =
 | 
			
		|||
    false;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
static string archiveVersion1 = "nix-archive-1";
 | 
			
		||||
const std::string narVersionMagic1 = "nix-archive-1";
 | 
			
		||||
 | 
			
		||||
static string caseHackSuffix = "~nix~case~hack~";
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -113,11 +113,17 @@ static void dump(const Path & path, Sink & sink, PathFilter & filter)
 | 
			
		|||
 | 
			
		||||
void dumpPath(const Path & path, Sink & sink, PathFilter & filter)
 | 
			
		||||
{
 | 
			
		||||
    sink << archiveVersion1;
 | 
			
		||||
    sink << narVersionMagic1;
 | 
			
		||||
    dump(path, sink, filter);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void dumpString(const std::string & s, Sink & sink)
 | 
			
		||||
{
 | 
			
		||||
    sink << narVersionMagic1 << "(" << "type" << "regular" << "contents" << s << ")";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static SerialisationError badArchive(string s)
 | 
			
		||||
{
 | 
			
		||||
    return SerialisationError("bad archive: " + s);
 | 
			
		||||
| 
						 | 
				
			
			@ -214,7 +220,8 @@ static void parse(ParseSink & sink, Source & source, const Path & path)
 | 
			
		|||
        }
 | 
			
		||||
 | 
			
		||||
        else if (s == "executable" && type == tpRegular) {
 | 
			
		||||
            readString(source);
 | 
			
		||||
            auto s = readString(source);
 | 
			
		||||
            if (s != "") throw badArchive("executable marker has non-empty value");
 | 
			
		||||
            sink.isExecutable();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -275,7 +282,7 @@ void parseDump(ParseSink & sink, Source & source)
 | 
			
		|||
        /* This generally means the integer at the start couldn't be
 | 
			
		||||
           decoded.  Ignore and throw the exception below. */
 | 
			
		||||
    }
 | 
			
		||||
    if (version != archiveVersion1)
 | 
			
		||||
    if (version != narVersionMagic1)
 | 
			
		||||
        throw badArchive("input doesn't look like a Nix archive");
 | 
			
		||||
    parse(sink, source, "");
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue