1 /* Guix --- Nix package management from Guile. -*- coding: utf-8 -*-
2 Copyright (C) 2012 Ludovic Courtès <ludo@gnu.org>
4 This file is part of Guix.
6 Guix is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or (at
9 your option) any later version.
11 Guix is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with Guix. If not, see <http://www.gnu.org/licenses/>. */
28 /* Variables used by `nix-daemon.cc'. */
29 volatile ::sig_atomic_t blockInt
;
34 /* Entry point in `nix-daemon.cc'. */
35 extern void run (Strings args
);
38 /* Command-line options. */
40 const char *argp_program_version
=
41 "guix-daemon (" PACKAGE_NAME
") " PACKAGE_VERSION
;
42 const char *argp_program_bug_address
= PACKAGE_BUGREPORT
;
45 "guix-daemon -- perform derivation builds and store accesses\
47 This program is a daemon meant to run in the background. It serves \
48 requests sent over a Unix-domain socket. It accesses the store, and \
49 builds derivations on behalf of its clients.";
51 #define GUIX_OPT_SYSTEM 1
52 #define GUIX_OPT_DISABLE_CHROOT 2
53 #define GUIX_OPT_BUILD_USERS_GROUP 3
54 #define GUIX_OPT_CACHE_FAILURES 4
55 #define GUIX_OPT_LOSE_LOGS 5
56 #define GUIX_OPT_DISABLE_LOG_COMPRESSION 6
57 #define GUIX_OPT_DISABLE_STORE_OPTIMIZATION 7
58 #define GUIX_OPT_IMPERSONATE_LINUX_26 8
60 static const struct argp_option options
[] =
62 { "system", GUIX_OPT_SYSTEM
, "SYSTEM", 0,
63 "Assume SYSTEM as the current system type" },
64 { "build-cores", 'C', "N", 0,
65 "Use N CPU cores to build each derivation; 0 means as many as available" },
66 { "max-jobs", 'M', "N", 0,
67 "Allow at most N build jobs" },
68 { "disable-chroot", GUIX_OPT_DISABLE_CHROOT
, 0, 0,
69 "Disable chroot builds"
71 " (chroots are not supported in this configuration, so "
72 "this option has no effect)"
75 { "build-users-group", GUIX_OPT_BUILD_USERS_GROUP
, "GROUP", 0,
76 "Perform builds as a user of GROUP" },
77 { "cache-failures", GUIX_OPT_CACHE_FAILURES
, 0, 0,
78 "Cache build failures" },
79 { "lose-logs", GUIX_OPT_LOSE_LOGS
, 0, 0,
80 "Do not keep build logs" },
81 { "disable-log-compression", GUIX_OPT_DISABLE_LOG_COMPRESSION
, 0, 0,
82 "Disable compression of the build logs" },
83 { "disable-store-optimization", GUIX_OPT_DISABLE_STORE_OPTIMIZATION
, 0, 0,
84 "Disable automatic file \"deduplication\" in the store" },
85 { "impersonate-linux-2.6", GUIX_OPT_IMPERSONATE_LINUX_26
, 0, 0,
86 "Impersonate Linux 2.6"
87 #ifndef HAVE_SYS_PERSONALITY_H
88 " (this option has no effect in this configuration)"
94 /* Parse a single option. */
96 parse_opt (int key
, char *arg
, struct argp_state
*state
)
100 case GUIX_OPT_DISABLE_CHROOT
:
101 settings
.useChroot
= false;
103 case GUIX_OPT_DISABLE_LOG_COMPRESSION
:
104 settings
.compressLog
= false;
106 case GUIX_OPT_BUILD_USERS_GROUP
:
107 settings
.buildUsersGroup
= arg
;
109 case GUIX_OPT_DISABLE_STORE_OPTIMIZATION
:
110 settings
.autoOptimiseStore
= false;
112 case GUIX_OPT_CACHE_FAILURES
:
113 settings
.cacheFailure
= true;
115 case GUIX_OPT_IMPERSONATE_LINUX_26
:
116 settings
.impersonateLinux26
= true;
118 case GUIX_OPT_LOSE_LOGS
:
119 settings
.keepLog
= false;
122 settings
.buildCores
= atoi (arg
);
125 settings
.maxBuildJobs
= atoi (arg
);
127 case GUIX_OPT_SYSTEM
:
128 settings
.thisSystem
= arg
;
131 return ARGP_ERR_UNKNOWN
;
137 /* Argument parsing. */
138 static struct argp argp
= { options
, parse_opt
, 0, doc
};
143 main (int argc
, char *argv
[])
148 settings
.useChroot
= true;
150 settings
.useChroot
= false;
153 settings
.processEnvironment ();
155 argp_parse (&argp
, argc
, argv
, 0, 0, 0);