Make symlinks work

This commit is contained in:
Alex 2022-11-28 18:08:02 +01:00
parent bf3165a706
commit cbde799457
Signed by: lx
GPG key ID: 0E496D15096376BE
3 changed files with 30 additions and 6 deletions

View file

@ -7,13 +7,36 @@ job "example" {
driver = "exec2" driver = "exec2"
config { config {
command = "/nix/store/y41s1vcn0irn9ahn9wh62yx2cygs7qjj-coreutils-8.32/bin/cat" command = "/sw/bin/nix"
args = ["/host-etc/nscd.conf"] args = [
bind_read_only = { "--extra-experimental-features", "flakes",
"--extra-experimental-features", "nix-command",
"run",
"github:NixOS/nixpkgs#hello"
]
bind = {
"/nix" = "/nix", "/nix" = "/nix",
"/etc" = "/host-etc", }
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",
}
}
user = "lx"
} }
} }
} }

View file

@ -434,7 +434,7 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *drive
user := cfg.User user := cfg.User
if user == "" { if user == "" {
user = "nobody" user = "0"
} }
if cfg.DNS != nil { if cfg.DNS != nil {

View file

@ -7,6 +7,7 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"io/fs"
"os" "os"
"os/exec" "os/exec"
"path" "path"
@ -913,7 +914,7 @@ func filepathIsRegular(path string) error {
if err != nil { if err != nil {
return err 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 fmt.Errorf("path was not a regular file")
} }
return nil return nil