aboutsummaryrefslogtreecommitdiff
path: root/example
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-11-29 11:41:40 +0100
committerAlex Auvolat <alex@adnab.me>2022-11-29 11:41:40 +0100
commitec3eba576a1a9574c6a2be8d90d973badb34f455 (patch)
tree5e139459046f23b00abdb4501bb9cf82bdefb722 /example
parent50412d4cf0c2ae780bc8a1acce8dd7aa1d0b19b0 (diff)
downloadnomad-driver-nix2-ec3eba576a1a9574c6a2be8d90d973badb34f455.tar.gz
nomad-driver-nix2-ec3eba576a1a9574c6a2be8d90d973badb34f455.zip
Ability to run Nix jobs
Diffstat (limited to 'example')
-rw-r--r--example/agent.hcl5
-rw-r--r--example/example.hcl49
-rw-r--r--example/example2.hcl28
3 files changed, 37 insertions, 45 deletions
diff --git a/example/agent.hcl b/example/agent.hcl
index c704243..740c221 100644
--- a/example/agent.hcl
+++ b/example/agent.hcl
@@ -3,10 +3,7 @@
client {
}
-plugin "exec2-driver" {
+plugin "nix2-driver" {
config {
- bind_read_only = {
- "/etc" = "/etc",
- }
}
}
diff --git a/example/example.hcl b/example/example.hcl
index 80da070..dee0e0e 100644
--- a/example/example.hcl
+++ b/example/example.hcl
@@ -3,53 +3,20 @@ job "example" {
type = "batch"
group "example" {
- task "test-host-bin" {
- driver = "exec2"
-
- config {
- command = "/bin/sh"
- args = ["-c", "echo hello world"]
- bind_read_only = {
- "/bin" = "/bin",
- "/lib" = "/lib",
- "/lib64" = "/lib64",
- "/usr" = "/usr",
- "/nix" = "/nix",
- }
- }
- user = "lx"
- }
-
task "test-nix-hello" {
- driver = "exec2"
+ driver = "nix2"
config {
- command = "/sw/bin/nix"
+ command = "sh"
args = [
- "--extra-experimental-features", "flakes",
- "--extra-experimental-features", "nix-command",
- "run",
+ "-c",
+ "pwd; ls -l *; mount; hello"
+ ]
+ packages = [
+ "github:NixOS/nixpkgs#coreutils",
+ "github:NixOS/nixpkgs#bash",
"github:NixOS/nixpkgs#hello"
]
- bind = {
- "/nix" = "/nix",
- }
- bind_read_only = {
- "/home/lx/.nix-profile" = "/sw",
- }
- }
- user = "lx"
- }
-
- task "test-nix-store" {
- 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 = {
- "/nix" = "/nix",
- }
}
user = "lx"
}
diff --git a/example/example2.hcl b/example/example2.hcl
new file mode 100644
index 0000000..8b56f8a
--- /dev/null
+++ b/example/example2.hcl
@@ -0,0 +1,28 @@
+job "example2" {
+ datacenters = ["dc1"]
+ type = "service"
+
+ group "example" {
+ task "server" {
+ driver = "nix2"
+
+ config {
+ packages = [
+ "github:nixos/nixpkgs#python3",
+ "github:nixos/nixpkgs#bash",
+ "github:nixos/nixpkgs#coreutils",
+ "github:nixos/nixpkgs#curl",
+ "github:nixos/nixpkgs#nix",
+ "github:nixos/nixpkgs#git",
+ "github:nixos/nixpkgs#cacert",
+ "github:nixos/nixpkgs#strace",
+ "github:nixos/nixpkgs#gnugrep",
+ "github:nixos/nixpkgs#mount",
+ ]
+ command = "python3"
+ args = [ "-m", "http.server", "8080" ]
+ }
+ user = "lx"
+ }
+ }
+}