diff options
author | Alex Auvolat <alex@adnab.me> | 2022-11-29 13:01:46 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2022-11-29 13:01:46 +0100 |
commit | fa49c13513ae5ab66157c634de244fdcf0a6cc1d (patch) | |
tree | 32508ecd16e0183767ecb7dd4bbeca82eccfdb0a /example/example-batch.hcl | |
parent | ec3eba576a1a9574c6a2be8d90d973badb34f455 (diff) | |
download | nomad-driver-nix2-fa49c13513ae5ab66157c634de244fdcf0a6cc1d.tar.gz nomad-driver-nix2-fa49c13513ae5ab66157c634de244fdcf0a6cc1d.zip |
Works better and better, write some examples
Diffstat (limited to 'example/example-batch.hcl')
-rw-r--r-- | example/example-batch.hcl | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/example/example-batch.hcl b/example/example-batch.hcl new file mode 100644 index 0000000..a4dc946 --- /dev/null +++ b/example/example-batch.hcl @@ -0,0 +1,46 @@ +job "nix2-example-batch" { + datacenters = ["dc1"] + type = "batch" + + group "example" { + # Simple example: how to run a binary from a Nixpkgs package + # By default, this will use nixpkgs from github:nixos/nixpkgs/nixos-22.05 + # as a base system, as defined in the agent config file. + # This could be overridden by setting nixpkgs = "another flake" + # inside the config {} block + task "nix-hello" { + driver = "nix2" + + config { + packages = [ + "hello" # equivalent to "github:nixos/nixpkgs/nixos-22.05#hello" + ] + command = "hello" + } + } + + # This example show how to setup root CA certificates so that jobs + # can do TLS connections + # Here, a Nix profile is built using packages curl and cacert from nixpkgs. + # Because the cacert package is included, the ca-bundle.crt file is added to + # /etc in that profile. Then, the nix2 driver binds all files from that + # profile in the root directory, making ca-bundle.crt available directly under /etc. + # Reference: see https://gist.github.com/CMCDragonkai/1ae4f4b5edeb021ca7bb1d271caca999 + task "nix-curl-ssl" { + driver = "nix2" + + config { + packages = [ + "curl", "cacert" + ] + command = "curl" + args = [ + "https://nixos.org" + ] + } + env = { + SSL_CERT_FILE = "/etc/ssl/certs/ca-bundle.crt" + } + } + } +} |