aboutsummaryrefslogtreecommitdiff
path: root/nix2
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-11-29 16:19:19 +0100
committerAlex Auvolat <alex@adnab.me>2022-11-29 16:19:19 +0100
commit59aba7607507193587be7c24229dc71066e3ae87 (patch)
treebe6910b86fa2bf5eb346359c06d85b50a7162b0e /nix2
parent8b424e195058dd1825c4a03304487860a3f73502 (diff)
downloadnomad-driver-nix2-59aba7607507193587be7c24229dc71066e3ae87.tar.gz
nomad-driver-nix2-59aba7607507193587be7c24229dc71066e3ae87.zip
Ability to use taskdir as flake; change nixpkgs syntax
Diffstat (limited to 'nix2')
-rw-r--r--nix2/driver.go4
-rw-r--r--nix2/nix.go5
2 files changed, 5 insertions, 4 deletions
diff --git a/nix2/driver.go b/nix2/driver.go
index 96bbf42..cba3bee 100644
--- a/nix2/driver.go
+++ b/nix2/driver.go
@@ -510,8 +510,8 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *drive
}
// Use that repo for all packages not specified from a flake already.
for i := range driverConfig.Packages {
- if !strings.Contains(driverConfig.Packages[i], "#") && !strings.Contains(driverConfig.Packages[i], "/") {
- driverConfig.Packages[i] = nixpkgs + "#" + driverConfig.Packages[i]
+ if strings.HasPrefix(driverConfig.Packages[i], "#") {
+ driverConfig.Packages[i] = nixpkgs + driverConfig.Packages[i]
}
}
diff --git a/nix2/nix.go b/nix2/nix.go
index 5b94065..badf38c 100644
--- a/nix2/nix.go
+++ b/nix2/nix.go
@@ -25,7 +25,7 @@ func prepareNixPackages(taskDir string, packages []string, nixpkgs string) (hclu
mounts := make(hclutils.MapStrStr)
profileLink := filepath.Join(taskDir, "current-profile")
- profile, err := nixBuildProfile(packages, profileLink)
+ profile, err := nixBuildProfile(taskDir, packages, profileLink)
if err != nil {
return nil, fmt.Errorf("Build of the flakes failed: %v", err)
}
@@ -71,7 +71,7 @@ func prepareNixPackages(taskDir string, packages []string, nixpkgs string) (hclu
return mounts, nil
}
-func nixBuildProfile(flakes []string, link string) (string, error) {
+func nixBuildProfile(taskDir string, flakes []string, link string) (string, error) {
cmd := exec.Command("nix", append(
[]string{
"--extra-experimental-features", "nix-command",
@@ -84,6 +84,7 @@ func nixBuildProfile(flakes []string, link string) (string, error) {
flakes...)...)
stderr := &bytes.Buffer{}
cmd.Stderr = stderr
+ cmd.Dir = taskDir
if err := cmd.Run(); err != nil {
return "", fmt.Errorf("%v failed: %s. Err: %v", cmd.Args, stderr.String(), err)