aboutsummaryrefslogtreecommitdiff
path: root/example
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 /example
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 'example')
-rw-r--r--example/example-batch.hcl27
-rw-r--r--example/example-service.hcl22
-rw-r--r--example/flake.nix18
3 files changed, 54 insertions, 13 deletions
diff --git a/example/example-batch.hcl b/example/example-batch.hcl
index a4dc946..15635f9 100644
--- a/example/example-batch.hcl
+++ b/example/example-batch.hcl
@@ -12,8 +12,11 @@ job "nix2-example-batch" {
driver = "nix2"
config {
+ # Packages contains a list of Nix flakes to include in the environement.
+ # Entries that start with # will be relative to nixpkgs.
+ # Otherwise, they are flake names that are passed directly to Nix build
packages = [
- "hello" # equivalent to "github:nixos/nixpkgs/nixos-22.05#hello"
+ "#hello" # equivalent to "github:nixos/nixpkgs/nixos-22.05#hello"
]
command = "hello"
}
@@ -31,7 +34,7 @@ job "nix2-example-batch" {
config {
packages = [
- "curl", "cacert"
+ "#curl", "#cacert"
]
command = "curl"
args = [
@@ -42,5 +45,25 @@ job "nix2-example-batch" {
SSL_CERT_FILE = "/etc/ssl/certs/ca-bundle.crt"
}
}
+
+ # This example show how to use a flake defined from a file
+ task "nix-hello-flake" {
+ driver = "nix2"
+
+ config {
+ # Packages contains a list of Nix flakes to include in the environement.
+ # Entries that start with # will be relative to nixpkgs.
+ # Otherwise, they are flake names that are passed directly to Nix build
+ packages = [
+ ".#hello"
+ ]
+ command = "hello"
+ }
+
+ template {
+ data = file("flake.nix")
+ destination = "flake.nix"
+ }
+ }
}
}
diff --git a/example/example-service.hcl b/example/example-service.hcl
index 03ba0d3..2f65435 100644
--- a/example/example-service.hcl
+++ b/example/example-service.hcl
@@ -13,17 +13,17 @@ job "nix2-example-service" {
config {
packages = [
- "python3",
- "bash",
- "coreutils",
- "curl",
- "nix",
- "git",
- "cacert",
- "strace",
- "gnugrep",
- "findutils",
- "mount",
+ "#python3",
+ "#bash",
+ "#coreutils",
+ "#curl",
+ "#nix",
+ "#git",
+ "#cacert",
+ "#strace",
+ "#gnugrep",
+ "#findutils",
+ "#mount",
]
command = "python3"
args = [ "-m", "http.server", "8080" ]
diff --git a/example/flake.nix b/example/flake.nix
new file mode 100644
index 0000000..3e48ddb
--- /dev/null
+++ b/example/flake.nix
@@ -0,0 +1,18 @@
+{
+ description = "A very basic flake";
+
+ outputs = { self, nixpkgs }:
+ let
+ pkgs = import nixpkgs { system = "x86_64-linux"; };
+ hello = pkgs.writeScriptBin "hello" ''
+ #!${pkgs.bash}/bin/bash
+ echo "Hello from bash script!"
+ '';
+ in {
+
+ packages.x86_64-linux.hello = hello;
+
+ packages.x86_64-linux.default = self.packages.x86_64-linux.hello;
+
+ };
+}