Documentationcurrent version
Help us improve the docs by fixing typos and proposing enhancements.


Action "system.tmpfs"

Mount a directory with tmpfs.d as a tmpfs configuration file.

Callback parameters

  • $status
    Wheter the directory was mounted or already mounted.


All parameters can be omitted except type. nikita.tmpfs will ommit by replacing the undefined value as '-', which does apply the os default behavior.

Setting uid/gid to '-', make the os creating the target owned by root:root.

Schema definitions

definitions =
    type: 'object'
        type: 'string'
        description: '''
        Used to decide what files to delete when cleaning.
        type: 'string'
        description: '''
        The destination path of the symlink if type is `L`.
        type: ['boolean', 'string']
        default: true
        description: '''
        Create a backup, append a provided string to the filename extension or
        a timestamp if value is not a string, only apply if the target file
        exists and is modified.
        $ref: 'module://@nikitajs/core/lib/actions/fs/chown#/definitions/config/properties/gid'
        description: '''
        File group name or group id.
        type: 'boolean'
        default: true
        description: '''
        Overrides properties if already exits.
        type: 'string'
        description: '''
        The mount point dir to create on system startup.
        $ref: 'module://@nikitajs/core/lib/actions/fs/chmod#/definitions/config/properties/mode'
        description: '''
        Mode of the target configuration file
        type: 'string'
        description: '''
        The file name, can not be used with target. If only `name` is set, it
        writes the content to default configuration directory and creates the
        file  as '`name`.conf'.
        type: 'string'
        default: '0644'
        description: '''
        Mount path mode in string format like `"0644"`.
        type: 'string'
        description: '''
        File path where to write content to. Defined to
        /etc/tmpfiles.d/{config.uid}.conf if uid is defined or
        $ref: 'module://@nikitajs/core/lib/actions/fs/chown#/definitions/config/properties/uid'
        description: '''
        File user name or user id.
    required: ['mount']


handler = ({config, tools: {log}}) ->
  # for now only support directory type path option
  content = {}
  content[config.mount] = {}
  content[config.mount][key] = config[key] for key in ['mount','perm','uid','gid','age','argu']
  content[config.mount]['type'] = 'd'
  if config.uid? ?= config.uid unless /^[0-9]+/.exec config.uid ?=  if then "/etc/tmpfiles.d/#{}.conf" else '/etc/tmpfiles.d/default.conf'
  log message: "target set to #{}", level: 'DEBUG'
  if config.merge
    log message: "opening target file for merge", level: 'DEBUG'
      {data} = await @fs.base.readFile target:, encoding: 'utf8'
      source = utils.tmpfs.parse data
      content = merge source, content
      log message: "content has been merged", level: 'DEBUG'
    catch err
      throw err unless err.code is 'NIKITA_FS_CRS_TARGET_ENOENT'
  # Seriazile and write the content
  content = utils.tmpfs.stringify(content)
  {$status} = await @file
    content: content
    gid: config.gid
    mode: config.mode
    uid: config.uid
  if $status
    log message: "re-creating #{config.mount} tmpfs file", level: 'INFO'
      command: "systemd-tmpfiles --remove #{}"
      command: "systemd-tmpfiles --create #{}"


module.exports =
  handler: handler
    definitions: definitions


utils = require './utils'
{merge} = require 'mixme'
Edit on GitHub

Nikita is an open source project hosted on GitHub and developed by Adaltas.