diff --git a/map.jinja b/map.jinja new file mode 100644 index 0000000..6dfca76 --- /dev/null +++ b/map.jinja @@ -0,0 +1,6 @@ +{% set noveria = { + 'bin_dir': '/usr/local/noveria/bin', + 'app_dir': '/usr/local/noveria/apps', + 'commonrc_dir': '/etc/commonrc.d', + 'zsh_dir': '/etc/zsh.d' +} %} \ No newline at end of file diff --git a/system/base.sls b/system/base.sls index 75ccc23..8a4df46 100644 --- a/system/base.sls +++ b/system/base.sls @@ -5,4 +5,22 @@ system_base_pkgs: - linux-firmware-none - openjdk17-jre-headless - jq - - zsh + - vim + +system_base_bin_dir: + file.directory: + - name: /usr/local/noveria/bin + - makedirs: true + - user: root + - group: root + - dir_mode: '0755' + - file_mode: '0644' + +system_base_apps_dir: + file.directory: + - name: /usr/local/noveria/apps + - makedirs: true + - user: root + - group: root + - dir_mode: '0755' + - file_mode: '0644' \ No newline at end of file diff --git a/system/files/salt_minion b/system/files/salt_minion new file mode 100644 index 0000000..351b866 --- /dev/null +++ b/system/files/salt_minion @@ -0,0 +1,7 @@ +--- +file_client: local +file_roots: + base: + - /srv/salt +state_verbose: false +... diff --git a/system/files/shell_commonrc.jinja b/system/files/shell_commonrc.jinja new file mode 100644 index 0000000..5a4a6d1 --- /dev/null +++ b/system/files/shell_commonrc.jinja @@ -0,0 +1,21 @@ +# This is the global common rc file sourced by all shells. This is not +# something the shells do natively, we just source this file in the appropriate +# places (/etc/bash.bashrc for bash, /etc/.zshrc for zsh). This file is intended +# for basic stuff that works in all shells, like env vars and aliases. +# +# Notes: +# - The code must be able to run in all shells, so keep it simple +# - Keep in mind that what's put in here affects all users on the system + +# add custom bin to PATH variable +export PATH="${PATH}:{{ CUSTOM_BIN }}" + +# source files from {{ COMMONRC_DIR }} +# use ls in a subshell because zsh will warn about an emtpy glob result by +# default. there's a glob flag to avoid that, but that would be zfs specific. +if [ -d {{ COMMONRC_DIR }} ]; then + for i in $(ls {{ COMMONRC_DIR }}/); do + [ -r "{{ COMMONRC_DIR }}/$i" ] && . "{{ COMMONRC_DIR }}/$i" + done + unset i +fi diff --git a/system/files/shell_keybinds b/system/files/shell_keybinds new file mode 100644 index 0000000..e2fb16c --- /dev/null +++ b/system/files/shell_keybinds @@ -0,0 +1,13 @@ +# zsh keys configuration +bindkey "^[[H" beginning-of-line +bindkey "^[[F" end-of-line +bindkey "^[[2~" overwrite-mode +bindkey "^[[3~" delete-char +bindkey "^[[A" up-line-or-history +bindkey "^[[B" down-line-or-history +bindkey "^[[D" backward-char +bindkey "^[[C" forward-char +bindkey "^[[1;5D" backward-word +bindkey "^[[1;5C" forward-word +bindkey "^[[5~" beginning-of-buffer-or-history +bindkey "^[[6~" end-of-buffer-or-history \ No newline at end of file diff --git a/system/files/shell_zshenv.jinja b/system/files/shell_zshenv.jinja new file mode 100644 index 0000000..1495d0f --- /dev/null +++ b/system/files/shell_zshenv.jinja @@ -0,0 +1,14 @@ +#!/usr/bin/env zsh + +# XDG +export XDG_CONFIG_HOME=$HOME/.config +export XDG_DATA_HOME=$XDG_CONFIG_HOME/local/share +export XDG_CACHE_HOME=$XDG_CONFIG_HOME/cache + +# editor +export EDITOR="vim" + +# zsh +export HISTFILE="$HOME/.zhistory" # History filepath +export HISTSIZE=10000 # Maximum events for internal history +export SAVEHIST=10000 # Maximum events in history file \ No newline at end of file diff --git a/system/files/shell_zshrc.jinja b/system/files/shell_zshrc.jinja new file mode 100644 index 0000000..35d8b48 --- /dev/null +++ b/system/files/shell_zshrc.jinja @@ -0,0 +1,6 @@ +# load commonrc which is shared by all shell types +[ -f /etc/commonrc ] && . /etc/commonrc +[ -f /etc/.zshenv ] && . /etc/.zshenv +[ -f {{ ZSH_DIR }}/00-keybinds ] && . {{ ZSH_DIR }}/00-keybinds + +export LANG=en_US.UTF-8 \ No newline at end of file diff --git a/system/init.sls b/system/init.sls index 7cbd088..d334958 100644 --- a/system/init.sls +++ b/system/init.sls @@ -5,3 +5,6 @@ include: - .firewall - .network - .user + - .shell + - .salt + - .localization diff --git a/system/localization.sls b/system/localization.sls new file mode 100644 index 0000000..7422b9b --- /dev/null +++ b/system/localization.sls @@ -0,0 +1,35 @@ +# Localization + +# keyboard layout +system_localization_keyboard_layout: + keyboard.system: + - name: de_CH-latin1 + +system_localization_vconsole_conf: + file.managed: + - name: /etc/vconsole.conf + - user: root + - group: root + - mode: '0644' + - contents: KEYMAP=de_CH-latin1 + +# Locale +system_localization_locale_en_us_utf: + locale.present: + - name: en_US.UTF-8 UTF-8 + +system_localization_locale_en_us_iso: + locale.present: + - name: en_US ISO-8859-1 + +system_localization_locale_de_ch_utf: + locale.present: + - name: de_CH.UTF-8 UTF-8 + +system_localization_locale_default: + file.managed: + - name: /etc/locale.conf + - user: root + - group: root + - mode: '0644' + - contents: 'LANG=en_US.UTF-8' diff --git a/system/salt.sls b/system/salt.sls new file mode 100644 index 0000000..65631dd --- /dev/null +++ b/system/salt.sls @@ -0,0 +1,39 @@ +include: + - system.base + +system_salt_pkg: + pkg.installed: + - pkgs: + - salt-minion + - require: + - system_base_pkgs + +system_salt_minion_config: + file.managed: + - name: /etc/salt/minion + - source: salt://{{ tpldir }}/files/salt_minion + - user: root + - group: root + - mode: '0644' + +system_salt_minon_service: + service.disabled: + - name: salt-minion + - require: + - system_salt_pkg + +system_salt_minion_cachedir_permission: + file.directory: + - name: /var/cache/salt/minion + - mode: '0700' + - require: + - system_salt_pkg + +system_salt_minion_logdir_permission: + file.directory: + - name: /var/log/salt + - user: root + - group: root + - mode: '0700' + - require: + - system_salt_pkg diff --git a/system/shell.sls b/system/shell.sls new file mode 100644 index 0000000..e394dea --- /dev/null +++ b/system/shell.sls @@ -0,0 +1,73 @@ +include: + - system.base + +{% from "map.jinja" import noveria %} + +system_shell_pkgs: + pkg.installed: + - pkgs: + - zsh + - bash + - require: + - system_base_pkgs + +system_shell_commonrc: + file.managed: + - name: /etc/commonrc + - source: salt://{{ tpldir }}/files/shell_commonrc.jinja + - template: jinja + - context: + CUSTOM_BIN: {{ noveria.bin_dir }} + COMMONRC_DIR: {{ noveria.commonrc_dir }} + - user: root + - group: root + - mode: '0644' + - require: + - system_shell_pkgs + +system_shell_zsh_include_commonrc: + file.managed: + - name: /etc/.zshrc + - source: salt://{{ tpldir }}/files/shell_zshrc.jinja + - template: jinja + - context: + ZSH_DIR: {{ noveria.zsh_dir }} + - user: root + - group: root + - mode: '0644' + - makedirs: false + - require: + - system_shell_commonrc + +system_shell_zsh_zshenv: + file.managed: + - name: /etc/.zshenv + - source: salt://{{ tpldir }}/files/shell_zshenv.jinja + - template: jinja + - user: root + - group: root + - mode: '0644' + - makedirs: false + - require: + - system_shell_commonrc + +system_shell_zshd_directory: + file.directory: + - name: {{ noveria.zsh_dir }} + - user: root + - group: root + - dir_mode: '0755' + - file_mode: '0644' + - makedirs: true + - require: + - system_shell_packages + +system_shell_zsh_keybinds: + file.managed: + - name: {{ noveria.zsh_dir }}/00-keybinds + - source: salt://{{ tpldir }}/files/shell_keybinds + - user: root + - group: root + - mode: '0644' + - require: + - system_shell_zshd_directory \ No newline at end of file diff --git a/util/files/noveriablcgen.jinja.sh b/util/files/noveriablcgen.jinja.sh deleted file mode 100644 index 96b4b06..0000000 --- a/util/files/noveriablcgen.jinja.sh +++ /dev/null @@ -1 +0,0 @@ -#!/bin/sh \ No newline at end of file diff --git a/util/files/noveriablcgen_config.json.jinja b/util/files/noveriablcgen_config.json.jinja new file mode 100644 index 0000000..177d047 --- /dev/null +++ b/util/files/noveriablcgen_config.json.jinja @@ -0,0 +1,6 @@ +{ + "be_env_dir": "{{ BTRFS_ROOT }}", + "grub_conf_dir": "{{ GRUB_CONFD }}", + "filename": "{{ GRUB_CONFIG_FILENAME }}", + "root_uuid": "{{ ROOT_UUID }}" +} \ No newline at end of file diff --git a/util/noveriablcgen.sls b/util/noveriablcgen.sls index e69de29..0a754d1 100644 --- a/util/noveriablcgen.sls +++ b/util/noveriablcgen.sls @@ -0,0 +1,39 @@ +include: + - system.base + +{% from "map.jinja" import noveria %} + +util_noveriablcgen_git: + git.latest: + - name: https://gitlab.com/noveria/tools/noveriablcgen.git + - target: {{ noveria.app_dir }} + - user: root + - require: + - system_base_apps_dir + +util_noveriablcgen_link: + file.symlink: + - name: {{ noveria.bin_dir }} + - target: {{ noveria.app_dir }}/noveriablcgen/noveriablcgen + - user: root + - group: root + - mode: '0755' + - require: + - system_base_bin_dir + - util_noveriablcgen_git + +util_noveriablcgen_config: + file.managed: + - name: {{ noveria.apps_dir }}/noveriablcgen/noveriablcgen.json + - target: salt://{{ tpldir }}/files/noveriablcgen_config.json.jinja + - template: jinja + - context: + BTRFS_ROOT: "/btrfs" + GRUB_CONFD: "/etc/grub.d" + GRUB_CONFIG_FILENAME: "10-noveria.conf" + ROOT_UUID: {{ salt['cmd.shell']('lsblk -o LABEL,UUID | grep ROOT | awk \'{print $2}\'') }} + - mode: '0644' + - user: root + - group: root + - require: + - util_noveriablcgen_git \ No newline at end of file