---
- name: river | Create config directory
  file:
    path: '{{ xdg_dir.config_home }}/river'
    state: directory
    mode: '755'

- name: river | Copy init lua script
  template:
    src: river/init.j2
    dest: '{{ xdg_dir.config_home }}/river/init.lua'
    mode: '644'

- name: river | Copy the actual init script invoked by river
  copy:
    src: river/init
    dest: '{{ xdg_dir.config_home }}/river/init'
    mode: '755'

- name: river | Compile init lua script to bytecode with luajit
  command:
    cmd: /usr/bin/luajit -b init.lua init_compiled.lua
    chdir: '{{ xdg_dir.config_home }}/river'
    removes: /usr/bin/luajit
