forked from lix-project/lix
Merge all nix-* binaries into nix
These are all symlinks to 'nix' now, reducing the installed size by about ~1.7 MiB.
This commit is contained in:
parent
c47e14ee45
commit
f6a3dfe4e0
24 changed files with 105 additions and 165 deletions
10
Makefile
10
Makefile
|
@ -5,17 +5,7 @@ makefiles = \
|
|||
src/libmain/local.mk \
|
||||
src/libexpr/local.mk \
|
||||
src/nix/local.mk \
|
||||
src/nix-store/local.mk \
|
||||
src/nix-instantiate/local.mk \
|
||||
src/nix-env/local.mk \
|
||||
src/nix-daemon/local.mk \
|
||||
src/nix-collect-garbage/local.mk \
|
||||
src/nix-copy-closure/local.mk \
|
||||
src/nix-prefetch-url/local.mk \
|
||||
src/resolve-system-dependencies/local.mk \
|
||||
src/nix-channel/local.mk \
|
||||
src/nix-build/local.mk \
|
||||
src/build-remote/local.mk \
|
||||
scripts/local.mk \
|
||||
corepkgs/local.mk \
|
||||
misc/systemd/local.mk \
|
||||
|
|
2
local.mk
2
local.mk
|
@ -6,7 +6,7 @@ dist-files += configure config.h.in nix.spec perl/configure
|
|||
|
||||
clean-files += Makefile.config
|
||||
|
||||
GLOBAL_CXXFLAGS += -I . -I src -I src/libutil -I src/libstore -I src/libmain -I src/libexpr
|
||||
GLOBAL_CXXFLAGS += -I . -I src -I src/libutil -I src/libstore -I src/libmain -I src/libexpr -I src/nix
|
||||
|
||||
$(foreach i, config.h $(call rwildcard, src/lib*, *.hh), \
|
||||
$(eval $(call install-file-in, $(i), $(includedir)/nix, 0644)))
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "store-api.hh"
|
||||
#include "derivations.hh"
|
||||
#include "local-store.hh"
|
||||
#include "legacy.hh"
|
||||
|
||||
using namespace nix;
|
||||
using std::cin;
|
||||
|
@ -37,11 +38,9 @@ static AutoCloseFD openSlotLock(const Machine & m, unsigned long long slot)
|
|||
return openLockFile(fmt("%s/%s-%d", currentLoad, escapeUri(m.storeUri), slot), true);
|
||||
}
|
||||
|
||||
int main (int argc, char * * argv)
|
||||
static int _main(int argc, char * * argv)
|
||||
{
|
||||
return handleExceptions(argv[0], [&]() {
|
||||
initNix();
|
||||
|
||||
{
|
||||
logger = makeJSONLogger(*logger);
|
||||
|
||||
/* Ensure we don't get any SSH passphrase or host key popups. */
|
||||
|
@ -80,7 +79,7 @@ int main (int argc, char * * argv)
|
|||
|
||||
if (machines.empty()) {
|
||||
std::cerr << "# decline-permanently\n";
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
string drvPath;
|
||||
|
@ -90,8 +89,8 @@ int main (int argc, char * * argv)
|
|||
|
||||
try {
|
||||
auto s = readString(source);
|
||||
if (s != "try") return;
|
||||
} catch (EndOfFile &) { return; }
|
||||
if (s != "try") return 0;
|
||||
} catch (EndOfFile &) { return 0; }
|
||||
|
||||
auto amWilling = readInt(source);
|
||||
auto neededSystem = readString(source);
|
||||
|
@ -253,6 +252,8 @@ connected:
|
|||
copyPaths(ref<Store>(sshStore), store, missing, NoRepair, NoCheckSigs, NoSubstitute);
|
||||
}
|
||||
|
||||
return;
|
||||
});
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static RegisterLegacyCommand s1("build-remote", _main);
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
programs += build-remote
|
||||
|
||||
build-remote_DIR := $(d)
|
||||
|
||||
build-remote_INSTALL_DIR := $(libexecdir)/nix
|
||||
|
||||
build-remote_LIBS = libmain libformat libstore libutil
|
||||
|
||||
build-remote_SOURCES := $(d)/build-remote.cc
|
|
@ -1,9 +0,0 @@
|
|||
programs += nix-build
|
||||
|
||||
nix-build_DIR := $(d)
|
||||
|
||||
nix-build_SOURCES := $(d)/nix-build.cc
|
||||
|
||||
nix-build_LIBS = libmain libexpr libstore libutil libformat
|
||||
|
||||
$(eval $(call install-symlink, nix-build, $(bindir)/nix-shell))
|
|
@ -16,6 +16,7 @@
|
|||
#include "get-drvs.hh"
|
||||
#include "common-eval-args.hh"
|
||||
#include "attr-path.hh"
|
||||
#include "legacy.hh"
|
||||
|
||||
using namespace nix;
|
||||
using namespace std::string_literals;
|
||||
|
@ -66,11 +67,8 @@ std::vector<string> shellwords(const string & s)
|
|||
return res;
|
||||
}
|
||||
|
||||
void mainWrapped(int argc, char * * argv)
|
||||
static void _main(int argc, char * * argv)
|
||||
{
|
||||
initNix();
|
||||
initGC();
|
||||
|
||||
auto dryRun = false;
|
||||
auto runEnv = std::regex_search(argv[0], std::regex("nix-shell$"));
|
||||
auto pure = false;
|
||||
|
@ -504,9 +502,5 @@ void mainWrapped(int argc, char * * argv)
|
|||
}
|
||||
}
|
||||
|
||||
int main(int argc, char * * argv)
|
||||
{
|
||||
return handleExceptions(argv[0], [&]() {
|
||||
return mainWrapped(argc, argv);
|
||||
});
|
||||
}
|
||||
static RegisterLegacyCommand s1("nix-build", _main);
|
||||
static RegisterLegacyCommand s2("nix-shell", _main);
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
programs += nix-channel
|
||||
|
||||
nix-channel_DIR := $(d)
|
||||
|
||||
nix-channel_LIBS = libmain libformat libstore libutil
|
||||
|
||||
nix-channel_SOURCES := $(d)/nix-channel.cc
|
|
@ -1,9 +1,11 @@
|
|||
#include "shared.hh"
|
||||
#include "globals.hh"
|
||||
#include "download.hh"
|
||||
#include "store-api.hh"
|
||||
#include "legacy.hh"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <regex>
|
||||
#include "store-api.hh"
|
||||
#include <pwd.h>
|
||||
|
||||
using namespace nix;
|
||||
|
@ -157,11 +159,9 @@ static void update(const StringSet & channelNames)
|
|||
replaceSymlink(profile, channelLink);
|
||||
}
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
static int _main(int argc, char ** argv)
|
||||
{
|
||||
return handleExceptions(argv[0], [&]() {
|
||||
initNix();
|
||||
|
||||
{
|
||||
// Figure out the name of the `.nix-channels' file to use
|
||||
auto home = getHome();
|
||||
channelsList = home + "/.nix-channels";
|
||||
|
@ -255,5 +255,9 @@ int main(int argc, char ** argv)
|
|||
runProgram(settings.nixBinDir + "/nix-env", false, envArgs);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static RegisterLegacyCommand s1("nix-channel", _main);
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
programs += nix-collect-garbage
|
||||
|
||||
nix-collect-garbage_DIR := $(d)
|
||||
|
||||
nix-collect-garbage_SOURCES := $(d)/nix-collect-garbage.cc
|
||||
|
||||
nix-collect-garbage_LIBS = libmain libstore libutil libformat
|
|
@ -2,6 +2,7 @@
|
|||
#include "profiles.hh"
|
||||
#include "shared.hh"
|
||||
#include "globals.hh"
|
||||
#include "legacy.hh"
|
||||
|
||||
#include <iostream>
|
||||
#include <cerrno>
|
||||
|
@ -48,12 +49,10 @@ void removeOldGenerations(std::string dir)
|
|||
}
|
||||
}
|
||||
|
||||
int main(int argc, char * * argv)
|
||||
static int _main(int argc, char * * argv)
|
||||
{
|
||||
bool removeOld = false;
|
||||
|
||||
return handleExceptions(argv[0], [&]() {
|
||||
initNix();
|
||||
{
|
||||
bool removeOld = false;
|
||||
|
||||
GCOptions options;
|
||||
|
||||
|
@ -90,5 +89,9 @@ int main(int argc, char * * argv)
|
|||
PrintFreed freed(true, results);
|
||||
store->collectGarbage(options, results);
|
||||
}
|
||||
});
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static RegisterLegacyCommand s1("nix-collect-garbage", _main);
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
programs += nix-copy-closure
|
||||
|
||||
nix-copy-closure_DIR := $(d)
|
||||
|
||||
nix-copy-closure_LIBS = libmain libformat libstore libutil
|
||||
|
||||
nix-copy-closure_SOURCES := $(d)/nix-copy-closure.cc
|
|
@ -1,13 +1,12 @@
|
|||
#include "shared.hh"
|
||||
#include "store-api.hh"
|
||||
#include "legacy.hh"
|
||||
|
||||
using namespace nix;
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
static int _main(int argc, char ** argv)
|
||||
{
|
||||
return handleExceptions(argv[0], [&]() {
|
||||
initNix();
|
||||
|
||||
{
|
||||
auto gzip = false;
|
||||
auto toMode = true;
|
||||
auto includeOutputs = false;
|
||||
|
@ -61,5 +60,9 @@ int main(int argc, char ** argv)
|
|||
from->computeFSClosure(storePaths2, closure, false, includeOutputs);
|
||||
|
||||
copyPaths(from, to, closure, NoRepair, NoCheckSigs, useSubstitutes);
|
||||
});
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static RegisterLegacyCommand s1("nix-copy-closure", _main);
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
programs += nix-daemon
|
||||
|
||||
nix-daemon_DIR := $(d)
|
||||
|
||||
nix-daemon_SOURCES := $(d)/nix-daemon.cc
|
||||
|
||||
nix-daemon_LIBS = libmain libstore libutil libformat
|
||||
|
||||
nix-daemon_LDFLAGS = -pthread
|
||||
|
||||
ifeq ($(OS), SunOS)
|
||||
nix-daemon_LDFLAGS += -lsocket
|
||||
endif
|
|
@ -9,6 +9,7 @@
|
|||
#include "monitor-fd.hh"
|
||||
#include "derivations.hh"
|
||||
#include "finally.hh"
|
||||
#include "legacy.hh"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
|
@ -1058,11 +1059,9 @@ static void daemonLoop(char * * argv)
|
|||
}
|
||||
|
||||
|
||||
int main(int argc, char * * argv)
|
||||
static int _main(int argc, char * * argv)
|
||||
{
|
||||
return handleExceptions(argv[0], [&]() {
|
||||
initNix();
|
||||
|
||||
{
|
||||
auto stdio = false;
|
||||
|
||||
parseCmdLine(argc, argv, [&](Strings::iterator & arg, const Strings::iterator & end) {
|
||||
|
@ -1122,7 +1121,7 @@ int main(int argc, char * * argv)
|
|||
if (res == -1)
|
||||
throw SysError("splicing data from stdin to daemon socket");
|
||||
else if (res == 0)
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -1131,5 +1130,9 @@ int main(int argc, char * * argv)
|
|||
} else {
|
||||
daemonLoop(argv);
|
||||
}
|
||||
});
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static RegisterLegacyCommand s1("nix-daemon", _main);
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
programs += nix-env
|
||||
|
||||
nix-env_DIR := $(d)
|
||||
|
||||
nix-env_SOURCES := $(wildcard $(d)/*.cc)
|
||||
|
||||
nix-env_LIBS = libexpr libmain libstore libutil libformat
|
|
@ -13,6 +13,7 @@
|
|||
#include "json.hh"
|
||||
#include "value-to-json.hh"
|
||||
#include "xml-writer.hh"
|
||||
#include "legacy.hh"
|
||||
|
||||
#include <cerrno>
|
||||
#include <ctime>
|
||||
|
@ -1311,12 +1312,9 @@ static void opVersion(Globals & globals, Strings opFlags, Strings opArgs)
|
|||
}
|
||||
|
||||
|
||||
int main(int argc, char * * argv)
|
||||
static int _main(int argc, char * * argv)
|
||||
{
|
||||
return handleExceptions(argv[0], [&]() {
|
||||
initNix();
|
||||
initGC();
|
||||
|
||||
{
|
||||
Strings opFlags, opArgs;
|
||||
Operation op = 0;
|
||||
RepairFlag repair = NoRepair;
|
||||
|
@ -1428,5 +1426,9 @@ int main(int argc, char * * argv)
|
|||
op(globals, opFlags, opArgs);
|
||||
|
||||
globals.state->printStats();
|
||||
});
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static RegisterLegacyCommand s1("nix-env", _main);
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
programs += nix-instantiate
|
||||
|
||||
nix-instantiate_DIR := $(d)
|
||||
|
||||
nix-instantiate_SOURCES := $(d)/nix-instantiate.cc
|
||||
|
||||
nix-instantiate_LIBS = libexpr libmain libstore libutil libformat
|
|
@ -9,6 +9,7 @@
|
|||
#include "util.hh"
|
||||
#include "store-api.hh"
|
||||
#include "common-eval-args.hh"
|
||||
#include "legacy.hh"
|
||||
|
||||
#include <map>
|
||||
#include <iostream>
|
||||
|
@ -83,12 +84,9 @@ void processExpr(EvalState & state, const Strings & attrPaths,
|
|||
}
|
||||
|
||||
|
||||
int main(int argc, char * * argv)
|
||||
static int _main(int argc, char * * argv)
|
||||
{
|
||||
return handleExceptions(argv[0], [&]() {
|
||||
initNix();
|
||||
initGC();
|
||||
|
||||
{
|
||||
Strings files;
|
||||
bool readStdin = false;
|
||||
bool fromArgs = false;
|
||||
|
@ -171,7 +169,7 @@ int main(int argc, char * * argv)
|
|||
if (p == "") throw Error(format("unable to find '%1%'") % i);
|
||||
std::cout << p << std::endl;
|
||||
}
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (readStdin) {
|
||||
|
@ -190,5 +188,9 @@ int main(int argc, char * * argv)
|
|||
}
|
||||
|
||||
state->printStats();
|
||||
});
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static RegisterLegacyCommand s1("nix-instantiate", _main);
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
programs += nix-prefetch-url
|
||||
|
||||
nix-prefetch-url_DIR := $(d)
|
||||
|
||||
nix-prefetch-url_SOURCES := $(d)/nix-prefetch-url.cc
|
||||
|
||||
nix-prefetch-url_LIBS = libmain libexpr libstore libutil libformat
|
|
@ -6,6 +6,7 @@
|
|||
#include "eval-inline.hh"
|
||||
#include "common-eval-args.hh"
|
||||
#include "attr-path.hh"
|
||||
#include "legacy.hh"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
|
@ -44,12 +45,9 @@ string resolveMirrorUri(EvalState & state, string uri)
|
|||
}
|
||||
|
||||
|
||||
int main(int argc, char * * argv)
|
||||
static int _main(int argc, char * * argv)
|
||||
{
|
||||
return handleExceptions(argv[0], [&]() {
|
||||
initNix();
|
||||
initGC();
|
||||
|
||||
{
|
||||
HashType ht = htSHA256;
|
||||
std::vector<string> args;
|
||||
bool printPath = getEnv("PRINT_PATH") != "";
|
||||
|
@ -221,5 +219,9 @@ int main(int argc, char * * argv)
|
|||
std::cout << printHash16or32(hash) << std::endl;
|
||||
if (printPath)
|
||||
std::cout << storePath << std::endl;
|
||||
});
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static RegisterLegacyCommand s1("nix-prefetch-url", _main);
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
programs += nix-store
|
||||
|
||||
nix-store_DIR := $(d)
|
||||
|
||||
nix-store_SOURCES := $(wildcard $(d)/*.cc)
|
||||
|
||||
nix-store_LIBS = libmain libstore libutil libformat
|
||||
|
||||
nix-store_LDFLAGS = -lbz2 -pthread $(SODIUM_LIBS)
|
|
@ -9,6 +9,7 @@
|
|||
#include "util.hh"
|
||||
#include "worker-protocol.hh"
|
||||
#include "graphml.hh"
|
||||
#include "legacy.hh"
|
||||
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
|
@ -993,11 +994,9 @@ static void opVersion(Strings opFlags, Strings opArgs)
|
|||
/* Scan the arguments; find the operation, set global flags, put all
|
||||
other flags in a list, and put all other arguments in another
|
||||
list. */
|
||||
int main(int argc, char * * argv)
|
||||
static int _main(int argc, char * * argv)
|
||||
{
|
||||
return handleExceptions(argv[0], [&]() {
|
||||
initNix();
|
||||
|
||||
{
|
||||
Strings opFlags, opArgs;
|
||||
Operation op = 0;
|
||||
|
||||
|
@ -1084,5 +1083,9 @@ int main(int argc, char * * argv)
|
|||
store = openStore();
|
||||
|
||||
op(opFlags, opArgs);
|
||||
});
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static RegisterLegacyCommand s1("nix-store", _main);
|
||||
|
|
|
@ -2,10 +2,25 @@ programs += nix
|
|||
|
||||
nix_DIR := $(d)
|
||||
|
||||
nix_SOURCES := $(wildcard $(d)/*.cc) $(wildcard src/linenoise/*.cpp)
|
||||
nix_SOURCES := \
|
||||
$(wildcard $(d)/*.cc) \
|
||||
$(wildcard src/linenoise/*.cpp) \
|
||||
$(wildcard src/build-remote/*.cc) \
|
||||
$(wildcard src/nix-build/*.cc) \
|
||||
$(wildcard src/nix-channel/*.cc) \
|
||||
$(wildcard src/nix-collect-garbage/*.cc) \
|
||||
$(wildcard src/nix-copy-closure/*.cc) \
|
||||
$(wildcard src/nix-daemon/*.cc) \
|
||||
$(wildcard src/nix-env/*.cc) \
|
||||
$(wildcard src/nix-instantiate/*.cc) \
|
||||
$(wildcard src/nix-prefetch-url/*.cc) \
|
||||
$(wildcard src/nix-store/*.cc) \
|
||||
|
||||
nix_LIBS = libexpr libmain libstore libutil libformat
|
||||
|
||||
nix_LDFLAGS = -pthread
|
||||
nix_LDFLAGS = -pthread $(SODIUM_LIBS)
|
||||
|
||||
$(eval $(call install-symlink, nix, $(bindir)/nix-hash))
|
||||
$(foreach name, \
|
||||
nix-build nix-channel nix-collect-garbage nix-copy-closure nix-daemon nix-env nix-hash nix-instantiate nix-prefetch-rul nix-shell nix-shore, \
|
||||
$(eval $(call install-symlink, nix, $(bindir)/$(name))))
|
||||
$(eval $(call install-symlink, $(bindir)/nix, $(libexecdir)/nix/build-remote))
|
||||
|
|
|
@ -67,9 +67,6 @@ struct NixArgs : virtual MultiCommand, virtual MixCommonArgs
|
|||
|
||||
void mainWrapped(int argc, char * * argv)
|
||||
{
|
||||
verbosity = lvlError;
|
||||
settings.verboseBuild = false;
|
||||
|
||||
/* The chroot helper needs to be run before any threads have been
|
||||
started. */
|
||||
if (argc > 0 && argv[0] == chrootHelperName) {
|
||||
|
@ -88,6 +85,9 @@ void mainWrapped(int argc, char * * argv)
|
|||
if (legacy) return legacy(argc, argv);
|
||||
}
|
||||
|
||||
verbosity = lvlError;
|
||||
settings.verboseBuild = false;
|
||||
|
||||
NixArgs args;
|
||||
|
||||
args.parseCmdline(argvToStrings(argc, argv));
|
||||
|
|
Loading…
Reference in a new issue