From 59aba7607507193587be7c24229dc71066e3ae87 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Tue, 29 Nov 2022 16:19:19 +0100 Subject: Ability to use taskdir as flake; change nixpkgs syntax --- nix2/driver.go | 4 ++-- nix2/nix.go | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'nix2') 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) -- cgit v1.2.3