github.com/hernad/nomad@v1.6.112/drivers/nix/example/example-batch.hcl (about)

     1  job "nix2-example-batch" {
     2    datacenters = ["dc1"]
     3    type        = "batch"
     4  
     5    group "example" {
     6      # Simple example: how to run a binary from a Nixpkgs package
     7      # By default, this will use nixpkgs from github:nixos/nixpkgs/nixos-22.05
     8      # as a base system, as defined in the agent config file.
     9      # This could be overridden by setting nixpkgs = "another flake"
    10      # inside the config {} block
    11      task "nix-hello" {
    12        driver = "nix2"
    13  
    14        config {
    15          # Packages contains a list of Nix flakes to include in the environement.
    16          # Entries that start with # will be relative to nixpkgs.
    17          # Otherwise, they are flake names that are passed directly to Nix build
    18          packages = [
    19            "#hello"   # equivalent to "github:nixos/nixpkgs/nixos-22.05#hello"
    20          ]
    21          command = "hello"
    22        }
    23      }
    24  
    25      # This example show how to setup root CA certificates so that jobs
    26      # can do TLS connections 
    27      # Here, a Nix profile is built using packages curl and cacert from nixpkgs.
    28      # Because the cacert package is included, the ca-bundle.crt file is added to
    29      # /etc in that profile. Then, the nix2 driver binds all files from that
    30      # profile in the root directory, making ca-bundle.crt available directly under /etc.
    31      # Reference: see https://gist.github.com/CMCDragonkai/1ae4f4b5edeb021ca7bb1d271caca999
    32      task "nix-curl-ssl" {
    33        driver = "nix2"
    34  
    35        config {
    36          packages = [
    37            "#curl", "#cacert"
    38          ]
    39          command = "curl"
    40          args = [
    41            "https://nixos.org"
    42          ]
    43        }
    44        env = {
    45          SSL_CERT_FILE = "/etc/ssl/certs/ca-bundle.crt"
    46        }
    47      }
    48  
    49      # This example show how to use a flake defined from a file
    50      task "nix-hello-flake" {
    51        driver = "nix2"
    52  
    53        config {
    54          # Packages contains a list of Nix flakes to include in the environement.
    55          # Entries that start with # will be relative to nixpkgs.
    56          # Otherwise, they are flake names that are passed directly to Nix build
    57          packages = [
    58            ".#hello"
    59          ]
    60          command = "hello"
    61        }
    62  
    63        template {
    64          data = file("flake.nix")
    65          destination = "flake.nix"
    66        }
    67      }
    68    }
    69  }