image:
  distribution: "voidlinux"

simplestream:
  distro_name: Void Linux

source:
  downloader: voidlinux-http
  url: https://mirrors.servercentral.com/voidlinux/live/current/
  keys:
  # 0xCF24B9C038097D8A44958E2C8DEBDA68B48282A4
  - |-
    -----BEGIN PGP PUBLIC KEY BLOCK-----

    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
    jSR63W3CMASolag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UvTGWj327H4iprZC1xesb+P5TWd9pt0egjgg
    pq9CD5sjsaMFdSzsgUFAMtDpeJ4sqJiaJE8/vJBoaPhk/jfs/OOEdFnQ0jiv8xLt
    aJJU9TBAtb6B8Vd4ZcFjlid/HroUvDGT2x7fundHLwMVduhNDSDNgzwOSHpckkNb
    db4nlXafR9hozvGboYm2BehVOCk+3gtgURYpfu/0G1Jn0OpOPHM=
    =DFTs
    -----END PGP PUBLIC KEY BLOCK-----

targets:
  lxc:
    create_message: |-
      You just created a {{ image.description }} container.
    config:
    - type: all
      before: 5
      content: |-
        lxc.include = LXC_TEMPLATE_CONFIG/voidlinux.common.conf

    - type: user
      before: 5
      content: |-
        lxc.include = LXC_TEMPLATE_CONFIG/voidlinux.userns.conf

    - type: all
      after: 4
      content: |-
        lxc.include = LXC_TEMPLATE_CONFIG/common.conf

    - type: user
      after: 4
      content: |-
        lxc.include = LXC_TEMPLATE_CONFIG/userns.conf

    - type: all
      content: |-
        lxc.arch = {{ image.architecture_personality }}

files:
- path: /etc/hostname
  generator: hostname

- path: /etc/hosts
  generator: hosts

packages:
  manager: xbps
  update: true
  cleanup: true
  sets:
  - packages:
    - cronie
    - dhclient
    - socklog-void
    - sudo
    action: install

actions:

- trigger: post-unpack
  action: |-
    #!/bin/sh
    set -eux

    echo repository=https://mirrors.servercentral.com/voidlinux/current/ > /usr/share/xbps.d/00-repository-main.conf
  architectures:
  - x86_64
  - i686
  - armv7l
  variants:
  - default

- trigger: post-unpack
  action: |-
    #!/bin/sh
    set -eux

    echo repository=https://mirrors.servercentral.com/voidlinux/current/musl/ > /usr/share/xbps.d/00-repository-main.conf
  architectures:
  - x86_64
  - i686
  - armv7l
  variants:
  - musl

- trigger: post-unpack
  action: |-
    #!/bin/sh
    set -eux

    echo repository=https://mirrors.servercentral.com/voidlinux/current/aarch64/ > /usr/share/xbps.d/00-repository-main.conf
  architectures:
  - aarch64

- trigger: post-unpack
  action: |-
    #!/bin/sh
    set -eux

    rm -rf /etc/ssl/certs/DST_Root_CA_X3.pem /usr/share/ca-certificates/mozilla/DST_Root_CA_X3.crt /etc/ssl/certs/2e5ac55d.0
    update-ca-certificates

    xbps-install -y -S
    xbps-install -y -u xbps || true

- trigger: post-unpack
  action: |-
    #!/bin/sh
    set -eux

    # This fixes an issue with newer glibc versions and xbps.
    # It's important that xbps is updated before glibc.
    [ -e /lib64 ] || ln -s lib /lib64
    echo ignorepkg=glibc > /etc/xbps.d/glibc.conf
  variants:
  - default

- trigger: post-unpack
  action: |-
    #!/bin/sh
    set -eux

    echo repository=https://mirrors.servercentral.com/voidlinux/current/ > /usr/share/xbps.d/00-repository-main.conf
  architectures:
  - x86_64
  - i686
  - armv7l
  variants:
  - default

- trigger: post-unpack
  action: |-
    #!/bin/sh
    set -eux

    echo repository=https://mirrors.servercentral.com/voidlinux/current/musl/ > /usr/share/xbps.d/00-repository-main.conf
  architectures:
  - x86_64
  - i686
  - armv7l
  variants:
  - musl

- trigger: post-unpack
  action: |-
    #!/bin/sh
    set -eux

    echo repository=https://mirrors.servercentral.com/voidlinux/current/aarch64/ > /usr/share/xbps.d/00-repository-main.conf
  architectures:
  - aarch64

- trigger: post-packages
  action: |-
    #! /bin/sh
    set -eux

    # Create dhclient-eth0 service
    mkdir /etc/sv/dhclient-eth0/
    cp /etc/sv/dhclient/run /etc/sv/dhclient-eth0/
    ln -s /run/runit/supervise.dhclient-eth0 /etc/sv/dhclient-eth0/supervice
    sed -i "/^exec dhclient/ s/$/eth0/" /etc/sv/dhclient-eth0/run

    # Configure stopit on each boot.
    # This ensures that the container performs a shutdown when receiving SIGCONT.
    # Runit will only perform a shutdown if /etc/runit/stopit has mode 100, and /etc/runit/reboot has mode 0.
    mkdir /etc/sv/setup-stopit
    cat << EOF > /etc/sv/setup-stopit/run
    #! /bin/sh
    mkdir -p /run/runit
    install -m100 /dev/null /run/runit/stopit
    EOF

    chmod +x /etc/sv/setup-stopit/run

    # Enable services
    ln -s /etc/sv/socklog-unix /etc/runit/runsvdir/default/
    ln -s /etc/sv/nanoklogd /etc/runit/runsvdir/default/
    ln -s /etc/sv/dhclient-eth0 /etc/runit/runsvdir/default/
    ln -s /etc/sv/cronie /etc/runit/runsvdir/default/
    ln -s /etc/sv/agetty-console /etc/runit/runsvdir/default/
    ln -s /etc/sv/setup-stopit /etc/runit/runsvdir/default/

    # Disable services
    for tty in 1 2 3 4 5 6; do
        rm /etc/runit/runsvdir/default/agetty-tty${tty}
        touch /etc/sv/agetty-tty${tty}/down
    done

- trigger: post-packages
  action: |-
    #! /bin/sh
    set -eux

    rm -f /etc/xbps.d/glibc.conf
  variants:
  - default

mappings:
  architecture_map: voidlinux
