summaryrefslogtreecommitdiff
path: root/nix/nix-daemon/guix-daemon.cc
diff options
context:
space:
mode:
Diffstat (limited to 'nix/nix-daemon/guix-daemon.cc')
-rw-r--r--nix/nix-daemon/guix-daemon.cc33
1 files changed, 33 insertions, 0 deletions
diff --git a/nix/nix-daemon/guix-daemon.cc b/nix/nix-daemon/guix-daemon.cc
index d35b1cd076..79cd080363 100644
--- a/nix/nix-daemon/guix-daemon.cc
+++ b/nix/nix-daemon/guix-daemon.cc
@@ -30,6 +30,7 @@
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include <strings.h>
#include <exception>
/* Variables used by `nix-daemon.cc'. */
@@ -68,6 +69,8 @@ builds derivations on behalf of its clients.";
#define GUIX_OPT_LISTEN 11
#define GUIX_OPT_NO_SUBSTITUTES 12
#define GUIX_OPT_NO_BUILD_HOOK 13
+#define GUIX_OPT_GC_KEEP_OUTPUTS 14
+#define GUIX_OPT_GC_KEEP_DERIVATIONS 15
static const struct argp_option options[] =
{
@@ -111,6 +114,14 @@ static const struct argp_option options[] =
" (this option has no effect in this configuration)"
#endif
},
+ { "gc-keep-outputs", GUIX_OPT_GC_KEEP_OUTPUTS,
+ "yes/no", OPTION_ARG_OPTIONAL,
+ "Tell whether the GC must keep outputs of live derivations" },
+ { "gc-keep-derivations", GUIX_OPT_GC_KEEP_DERIVATIONS,
+ "yes/no", OPTION_ARG_OPTIONAL,
+ "Tell whether the GC must keep derivations corresponding \
+to live outputs" },
+
{ "listen", GUIX_OPT_LISTEN, "SOCKET", 0,
"Listen for connections on SOCKET" },
{ "debug", GUIX_OPT_DEBUG, 0, 0,
@@ -118,6 +129,22 @@ static const struct argp_option options[] =
{ 0, 0, 0, 0, 0 }
};
+
+/* Convert ARG to a Boolean value, or throw an error if it does not denote a
+ Boolean. */
+static bool
+string_to_bool (const char *arg, bool dflt = true)
+{
+ if (arg == NULL)
+ return dflt;
+ else if (strcasecmp (arg, "yes") == 0)
+ return true;
+ else if (strcasecmp (arg, "no") == 0)
+ return false;
+ else
+ throw nix::Error (format ("'%1%': invalid Boolean value") % arg);
+}
+
/* Parse a single option. */
static error_t
parse_opt (int key, char *arg, struct argp_state *state)
@@ -168,6 +195,12 @@ parse_opt (int key, char *arg, struct argp_state *state)
case GUIX_OPT_DEBUG:
verbosity = lvlDebug;
break;
+ case GUIX_OPT_GC_KEEP_OUTPUTS:
+ settings.gcKeepOutputs = string_to_bool (arg);
+ break;
+ case GUIX_OPT_GC_KEEP_DERIVATIONS:
+ settings.gcKeepDerivations = string_to_bool (arg);
+ break;
case 'c':
settings.buildCores = atoi (arg);
break;