aboutsummaryrefslogtreecommitdiff
path: root/src/build.c
diff options
context:
space:
mode:
authorsinanmohd <sinan@sinanmohd.com>2024-06-28 16:29:56 +0530
committersinanmohd <sinan@sinanmohd.com>2024-06-28 16:29:56 +0530
commit52c3389547e821c481213f755f912f4021d01536 (patch)
treef3cfe413d2105a1ece880c07f6a1c4574681f4ad /src/build.c
parent63c4f3d603650b90b182e6d6b1b92a272538ce5d (diff)
build: set out link based on attr name
Diffstat (limited to 'src/build.c')
-rw-r--r--src/build.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/build.c b/src/build.c
index 39750b5..87238e9 100644
--- a/src/build.c
+++ b/src/build.c
@@ -2,6 +2,7 @@
#include <pthread.h>
#include <stdbool.h>
#include <stdlib.h>
+#include <limits.h>
#include <string.h>
#include "build.h"
@@ -43,16 +44,29 @@ out:
static int build(struct queue *queue)
{
struct job *job;
- char *args[3];
+ char *args[5];
size_t argindex;
int ret;
+ char out_link[NAME_MAX] = "result";
+
ret = queue_pop(queue, &job, queue->htab);
if (ret < 0)
return ret;
+ if (job->attr) {
+ ret = snprintf(out_link, sizeof(out_link), "result-%s", job->attr);
+ if (ret < 0 || (size_t)ret > sizeof(out_link)) {
+ ret = -ENAMETOOLONG;
+ print_err("%s", strerror(-ret));
+ goto out_free_job;
+ }
+ }
+
argindex = 0;
args[argindex++] = "nix-build";
+ args[argindex++] = "--out-link";
+ args[argindex++] = out_link;
args[argindex++] = job->drv_path;
args[argindex++] = NULL;
@@ -64,9 +78,10 @@ static int build(struct queue *queue)
run("nix-build", args);
}
+out_free_job:
job_free(job);
- return 0;
+ return ret;
}
int build_thread_new(struct build_thread **build_thread, struct queue *q)