alejandra: initial repo format

This commit is contained in:
Fiscal Velvet Poet 2022-08-15 17:32:25 +10:00
parent 180d6bc1a5
commit 584f00ed86
Signed by: fiscalvelvetpoet
GPG key ID: D8EBFD58B023BD47
13 changed files with 426 additions and 435 deletions

View file

@ -1,18 +1,20 @@
# Configuration common to all JFDIC Linode VMs # Configuration common to all JFDIC Linode VMs
{ config, pkgs, lib, ... }:
{ {
config,
pkgs,
lib,
...
}: {
imports = [ imports = [
# Import the NixOS Qemu guest settings # Import the NixOS Qemu guest settings
<nixpkgs/nixos/modules/profiles/qemu-guest.nix> <nixpkgs/nixos/modules/profiles/qemu-guest.nix>
]; ];
boot.initrd.availableKernelModules = [ "virtio_pci" "ahci" "sd_mod" ]; boot.initrd.availableKernelModules = ["virtio_pci" "ahci" "sd_mod"];
boot.initrd.kernelModules = [ ]; boot.initrd.kernelModules = [];
boot.kernelModules = [ ]; boot.kernelModules = [];
boot.extraModulePackages = [ ]; boot.extraModulePackages = [];
boot.kernelParams = [ "console=ttyS0,19200n8" ]; boot.kernelParams = ["console=ttyS0,19200n8"];
boot.loader = { boot.loader = {
grub = { grub = {
extraConfig = '' extraConfig = ''
@ -26,10 +28,10 @@
}; };
# File systems configuration for the Linode VMs # File systems configuration for the Linode VMs
fileSystems."/" = fileSystems."/" = {
{ device = "/dev/sda"; device = "/dev/sda";
fsType = "ext4"; fsType = "ext4";
}; };
swapDevices = [ swapDevices = [
{ {

View file

@ -1,13 +1,14 @@
# NixOps configuration common to Linode VMs # NixOps configuration common to Linode VMs
{ config, pkgs, lib, ... }:
{ {
imports = config,
[ pkgs,
../profiles/host_common.nix lib,
../profiles/server_common.nix ...
]; }: {
imports = [
../profiles/host_common.nix
../profiles/server_common.nix
];
# Ensure the right package architecture is used # Ensure the right package architecture is used
nixpkgs.localSystem = { nixpkgs.localSystem = {
@ -29,9 +30,8 @@
interfaces.eth0.useDHCP = true; interfaces.eth0.useDHCP = true;
firewall = { firewall = {
enable = true; enable = true;
allowedTCPPorts = [ 80 443 ]; allowedTCPPorts = [80 443];
trustedInterfaces = [ "lo" ]; trustedInterfaces = ["lo"];
}; };
}; };
} }

View file

@ -1,11 +1,12 @@
# NixOps configuration for the Linode VMs # NixOps configuration for the Linode VMs
{ config, pkgs, lib, ... }:
{ {
imports = config,
[ pkgs,
../hardware/linode_vm.nix lib,
./linode-common.nix ...
]; }: {
imports = [
../hardware/linode_vm.nix
./linode-common.nix
];
} }

View file

@ -1,9 +1,5 @@
# Configuration common to all JFDIC servers # Configuration common to all JFDIC servers
{config, ...}: {
{ config, ... }:
{
# Program defaults for all hosts # Program defaults for all hosts
programs.bash = { programs.bash = {
interactiveShellInit = '' interactiveShellInit = ''
@ -15,5 +11,4 @@
''; '';
vteIntegration = true; vteIntegration = true;
}; };
} }

View file

@ -1,11 +1,6 @@
# NixOps configuration for the hosts running a Chrony service # NixOps configuration for the hosts running a Chrony service
{config, ...}: {
{ config, ... }:
{
services.chrony = { services.chrony = {
enable = true; # Enable Chrony enable = true; # Enable Chrony
}; };
} }

View file

@ -1,26 +1,27 @@
# NixOps configuration for the hosts running Gitea # NixOps configuration for the hosts running Gitea
{ config, pkgs, lib, ... }:
{ {
config,
pkgs,
lib,
...
}: {
services.gitea = { services.gitea = {
enable = true; # Enable Gitea enable = true; # Enable Gitea
appName = "JFDI Collective: Gitea Service"; # Give the site a name appName = "JFDI Collective: Gitea Service"; # Give the site a name
database = { database = {
type = "postgres"; # Database type type = "postgres"; # Database type
passwordFile = "/run/keys/gitea-dbpass"; # Where to find the password passwordFile = "/run/keys/gitea-dbpass"; # Where to find the password
}; };
disableRegistration = true; disableRegistration = true;
domain = "source.jfdic.org"; # Domain name domain = "source.jfdic.org"; # Domain name
rootUrl = "https://source.jfdic.org/"; # Root web URL rootUrl = "https://source.jfdic.org/"; # Root web URL
httpPort = 3002; # Provided unique port httpPort = 3002; # Provided unique port
settings = let settings = let
docutils = docutils = pkgs.python37.withPackages (ps:
pkgs.python37.withPackages (ps: with ps; [ with ps; [
docutils # Provides rendering of ReStructured Text files docutils # Provides rendering of ReStructured Text files
pygments # Provides syntax highlighting pygments # Provides syntax highlighting
]); ]);
in { in {
mailer = { mailer = {
ENABLED = true; ENABLED = true;
@ -39,25 +40,27 @@
IS_INPUT_FILE = false; IS_INPUT_FILE = false;
}; };
ui = { ui = {
DEFAULT_THEME = "gitea"; # Set the default theme DEFAULT_THEME = "gitea"; # Set the default theme
}; };
}; };
}; };
services.postgresql = { services.postgresql = {
enable = true; # Ensure postgresql is enabled enable = true; # Ensure postgresql is enabled
authentication = '' authentication = ''
local gitea all ident map=gitea-users local gitea all ident map=gitea-users
''; '';
identMap = # Map the gitea user to postgresql identMap =
# Map the gitea user to postgresql
'' ''
gitea-users gitea gitea gitea-users gitea gitea
''; '';
ensureDatabases = [ "gitea" ]; # Ensure the database persists ensureDatabases = ["gitea"]; # Ensure the database persists
ensureUsers = [ ensureUsers = [
{ {
name = "gitea"; # Ensure the database user persists name = "gitea"; # Ensure the database user persists
ensurePermissions = { # Ensure the database permissions persist ensurePermissions = {
# Ensure the database permissions persist
"DATABASE gitea" = "ALL PRIVILEGES"; "DATABASE gitea" = "ALL PRIVILEGES";
"ALL TABLES IN SCHEMA public" = "ALL PRIVILEGES"; "ALL TABLES IN SCHEMA public" = "ALL PRIVILEGES";
}; };
@ -66,15 +69,16 @@
}; };
services.nginx = { services.nginx = {
enable = true; # Enable Nginx enable = true; # Enable Nginx
recommendedGzipSettings = true; recommendedGzipSettings = true;
recommendedOptimisation = true; recommendedOptimisation = true;
recommendedProxySettings = true; recommendedProxySettings = true;
recommendedTlsSettings = true; recommendedTlsSettings = true;
virtualHosts."source.jfdic.org" = { # Gitea hostname virtualHosts."source.jfdic.org" = {
enableACME = true; # Use ACME certs # Gitea hostname
forceSSL = true; # Force SSL enableACME = true; # Use ACME certs
locations."/".proxyPass = "http://localhost:3002/"; # Proxy Gitea forceSSL = true; # Force SSL
locations."/".proxyPass = "http://localhost:3002/"; # Proxy Gitea
}; };
}; };
@ -85,6 +89,5 @@
}; };
}; };
users.groups.keys.members = [ "gitea" ]; # Required due to NixOps issue #1204 users.groups.keys.members = ["gitea"]; # Required due to NixOps issue #1204
} }

View file

@ -1,9 +1,10 @@
# Configuration common to all JFDIC servers # Configuration common to all JFDIC servers
{ config, pkgs, lib, ... }:
{ {
config,
pkgs,
lib,
...
}: {
imports = [ imports = [
../profiles/bash.nix ../profiles/bash.nix
../profiles/chrony.nix ../profiles/chrony.nix
@ -17,22 +18,22 @@
# Common boot settings # Common boot settings
boot = { boot = {
cleanTmpDir = true; # Clean /tmp on reboot cleanTmpDir = true; # Clean /tmp on reboot
}; };
# Select internationalisation properties. # Select internationalisation properties.
i18n = { i18n = {
defaultLocale = "en_AU.UTF-8"; # Set the default locale defaultLocale = "en_AU.UTF-8"; # Set the default locale
}; };
# Set the defaul console properties # Set the defaul console properties
console = { console = {
keyMap = "us"; # Set the default console key map keyMap = "us"; # Set the default console key map
font = "ter-powerline-v16Rv"; # Set the default console font font = "ter-powerline-v16Rv"; # Set the default console font
}; };
time.timeZone = "Etc/UTC"; time.timeZone = "Etc/UTC";
documentation.nixos.enable = false; # Disable documentation, save space documentation.nixos.enable = false; # Disable documentation, save space
# Set security options: # Set security options:
security.sudo.enable = true; security.sudo.enable = true;
@ -42,7 +43,7 @@
fonts.enableDefaultFonts = true; fonts.enableDefaultFonts = true;
fonts.fontDir.enable = true; fonts.fontDir.enable = true;
fonts.fonts = with pkgs; [ fonts.fonts = with pkgs; [
powerline-fonts # Required for Powerline prompts powerline-fonts # Required for Powerline prompts
]; ];
fonts.fontconfig.includeUserConf = false; fonts.fontconfig.includeUserConf = false;
@ -52,7 +53,8 @@
# Ruin the config so we don't accidentally run # Ruin the config so we don't accidentally run
# nixos-rebuild switch on the host # nixos-rebuild switch on the host
(let (let
cfg = pkgs.writeText "configuration.nix" cfg =
pkgs.writeText "configuration.nix"
'' ''
assert builtins.trace "This system is managed by NixOps." false; assert builtins.trace "This system is managed by NixOps." false;
{} {}
@ -63,7 +65,7 @@
"nixpkgs=/run/current-system/nixpkgs" "nixpkgs=/run/current-system/nixpkgs"
]; ];
gc = { gc = {
automatic = true; # Enable Nix garbage collection: automatic = true; # Enable Nix garbage collection:
dates = "weekly"; dates = "weekly";
options = "--delete-older-than 90d"; options = "--delete-older-than 90d";
}; };
@ -81,29 +83,29 @@
environment.etc.host-nix-channel.source = pkgs.path; environment.etc.host-nix-channel.source = pkgs.path;
environment.variables = { environment.variables = {
BAT_THEME="Dracula"; BAT_THEME = "Dracula";
}; };
# Set the system-wide environment # Set the system-wide environment
environment = { environment = {
systemPackages = with pkgs; [ systemPackages = with pkgs; [
bat # cat clone with syntax highlighting & Git integration bat # cat clone with syntax highlighting & Git integration
byobu # text-based window manager and terminal multiplexer. byobu # text-based window manager and terminal multiplexer.
dnsutils # Bind DNS utilities dnsutils # Bind DNS utilities
fd # A simple, fast and user-friendly alternative to find fd # A simple, fast and user-friendly alternative to find
git # Distributed version control system git # Distributed version control system
htop # interactive process viewer htop # interactive process viewer
hwinfo # Hardware detection tool hwinfo # Hardware detection tool
killall # kill processes by name killall # kill processes by name
lshw # Detailed information on the hardware configuration lshw # Detailed information on the hardware configuration
lsof # list open files lsof # list open files
mosh # Mobile shell (ssh replacement) mosh # Mobile shell (ssh replacement)
ncdu # Disk usage analyzer with an ncurses interface ncdu # Disk usage analyzer with an ncurses interface
nix-index # A files database for nixpkgs nix-index # A files database for nixpkgs
ripgrep # Utility that provides usability of The Silver Searcher with the raw speed of grep ripgrep # Utility that provides usability of The Silver Searcher with the raw speed of grep
]; ];
}; };
# Users common across JFDIC Ops: # Users common across JFDIC Ops:
users.mutableUsers = false; # Remove any users not defined in here users.mutableUsers = false; # Remove any users not defined in here
} }

View file

@ -1,11 +1,6 @@
# logrotate configuration for NixOS / NixOps # logrotate configuration for NixOS / NixOps
{config, ...}: {
{ config, ... }:
{
services.logrotate = { services.logrotate = {
enable = true; # Enable the logrotate service enable = true; # Enable the logrotate service
}; };
} }

View file

@ -1,300 +1,301 @@
{ pkgs, ... }: {pkgs, ...}: {
{ environment.variables = {EDITOR = "vim";};
environment.variables = { EDITOR = "vim"; };
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
(neovim.override { (
vimAlias = true; neovim.override {
configure = { vimAlias = true;
packages.myPlugins = with pkgs.vimPlugins; { configure = {
start = [ packages.myPlugins = with pkgs.vimPlugins; {
airline # Lean & mean status/tabline for vim that's light as air start = [
dracula-vim # Dracula theme for vim airline # Lean & mean status/tabline for vim that's light as air
fugitive # Vim Git wrapper dracula-vim # Dracula theme for vim
fzf-vim # Full path fuzzy file, buffer, mru, tag, finder for Vim fugitive # Vim Git wrapper
haskell-vim # Syntax Highlighting and Indentation for Haskell fzf-vim # Full path fuzzy file, buffer, mru, tag, finder for Vim
indentLine # Display thin vertical lines at each indentation level haskell-vim # Syntax Highlighting and Indentation for Haskell
neocomplete-vim # Keyword completion system indentLine # Display thin vertical lines at each indentation level
nerdcommenter # Comment functions so powerful—no comment necessary neocomplete-vim # Keyword completion system
nerdtree # File system explorer nerdcommenter # Comment functions so powerful—no comment necessary
nerdtree-git-plugin # Plugin for nerdtree showing git status nerdtree # File system explorer
supertab # Allows you to use <Tab> for all your insert completion nerdtree-git-plugin # Plugin for nerdtree showing git status
syntastic # Syntax checking hacks supertab # Allows you to use <Tab> for all your insert completion
vim-addon-nix # Scripts assisting writing .nix files syntastic # Syntax checking hacks
vim-autoformat # Automatically format code vim-addon-nix # Scripts assisting writing .nix files
vim-cue # Cue filetype plugin for Vim vim-autoformat # Automatically format code
vim-lastplace vim-cue # Cue filetype plugin for Vim
vim-markdown-toc # Generate table of contents for Markdown files vim-lastplace
vim-nix # Support for writing Nix expressions in vim vim-markdown-toc # Generate table of contents for Markdown files
vim-numbertoggle # Toggle between relative / absolute line numbers automatically vim-nix # Support for writing Nix expressions in vim
vim-one vim-numbertoggle # Toggle between relative / absolute line numbers automatically
]; vim-one
opt = []; ];
opt = [];
};
customRC = ''
" Preferred global default settings:
set nocompatible
set backspace=indent,eol,start
set number relativenumber " Enable relative line numbers by default
set cursorline " Highlight the current line number
set smartindent " Automatically insert extra level of indentation
set tabstop=4 " Default tabstop
set shiftwidth=4 " Default indent spacing
set expandtab " Expand [TABS] to spaces
packadd! dracula-vim
syntax on " Enable syntax highlighting
set t_Co=256 " Use 265 colors in vim
set background=dark " Set the default background scheme
colorscheme dracula " Set the default colour scheme
"let g:one_allow_italics = 1 " I love italic for comments
set spell spelllang=en_au " Defaul spell checking language
set spellfile=~/.vim-spell.en.utf-8.add " Add the spellfile
hi clear SpellBad " Clear any unwanted default settings
hi SpellBad cterm=underline " Set the spell checking highlight style
hi SpellBad ctermbg=NONE " Set the spell checking highlight background
match ErrorMsg '\s\+$' "
nnoremap <silent> <C-p> :Files<CR>
nnoremap <silent> <Leader>f :Rg<CR>
set grepprg=rg\ --vimgrep\ --smart-case\ --follow
let g:airline_powerline_fonts = 1 " Use powerline fonts
let g:airline_theme='dracula' " Set the airline theme
"call togglebg#map("<F10>") " Toggle background colour between dark|light
set laststatus=2 " Set up the status line so it's coloured and always on
" Removes trailing spaces:
function! TrimWhiteSpace()
%s/\s\+$//e
endfunction
" Trigger for numbertoggle to switch modes
nnoremap <silent> <C-n> :set relativenumber!<CR>
" Tab settings
let g:SuperTabDefaultCompletionType = 'context'
let g:SuperTabContextTextOmniPrecedence = ['&omnifunc','&completefunc']
let g:SuperTabRetainCompletionType=2
inoremap <expr><Enter> pumvisible() ? "\<C-Y>" : "\<Enter>"
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
nnoremap <silent> <Leader>RemoveTrailingWhiteSpace :call TrimWhiteSpace()<CR>
autocmd FileWritePre * :call TrimWhiteSpace()
autocmd FileAppendPre * :call TrimWhiteSpace()
autocmd FilterWritePre * :call TrimWhiteSpace()
autocmd BufWritePre * :call TrimWhiteSpace()
"autocmd BufWrite * :Autoformat
" FIXME: Currently always set to dark due to issues with Termonad Solarized theme
" Light during the day, dark during the night
let hour = strftime("%H")
if 7 <= hour && hour < 17
"set background=dark
"hi Normal ctermbg=none " Set a transparent background
"let g:airline_solarized_bg='dark' " Set the airline background
else
"set background=dark
"hi Normal ctermbg=none " Set a transparent background
"let g:airline_solarized_bg='dark' " Set the airline background
endif
" Transparent editing of gpg encrypted files.
" By Wouter Hanegraaff <wouter@blub.net>
augroup encrypted
au!
" First make sure nothing is written to ~/.viminfo while editing an encrypted file.
autocmd BufReadPre,FileReadPre *.gpg set viminfo=
" We don't want a swap file, as it writes unencrypted data to disk
autocmd BufReadPre,FileReadPre *.gpg set noswapfile
" Switch to binary mode to read the encrypted file
autocmd BufReadPre,FileReadPre *.gpg set bin
autocmd BufReadPre,FileReadPre *.gpg let ch_save = &ch|set ch=2
autocmd BufReadPost,FileReadPost *.gpg '[,']!gpg --decrypt 2> /dev/null
" Switch to normal mode for editing
autocmd BufReadPost,FileReadPost *.gpg set nobin
autocmd BufReadPost,FileReadPost *.gpg let &ch = ch_save|unlet ch_save
autocmd BufReadPost,FileReadPost *.gpg execute ":doautocmd BufReadPost " . expand("%:r")
" Convert all text to encrypted text before writing
autocmd BufWritePre,FileWritePre *.gpg '[,']!gpg --default-key=A4122FF3971B6865 --default-recipient-self -ae 2>/dev/null
" Undo the encryption so we are back in the normal text, directly
" after the file has been written.
autocmd BufWritePost,FileWritePost *.gpg u
augroup END
" Manage ISO files
augroup iso
au!
" First make sure nothing is written to ~/.viminfo while editing an encrypted file.
autocmd BufReadPre,FileReadPre *.iso set viminfo=
" We don't want a swap file, as it writes unencrypted data to disk
autocmd BufReadPre,FileReadPre *.iso set noswapfile
" Switch to binary mode to read the encrypted file
autocmd BufReadPre,FileReadPre *.iso set bin
autocmd BufReadPre,FileReadPre *.iso let ch_save = &ch|set ch=2
autocmd BufReadPost,FileReadPost *.iso '[,']!gpg --decrypt 2> /dev/null
" Switch to normal mode for editing
autocmd BufReadPost,FileReadPost *.iso set nobin
autocmd BufReadPost,FileReadPost *.iso let &ch = ch_save|unlet ch_save
autocmd BufReadPost,FileReadPost *.iso execute ":doautocmd BufReadPost " . expand("%:r")
" Convert all text to encrypted text before writing
autocmd BufWritePre,FileWritePre *.iso '[,']!gpg --default-key=A4122FF3971B6865 --default-recipient-self -ae 2>/dev/null
" Undo the encryption so we are back in the normal text, directly
" after the file has been written.
autocmd BufWritePost,FileWritePost *.iso u
augroup END
" Use persistent history.
if !isdirectory("/tmp/.vim-undo-dir")
call mkdir("/tmp/.vim-undo-dir", "", 0700)
endif
set undodir=/tmp/.vim-undo-dir
set undofile
" JFDIC Markdown environment
function! MarkdownSettings()
set textwidth=79
set spell spelllang=en_au
endfunction
autocmd BufNewFile,BufFilePre,BufRead *.mdwn :call MarkdownSettings()
autocmd BufNewFile,BufFilePre,BufRead *.md :call MarkdownSettings()
" JFDIC ReStructured Text environment
function! ReStructuredSettings()
set textwidth=79
set spell spelllang=en_au
hi clear SpellBad " Clear any unwanted default settings
hi SpellBad cterm=underline " Set the spell checking highlight style
hi SpellBad ctermbg=NONE " Set the spell checking highlight background
endfunction
autocmd BufNewFile,BufFilePre,BufRead *.rst :call ReStructuredSettings()
autocmd BufNewFile,BufFilePre,BufRead *.txt :call ReStructuredSettings()
" JFDIC LaTeX environment:
function! LaTeXSettings()
set textwidth=79
set spell spelllang=en_au
endfunction
autocmd BufNewFile,BufFilePre,BufRead *.tex :call LaTeXSettings()
" Settings for JFDIC Haskell environment:
function! HaskellSettings()
set tabstop=2
set shiftwidth=2
set expandtab
set textwidth=79
endfunction
autocmd BufNewFile,BufFilePre,BufRead *.hs :call HaskellSettings()
" Settings for JFDIC Nix environment:
function! NixSettings()
set tabstop=2
set shiftwidth=2
set expandtab
set textwidth=79
set filetype=nix
endfunction
autocmd BufNewFile,BufFilePre,BufRead *.nix :call NixSettings()
" Settings for JFDIC Cue environment:
function! CueSettings()
set noexpandtab
set tabstop=2
set shiftwidth=2
set textwidth=79
let g:cue_fmt_on_save = 1
endfunction
autocmd BufNewFile,BufFilePre,BufRead *.cue :call CueSettings()
" Settings for JFDIC Rust environment:
function! RustSettings()
set tabstop=4
set shiftwidth=4
set expandtab
set textwidth=79
let g:rustfmt_autosave = 1
endfunction
autocmd BufNewFile,BufFilePre,BufRead *.rs :call RustSettings()
" Settings for JFDIC Crystal environment:
function! CrystalSettings()
set tabstop=2
set shiftwidth=2
set expandtab
set textwidth=79
set filetype=crystal
endfunction
autocmd BufNewFile,BufFilePre,BufRead *.cr :call CrystalSettings()
" Settings for JFDIC Golang environment:
function! GoSettings()
set tabstop=7
set shiftwidth=7
set noexpandtab
endfunction
autocmd BufNewFile,BufFilePre,BufRead *.go :call GoSettings()
" Settings for JFDIC Python environment:
function! PythonSettings()
set tabstop=4
set shiftwidth=4
set expandtab
set textwidth=79
set spell!
endfunction
autocmd BufNewFile,BufFilePre,BufRead *.py :call PythonSettings()
" JFDIC Mutt environment
function! MuttSettings()
set textwidth=79
set spell spelllang=en_au
hi clear SpellBad " Clear any unwanted default settings
hi SpellBad cterm=underline " Set the spell checking highlight style
hi SpellBad ctermbg=NONE " Set the spell checking highlight background
endfunction
autocmd BufNewFile,BufFilePre,BufRead mutt-* :call MuttSettings()
autocmd BufNewFile,BufFilePre,BufRead neomutt-* :call MuttSettings()
" Settings for JFDIC C environment:
function! CSettings()
set tabstop=2
set shiftwidth=2
set expandtab
set textwidth=79
endfunction
autocmd BufNewFile,BufFilePre,BufRead *.c :call CSettings()
" Settings for JFDIC YAML environment:
function! YAMLSettings()
set tabstop=2
set shiftwidth=2
set expandtab
set textwidth=79
set spell spelllang=en_au
hi clear SpellBad " Clear any unwanted default settings
hi SpellBad cterm=underline " Set the spell checking highlight style
hi SpellBad ctermbg=NONE " Set the spell checking highlight background
endfunction
autocmd BufNewFile,BufFilePre,BufRead *.yaml :call YAMLSettings()
autocmd BufNewFile,BufFilePre,BufRead *.yml :call YAMLSettings()
" Settings for JFDIC Bash environment:
function! BashSettings()
set tabstop=4
set shiftwidth=4
set expandtab
set textwidth=79
set spell!
endfunction
autocmd BufNewFile,BufFilePre,BufRead *.sh :call BashSettings()
'';
}; };
customRC = '' }
" Preferred global default settings: )
set nocompatible ];
set backspace=indent,eol,start
set number relativenumber " Enable relative line numbers by default
set cursorline " Highlight the current line number
set smartindent " Automatically insert extra level of indentation
set tabstop=4 " Default tabstop
set shiftwidth=4 " Default indent spacing
set expandtab " Expand [TABS] to spaces
packadd! dracula-vim
syntax on " Enable syntax highlighting
set t_Co=256 " Use 265 colors in vim
set background=dark " Set the default background scheme
colorscheme dracula " Set the default colour scheme
"let g:one_allow_italics = 1 " I love italic for comments
set spell spelllang=en_au " Defaul spell checking language
set spellfile=~/.vim-spell.en.utf-8.add " Add the spellfile
hi clear SpellBad " Clear any unwanted default settings
hi SpellBad cterm=underline " Set the spell checking highlight style
hi SpellBad ctermbg=NONE " Set the spell checking highlight background
match ErrorMsg '\s\+$' "
nnoremap <silent> <C-p> :Files<CR>
nnoremap <silent> <Leader>f :Rg<CR>
set grepprg=rg\ --vimgrep\ --smart-case\ --follow
let g:airline_powerline_fonts = 1 " Use powerline fonts
let g:airline_theme='dracula' " Set the airline theme
"call togglebg#map("<F10>") " Toggle background colour between dark|light
set laststatus=2 " Set up the status line so it's coloured and always on
" Removes trailing spaces:
function! TrimWhiteSpace()
%s/\s\+$//e
endfunction
" Trigger for numbertoggle to switch modes
nnoremap <silent> <C-n> :set relativenumber!<CR>
" Tab settings
let g:SuperTabDefaultCompletionType = 'context'
let g:SuperTabContextTextOmniPrecedence = ['&omnifunc','&completefunc']
let g:SuperTabRetainCompletionType=2
inoremap <expr><Enter> pumvisible() ? "\<C-Y>" : "\<Enter>"
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
nnoremap <silent> <Leader>RemoveTrailingWhiteSpace :call TrimWhiteSpace()<CR>
autocmd FileWritePre * :call TrimWhiteSpace()
autocmd FileAppendPre * :call TrimWhiteSpace()
autocmd FilterWritePre * :call TrimWhiteSpace()
autocmd BufWritePre * :call TrimWhiteSpace()
"autocmd BufWrite * :Autoformat
" FIXME: Currently always set to dark due to issues with Termonad Solarized theme
" Light during the day, dark during the night
let hour = strftime("%H")
if 7 <= hour && hour < 17
"set background=dark
"hi Normal ctermbg=none " Set a transparent background
"let g:airline_solarized_bg='dark' " Set the airline background
else
"set background=dark
"hi Normal ctermbg=none " Set a transparent background
"let g:airline_solarized_bg='dark' " Set the airline background
endif
" Transparent editing of gpg encrypted files.
" By Wouter Hanegraaff <wouter@blub.net>
augroup encrypted
au!
" First make sure nothing is written to ~/.viminfo while editing an encrypted file.
autocmd BufReadPre,FileReadPre *.gpg set viminfo=
" We don't want a swap file, as it writes unencrypted data to disk
autocmd BufReadPre,FileReadPre *.gpg set noswapfile
" Switch to binary mode to read the encrypted file
autocmd BufReadPre,FileReadPre *.gpg set bin
autocmd BufReadPre,FileReadPre *.gpg let ch_save = &ch|set ch=2
autocmd BufReadPost,FileReadPost *.gpg '[,']!gpg --decrypt 2> /dev/null
" Switch to normal mode for editing
autocmd BufReadPost,FileReadPost *.gpg set nobin
autocmd BufReadPost,FileReadPost *.gpg let &ch = ch_save|unlet ch_save
autocmd BufReadPost,FileReadPost *.gpg execute ":doautocmd BufReadPost " . expand("%:r")
" Convert all text to encrypted text before writing
autocmd BufWritePre,FileWritePre *.gpg '[,']!gpg --default-key=A4122FF3971B6865 --default-recipient-self -ae 2>/dev/null
" Undo the encryption so we are back in the normal text, directly
" after the file has been written.
autocmd BufWritePost,FileWritePost *.gpg u
augroup END
" Manage ISO files
augroup iso
au!
" First make sure nothing is written to ~/.viminfo while editing an encrypted file.
autocmd BufReadPre,FileReadPre *.iso set viminfo=
" We don't want a swap file, as it writes unencrypted data to disk
autocmd BufReadPre,FileReadPre *.iso set noswapfile
" Switch to binary mode to read the encrypted file
autocmd BufReadPre,FileReadPre *.iso set bin
autocmd BufReadPre,FileReadPre *.iso let ch_save = &ch|set ch=2
autocmd BufReadPost,FileReadPost *.iso '[,']!gpg --decrypt 2> /dev/null
" Switch to normal mode for editing
autocmd BufReadPost,FileReadPost *.iso set nobin
autocmd BufReadPost,FileReadPost *.iso let &ch = ch_save|unlet ch_save
autocmd BufReadPost,FileReadPost *.iso execute ":doautocmd BufReadPost " . expand("%:r")
" Convert all text to encrypted text before writing
autocmd BufWritePre,FileWritePre *.iso '[,']!gpg --default-key=A4122FF3971B6865 --default-recipient-self -ae 2>/dev/null
" Undo the encryption so we are back in the normal text, directly
" after the file has been written.
autocmd BufWritePost,FileWritePost *.iso u
augroup END
" Use persistent history.
if !isdirectory("/tmp/.vim-undo-dir")
call mkdir("/tmp/.vim-undo-dir", "", 0700)
endif
set undodir=/tmp/.vim-undo-dir
set undofile
" JFDIC Markdown environment
function! MarkdownSettings()
set textwidth=79
set spell spelllang=en_au
endfunction
autocmd BufNewFile,BufFilePre,BufRead *.mdwn :call MarkdownSettings()
autocmd BufNewFile,BufFilePre,BufRead *.md :call MarkdownSettings()
" JFDIC ReStructured Text environment
function! ReStructuredSettings()
set textwidth=79
set spell spelllang=en_au
hi clear SpellBad " Clear any unwanted default settings
hi SpellBad cterm=underline " Set the spell checking highlight style
hi SpellBad ctermbg=NONE " Set the spell checking highlight background
endfunction
autocmd BufNewFile,BufFilePre,BufRead *.rst :call ReStructuredSettings()
autocmd BufNewFile,BufFilePre,BufRead *.txt :call ReStructuredSettings()
" JFDIC LaTeX environment:
function! LaTeXSettings()
set textwidth=79
set spell spelllang=en_au
endfunction
autocmd BufNewFile,BufFilePre,BufRead *.tex :call LaTeXSettings()
" Settings for JFDIC Haskell environment:
function! HaskellSettings()
set tabstop=2
set shiftwidth=2
set expandtab
set textwidth=79
endfunction
autocmd BufNewFile,BufFilePre,BufRead *.hs :call HaskellSettings()
" Settings for JFDIC Nix environment:
function! NixSettings()
set tabstop=2
set shiftwidth=2
set expandtab
set textwidth=79
set filetype=nix
endfunction
autocmd BufNewFile,BufFilePre,BufRead *.nix :call NixSettings()
" Settings for JFDIC Cue environment:
function! CueSettings()
set noexpandtab
set tabstop=2
set shiftwidth=2
set textwidth=79
let g:cue_fmt_on_save = 1
endfunction
autocmd BufNewFile,BufFilePre,BufRead *.cue :call CueSettings()
" Settings for JFDIC Rust environment:
function! RustSettings()
set tabstop=4
set shiftwidth=4
set expandtab
set textwidth=79
let g:rustfmt_autosave = 1
endfunction
autocmd BufNewFile,BufFilePre,BufRead *.rs :call RustSettings()
" Settings for JFDIC Crystal environment:
function! CrystalSettings()
set tabstop=2
set shiftwidth=2
set expandtab
set textwidth=79
set filetype=crystal
endfunction
autocmd BufNewFile,BufFilePre,BufRead *.cr :call CrystalSettings()
" Settings for JFDIC Golang environment:
function! GoSettings()
set tabstop=7
set shiftwidth=7
set noexpandtab
endfunction
autocmd BufNewFile,BufFilePre,BufRead *.go :call GoSettings()
" Settings for JFDIC Python environment:
function! PythonSettings()
set tabstop=4
set shiftwidth=4
set expandtab
set textwidth=79
set spell!
endfunction
autocmd BufNewFile,BufFilePre,BufRead *.py :call PythonSettings()
" JFDIC Mutt environment
function! MuttSettings()
set textwidth=79
set spell spelllang=en_au
hi clear SpellBad " Clear any unwanted default settings
hi SpellBad cterm=underline " Set the spell checking highlight style
hi SpellBad ctermbg=NONE " Set the spell checking highlight background
endfunction
autocmd BufNewFile,BufFilePre,BufRead mutt-* :call MuttSettings()
autocmd BufNewFile,BufFilePre,BufRead neomutt-* :call MuttSettings()
" Settings for JFDIC C environment:
function! CSettings()
set tabstop=2
set shiftwidth=2
set expandtab
set textwidth=79
endfunction
autocmd BufNewFile,BufFilePre,BufRead *.c :call CSettings()
" Settings for JFDIC YAML environment:
function! YAMLSettings()
set tabstop=2
set shiftwidth=2
set expandtab
set textwidth=79
set spell spelllang=en_au
hi clear SpellBad " Clear any unwanted default settings
hi SpellBad cterm=underline " Set the spell checking highlight style
hi SpellBad ctermbg=NONE " Set the spell checking highlight background
endfunction
autocmd BufNewFile,BufFilePre,BufRead *.yaml :call YAMLSettings()
autocmd BufNewFile,BufFilePre,BufRead *.yml :call YAMLSettings()
" Settings for JFDIC Bash environment:
function! BashSettings()
set tabstop=4
set shiftwidth=4
set expandtab
set textwidth=79
set spell!
endfunction
autocmd BufNewFile,BufFilePre,BufRead *.sh :call BashSettings()
'';
};
}
)];
} }

View file

@ -1,9 +1,10 @@
# NixOps configuration nix-direnv # NixOps configuration nix-direnv
{ config, pkgs, lib, ... }:
{ {
config,
pkgs,
lib,
...
}: {
nix = { nix = {
extraOptions = '' extraOptions = ''
keep-outputs = true keep-outputs = true
@ -14,16 +15,15 @@
# Set the environment # Set the environment
environment = { environment = {
systemPackages = with pkgs; [ systemPackages = with pkgs; [
direnv # A shell extension that manages your environment direnv # A shell extension that manages your environment
nix-direnv # A fast, persistent use_nix implementation for direnv nix-direnv # A fast, persistent use_nix implementation for direnv
]; ];
pathsToLink = [ pathsToLink = [
"/share/nix-direnv" "/share/nix-direnv"
]; ];
}; };
nixpkgs.overlays = [ nixpkgs.overlays = [
(self: super: { nix-direnv = super.nix-direnv.override { enableFlakes = true; }; } ) (self: super: {nix-direnv = super.nix-direnv.override {enableFlakes = true;};})
]; ];
} }

View file

@ -1,19 +1,18 @@
# Configuration common to all JFDIC servers # Configuration common to all JFDIC servers
{ config, pkgs, lib, ... }:
{ {
config,
imports = pkgs,
[ lib,
../profiles/openssh.nix ...
../secrets/user-fiscalvelvetpoet.nix }: {
../secrets/user-root.nix imports = [
]; ../profiles/openssh.nix
../secrets/user-fiscalvelvetpoet.nix
../secrets/user-root.nix
];
programs.mosh = { programs.mosh = {
enable = true; enable = true;
withUtempter = true; withUtempter = true;
}; };
} }

View file

@ -1,7 +1,5 @@
{ pkgs, ... }: {pkgs, ...}: {
{
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
starship # A minimal, blazing fast, and extremely customizable prompt for any shell starship # A minimal, blazing fast, and extremely customizable prompt for any shell
]; ];
} }

View file

@ -1,12 +1,13 @@
# Configuration common to all JFDIC servers # Configuration common to all JFDIC servers
{ config, pkgs, lib, ... }:
{ {
config,
pkgs,
lib,
...
}: {
# Program defaults for all hosts # Program defaults for all hosts
programs.zsh = { programs.zsh = {
enable = true; # Also enables & installs nix-zsh-completions enable = true; # Also enables & installs nix-zsh-completions
autosuggestions.enable = true; autosuggestions.enable = true;
interactiveShellInit = '' interactiveShellInit = ''
export TERM="xterm-256color" export TERM="xterm-256color"
@ -37,6 +38,5 @@
fzf fzf
]; ];
users.defaultUserShell = pkgs.zsh; # Set the default shell for all users users.defaultUserShell = pkgs.zsh; # Set the default shell for all users
} }