# | nix-amer | [![Go version](https://img.shields.io/badge/go_version-1.11-blue.svg)](https://golang.org/doc/go1.11) [![License: MIT](https://img.shields.io/github/license/xdrm-brackets/nix-amer.svg)](https://opensource.org/licenses/MIT) [![Go Report Card](https://goreportcard.com/badge/git.xdrm.io/go/nix-amer)](https://goreportcard.com/report/git.xdrm.io/go/nix-amer) [![Coverage Status](https://img.shields.io/coveralls/github/xdrm-brackets/nix-amer/master.svg)](https://coveralls.io/github/xdrm-brackets/nix-amer?branch=master) [![Build Status](https://drone.xdrm.io/api/badges/xdrm-brackets/ci-test/status.svg)](https://drone.xdrm.io/xdrm-brackets/ci-test) [![Go doc](https://godoc.org/git.xdrm.io/go/nix-amer?status.svg)](https://godoc.org/git.xdrm.io/go/nix-amer) ```yaml name: nix-amer version: 0.1.0 description: Configuration automation tool author: xdrm-brackets ``` >Need to automate the setup of your linux server or desktop ? This tool is made for you. * [I. How to use](#i-how-to-use) + [1) Requirements](#1-requirements) + [2) Installation](#2-installation) + [3) Usage](#3-usage) * [1. Create build file](#1-create-build-file) * [2. Run on the target](#2-run-on-the-target) * [II. Commands](#ii-commands) + [1) Sections](#1-sections) + [2) Comments](#2-comments) + [3) Install/remove Packages](#3-installremove-packages) + [4) Setup configuration](#4-setup-configuration) + [5) Service management](#5-service-management) + [6) Custom scripts](#6-custom-scripts) + [7) Copy files](#7-copy-files) + [8) Aliases](#8-aliases) * [III. Path Expressions](#iii-path-expressions) + [1) Syntax](#1-syntax) + [2) File Formats](#2-file-formats) - [Example](#example) ---- ### I. How to use #### 1) Requirements In order to install the `nix-amer` executable, you must have : - any recent linux system (_has not been tested over other OS_) - `go` installed (_has not been tested under version **1.11**_) #### 2) Installation Simply launch the following command in any terminal ```bash $ go get -u git.xdrm.io/go/nix-amer ``` > For those who don't know, it will load the project sources into `$GOPATH/src/git.xdrm.io/go/nix-amer` and compile into the executable at `$GOPATH/bin/nix-amer`. #### 3) Usage ###### 1. Create build file The first step is to write your build file according to the installation you want. While writing it you can check the syntax and validate instructions by using the `-dry-run` command-line argument as follows : ```bash $ nix-amer -p apt-get -dry-run ``` > The `-p` argument (package manager) is mandatory but it will have no effect in `-dry-run` mode. You can use for instance `apt-get` as a default. ###### 2. Run on the target Once your build file is correct and fulfills your needs, you can log in to the target machine, install nix-amer and run it with your build file. The rich and colorful command-line output will give you a good feedback to rapidly fix problems. ------ ### II. Commands Your whole setup remains in only one file. Each line contains one instruction, the list of instructions is listed below. #### 1) Sections Each instruction is enclosed in a section (_cf. ini file format_), a section definition stands on a line where the name of the section is surrounded by `[` and `]`. Each section is executed in parallel ; the special section named `pre` is executed before every other. #### 2) Comments Each line beginning with one of the following characters : `#` or `;` is considered a comment and is not interpreted. #### 3) Install/remove Packages These instructions allow you to interact with the package system available on your system. ``` install ``` Install the listed packages. If more than one, use spaces to separate package names. ``` delete ``` Remove the listed packages. If more than one, use spaces to separate package names. #### 4) Setup configuration This instruction allow you to set fields of configuration files without the need of an editor and in a developer-readable manner. ``` set ``` Update a configuration file where \ is a dot-separated human-readable [path expression](#ii-path-expressions) and \ is a string or a file. If a string is given, it will override/add the field ; if a file is given the configuration file will be replaced by it. #### 5) Service management These instructions allow you to interact with the service system (_cf. [systemd](https://github.com/systemd/systemd)_). ``` service [enable|start|stop|restart|reload] ``` Perform the action on services. If more than one, use spaces to separate service names. #### 6) Custom scripts This instruction allows you to use custom scripts for complex operations. ``` run