diff options
author | Alex Auvolat <alex@adnab.me> | 2022-11-28 18:08:02 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2022-11-28 18:08:02 +0100 |
commit | cbde799457a8470cd64a09d10827577d005ca6f8 (patch) | |
tree | 04a6b7c445b6eb97c422a0ee1800fdfb8b73b8bc | |
parent | bf3165a7069fc6dcf9ae3a28be3af07fe8b4e1c2 (diff) | |
download | nomad-driver-nix2-cbde799457a8470cd64a09d10827577d005ca6f8.tar.gz nomad-driver-nix2-cbde799457a8470cd64a09d10827577d005ca6f8.zip |
Make symlinks work
-rw-r--r-- | example/example.hcl | 29 | ||||
-rw-r--r-- | exec2/driver.go | 2 | ||||
-rw-r--r-- | executor/executor_linux.go | 3 |
3 files changed, 29 insertions, 5 deletions
diff --git a/example/example.hcl b/example/example.hcl index fbbe4ad..52b02f6 100644 --- a/example/example.hcl +++ b/example/example.hcl @@ -7,13 +7,36 @@ job "example" { driver = "exec2" config { - command = "/nix/store/y41s1vcn0irn9ahn9wh62yx2cygs7qjj-coreutils-8.32/bin/cat" - args = ["/host-etc/nscd.conf"] + command = "/sw/bin/nix" + args = [ + "--extra-experimental-features", "flakes", + "--extra-experimental-features", "nix-command", + "run", + "github:NixOS/nixpkgs#hello" + ] + bind = { + "/nix" = "/nix", + } + bind_read_only = { + "/etc" = "/etc", + "/home/lx/.nix-profile" = "/sw", + } + } + user = "lx" + } + + task "test" { + driver = "exec2" + + config { + command = "/nix/store/30j23057fqnnc1p4jqmq73p0gxgn0frq-bash-5.1-p16/bin/sh" + args = ["-c", "/nix/store/y41s1vcn0irn9ahn9wh62yx2cygs7qjj-coreutils-8.32/bin/ls /*; /nix/store/y41s1vcn0irn9ahn9wh62yx2cygs7qjj-coreutils-8.32/bin/id"] bind_read_only = { + "/etc" = "/etc", "/nix" = "/nix", - "/etc" = "/host-etc", } } + user = "lx" } } } diff --git a/exec2/driver.go b/exec2/driver.go index 3624c7c..b223faa 100644 --- a/exec2/driver.go +++ b/exec2/driver.go @@ -434,7 +434,7 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *drive user := cfg.User if user == "" { - user = "nobody" + user = "0" } if cfg.DNS != nil { diff --git a/executor/executor_linux.go b/executor/executor_linux.go index 4ab8367..8665fd0 100644 --- a/executor/executor_linux.go +++ b/executor/executor_linux.go @@ -7,6 +7,7 @@ import ( "errors" "fmt" "io" + "io/fs" "os" "os/exec" "path" @@ -913,7 +914,7 @@ func filepathIsRegular(path string) error { if err != nil { return err } - if !f.Mode().Type().IsRegular() { + if !(f.Mode().Type().IsRegular() || f.Mode().Type() & fs.ModeType == fs.ModeSymlink) { return fmt.Errorf("path was not a regular file") } return nil |