2024-05-23 13:39:48 +03:00
|
|
|
#Basic system config
|
|
|
|
{ config, pkgs, ... }:
|
|
|
|
{
|
2024-06-02 16:18:19 +03:00
|
|
|
#################### Packages ####################
|
|
|
|
environment.systemPackages = with pkgs; [
|
2024-06-04 14:29:06 +03:00
|
|
|
rxvt-unicode
|
2024-06-02 16:18:19 +03:00
|
|
|
tmux
|
|
|
|
git
|
|
|
|
nano
|
|
|
|
p7zip
|
|
|
|
tree
|
|
|
|
];
|
|
|
|
|
|
|
|
#################### ZSH configuration ####################
|
|
|
|
users.defaultUserShell = pkgs.zsh;
|
|
|
|
environment.shells = with pkgs; [ zsh ];
|
|
|
|
programs.zsh = {
|
2024-06-02 05:53:39 +03:00
|
|
|
enable = true;
|
2024-06-02 16:18:19 +03:00
|
|
|
autosuggestions.enable = true;
|
|
|
|
syntaxHighlighting.enable = true;
|
|
|
|
ohMyZsh = {
|
|
|
|
enable = true;
|
|
|
|
plugins = [
|
|
|
|
"history-substring-search"
|
|
|
|
"tmux"
|
|
|
|
];
|
|
|
|
theme = "af-magic";
|
|
|
|
};
|
|
|
|
interactiveShellInit = ''
|
|
|
|
ZSH_TMUX_AUTOSTART=false
|
|
|
|
ZSH_TMUX_AUTOQUIT=false
|
|
|
|
ZSH_TMUX_CONFIG=/etc/tmux.conf
|
2024-06-02 05:53:39 +03:00
|
|
|
'';
|
2024-06-02 16:18:19 +03:00
|
|
|
promptInit = ''
|
|
|
|
if [ -n "$IN_NIX_SHELL" ]; then
|
|
|
|
setopt PROMPT_SUBST
|
|
|
|
RPROMPT+='[nix]'
|
|
|
|
fi
|
2024-06-02 05:53:39 +03:00
|
|
|
'';
|
|
|
|
};
|
2024-05-23 13:39:48 +03:00
|
|
|
|
2024-06-02 16:18:19 +03:00
|
|
|
#################### tmux configuration ####################
|
|
|
|
programs.tmux.enable = true;
|
|
|
|
programs.tmux.extraConfig = ''
|
|
|
|
unbind C-b
|
|
|
|
set -g prefix M-w
|
|
|
|
bind M-w send-prefix
|
|
|
|
|
|
|
|
bind s split-window -v
|
|
|
|
bind v split-window -h
|
|
|
|
|
|
|
|
# Smart pane switching with awareness of Vim splits.
|
|
|
|
bind -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-h) || tmux select-pane -L"
|
|
|
|
bind -n C-j run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-j) || tmux select-pane -D"
|
|
|
|
bind -n C-k run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-k) || tmux select-pane -U"
|
|
|
|
bind -n C-l run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-l) || tmux select-pane -R"
|
|
|
|
|
|
|
|
bind -n C-Left select-pane -L
|
|
|
|
bind -n C-Right select-pane -R
|
|
|
|
bind -n C-Up select-pane -U
|
|
|
|
bind -n C-Down select-pane -D
|
|
|
|
|
|
|
|
# resize panes more easily
|
|
|
|
bind -r h resize-pane -L 10
|
|
|
|
bind -r j resize-pane -D 10
|
|
|
|
bind -r k resize-pane -U 10
|
|
|
|
bind -r l resize-pane -R 10
|
|
|
|
|
|
|
|
bind M-c attach -c "#{pane_current_path}"
|
|
|
|
|
|
|
|
set -s escape-time 0
|
2024-06-02 05:53:39 +03:00
|
|
|
'';
|
2024-05-23 13:39:48 +03:00
|
|
|
|
2024-06-02 16:18:19 +03:00
|
|
|
#################### SSH configuration ####################
|
2024-07-05 16:12:27 +03:00
|
|
|
services.openssh = {
|
|
|
|
enable = true;
|
|
|
|
settings.PasswordAuthentication = false;
|
|
|
|
};
|
2024-06-02 16:18:19 +03:00
|
|
|
users.users.root.openssh.authorizedKeys.keys = [
|
|
|
|
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBbGREoK1uVny1s8FK3KZ74Wmaf0VtifhqPyK69C/Gez vili@helium"
|
|
|
|
];
|
2024-05-23 13:39:48 +03:00
|
|
|
|
2024-07-05 16:12:27 +03:00
|
|
|
#################### Basic fail2ban configuration ####################
|
|
|
|
services.fail2ban = {
|
|
|
|
enable = true;
|
|
|
|
bantime = "1h";
|
|
|
|
bantime-increment = {
|
|
|
|
enable = true;
|
|
|
|
factor = "2";
|
|
|
|
formula = "ban.Time * (1 << (min(ban.Count, 6) * banFactor))";
|
|
|
|
maxtime = "90d";
|
|
|
|
};
|
|
|
|
jails = {
|
|
|
|
DEFAULT.settings = {
|
|
|
|
findtime = 3600;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-06-02 16:18:19 +03:00
|
|
|
#################### BASE ####################
|
|
|
|
nixpkgs.config.allowUnfree = true;
|
|
|
|
networking.networkmanager.enable = true; # Easiest to use and most distros use this by default.
|
2024-05-23 13:39:48 +03:00
|
|
|
|
2024-06-02 16:18:19 +03:00
|
|
|
users.mutableUsers = false; # Force all user management to happen throught nix-files
|
2024-05-23 13:39:48 +03:00
|
|
|
|
2024-06-02 16:18:19 +03:00
|
|
|
# Select internationalisation properties.
|
|
|
|
i18n.defaultLocale = "en_US.UTF-8";
|
|
|
|
services.xserver.xkb = {
|
|
|
|
layout = "us,";
|
|
|
|
variant = "de_se_fi,";
|
|
|
|
};
|
|
|
|
console = pkgs.lib.mkForce {
|
|
|
|
font = "Lat2-Terminus16";
|
|
|
|
useXkbConfig = true; # use xkbOptions in tty.
|
2024-06-02 05:53:39 +03:00
|
|
|
};
|
2024-06-02 16:18:19 +03:00
|
|
|
time.timeZone = "Europe/Helsinki";
|
|
|
|
|
|
|
|
#################### Housekeeping ####################
|
|
|
|
system.autoUpgrade = {
|
|
|
|
enable = true;
|
|
|
|
dates = "04:00";
|
2024-06-02 05:53:39 +03:00
|
|
|
randomizedDelaySec = "30min";
|
|
|
|
};
|
2024-05-23 13:39:48 +03:00
|
|
|
|
2024-06-02 16:18:19 +03:00
|
|
|
nix = {
|
2024-06-05 17:14:32 +03:00
|
|
|
package = pkgs.nixVersions.latest;
|
2024-06-02 16:18:19 +03:00
|
|
|
settings = {
|
|
|
|
auto-optimise-store = true;
|
|
|
|
tarball-ttl = 0;
|
|
|
|
};
|
|
|
|
gc = {
|
|
|
|
automatic = true;
|
|
|
|
options = "--delete-older-than 7d";
|
|
|
|
dates = "05:00";
|
|
|
|
randomizedDelaySec = "30min";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
# Copy the NixOS configuration file and link it from the resulting system
|
|
|
|
# (/run/current-system/configuration.nix). This is useful in case you
|
|
|
|
# accidentally delete configuration.nix.
|
|
|
|
system.copySystemConfiguration = true;
|
|
|
|
}
|