Move defaults/base-minimal to nixos-modules/system
This commit is contained in:
parent
0abeadc533
commit
94510a8cd9
9 changed files with 0 additions and 2 deletions
55
nixos-modules/system/applications.nix
Normal file
55
nixos-modules/system/applications.nix
Normal file
|
@ -0,0 +1,55 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
{
|
||||
environment.systemPackages =
|
||||
with pkgs;
|
||||
[
|
||||
vim
|
||||
tmux
|
||||
killall
|
||||
bc
|
||||
rename
|
||||
wipe
|
||||
gnupg
|
||||
ripgrep
|
||||
]
|
||||
++ [
|
||||
nix-index
|
||||
nix-diff
|
||||
]
|
||||
++ [
|
||||
autojump
|
||||
powerline-go
|
||||
]
|
||||
++ [
|
||||
# File Utilities
|
||||
ack
|
||||
unzip
|
||||
iotop
|
||||
tree
|
||||
vim
|
||||
vimPlugins.pathogen
|
||||
vimPlugins.airline
|
||||
git
|
||||
git-lfs
|
||||
]
|
||||
++ [
|
||||
# Filesystem & Disk Utilities
|
||||
parted
|
||||
]
|
||||
++ [
|
||||
# Networking Utilities
|
||||
nmap
|
||||
bind
|
||||
curl
|
||||
wget
|
||||
rsync
|
||||
iftop
|
||||
mailutils
|
||||
];
|
||||
}
|
126
nixos-modules/system/default.nix
Normal file
126
nixos-modules/system/default.nix
Normal file
|
@ -0,0 +1,126 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
inputs,
|
||||
...
|
||||
}:
|
||||
{
|
||||
imports = [
|
||||
./unfree.nix
|
||||
./applications.nix
|
||||
./overlays.nix
|
||||
./security.nix
|
||||
];
|
||||
|
||||
boot.loader.timeout = 2;
|
||||
boot.tmp.useTmpfs = true;
|
||||
boot.loader.grub.splashImage = null;
|
||||
|
||||
console.keyMap = "de_CH-latin1";
|
||||
i18n.defaultLocale = "en_US.UTF-8";
|
||||
|
||||
boot.kernel.sysctl = {
|
||||
"kernel.panic" = 20; # Reboot kernel on panic after this much seconds
|
||||
};
|
||||
|
||||
boot.initrd.network.udhcpc.extraArgs = [
|
||||
"-A"
|
||||
"900" # Wait for a DHCP lease on boot for 15mins
|
||||
];
|
||||
|
||||
systemd.watchdog = {
|
||||
runtimeTime = "5m";
|
||||
rebootTime = "10m";
|
||||
};
|
||||
|
||||
users.mutableUsers = false;
|
||||
users.users = {
|
||||
root.openssh.authorizedKeys.keys =
|
||||
with lib;
|
||||
concatLists (
|
||||
mapAttrsToList (
|
||||
name: user:
|
||||
if elem "wheel" user.extraGroups && name != "root" then user.openssh.authorizedKeys.keys else [ ]
|
||||
) config.users.users
|
||||
);
|
||||
};
|
||||
|
||||
# Disable dependency on xorg
|
||||
# TODO: Set environment.noXlibs on hosts that don't need any x libraries.
|
||||
security.pam.services.su.forwardXAuth = lib.mkForce false;
|
||||
|
||||
# Package management
|
||||
nix = {
|
||||
settings =
|
||||
let
|
||||
substituters = [
|
||||
"https://${inputs.self.nixosConfigurations.lindberg-build.config.qois.nixpkgs-cache.hostname}?priority=39"
|
||||
"https://cache.nixos.org?priority=40"
|
||||
"https://attic.qo.is/qois-infrastructure"
|
||||
];
|
||||
in
|
||||
{
|
||||
trusted-users = [
|
||||
"root"
|
||||
"@wheel"
|
||||
];
|
||||
trusted-public-keys = [
|
||||
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
|
||||
"qois-infrastructure:lh35ymN7Aoxm5Hz0S6JusxE+cYzMU+x9OMKjDVIpfuE="
|
||||
];
|
||||
trusted-substituters = substituters; # For hosts that limit the subst list
|
||||
inherit substituters;
|
||||
};
|
||||
gc = {
|
||||
automatic = true;
|
||||
dates = "weekly";
|
||||
options = "--delete-older-than 90d";
|
||||
};
|
||||
package = pkgs.nixVersions.stable;
|
||||
extraOptions = ''
|
||||
experimental-features = nix-command flakes
|
||||
'';
|
||||
};
|
||||
|
||||
# Network services
|
||||
networking.firewall = {
|
||||
allowPing = true;
|
||||
allowedTCPPorts = [ 22 ];
|
||||
};
|
||||
|
||||
services.openssh = {
|
||||
enable = true;
|
||||
settings.PasswordAuthentication = false;
|
||||
};
|
||||
|
||||
security.acme = {
|
||||
acceptTerms = true;
|
||||
defaults.email = "sysadmin@qo.is";
|
||||
};
|
||||
|
||||
# Default Settings
|
||||
environment.etc = {
|
||||
gitconfig.source = ./etc/gitconfig;
|
||||
vimrc.source = ./etc/vimrc;
|
||||
};
|
||||
|
||||
programs.autojump.enable = true;
|
||||
programs.vim = {
|
||||
enable = true;
|
||||
defaultEditor = true;
|
||||
};
|
||||
|
||||
sops.defaultSopsFile =
|
||||
let
|
||||
defaultSopsPath = "${inputs.private}/nixos-configurations/${config.networking.hostName}/secrets.sops.yaml";
|
||||
in
|
||||
lib.mkIf (builtins.pathExists defaultSopsPath) defaultSopsPath;
|
||||
|
||||
services.fstrim.enable = true;
|
||||
|
||||
qois.outgoing-server-mail.enable = true;
|
||||
qois.backup-client.enable = true;
|
||||
|
||||
systemd.extraConfig = "DefaultLimitNOFILE=4096";
|
||||
}
|
31
nixos-modules/system/etc/gitconfig
Normal file
31
nixos-modules/system/etc/gitconfig
Normal file
|
@ -0,0 +1,31 @@
|
|||
[core]
|
||||
packedGitWindowSize = 16m
|
||||
packedGitLimit = 64m
|
||||
[pack]
|
||||
windowMemory = 64m
|
||||
packSizeLimit = 64m
|
||||
thread = 1
|
||||
deltaCacheSize = 1m
|
||||
[color]
|
||||
branch = auto
|
||||
diff = auto
|
||||
status = auto
|
||||
[push]
|
||||
default = simple
|
||||
[pull]
|
||||
rebase = true
|
||||
[branch]
|
||||
autosetuprebase = always
|
||||
[commit]
|
||||
# gpgsign = true
|
||||
[tag]
|
||||
# gpgsign = true
|
||||
|
||||
[alias]
|
||||
s = status --short --branch
|
||||
a = add --patch
|
||||
c = commit --message
|
||||
l = log --color --graph --pretty=format:'%Cred%h%Creset - %C(bold)%s%Creset%C(yellow)%d%Creset %C(green)%an%Creset %C(cyan)%cr%Creset' --abbrev-commit
|
||||
d = diff
|
||||
[diff]
|
||||
# noprefix = true
|
54
nixos-modules/system/etc/vimrc
Normal file
54
nixos-modules/system/etc/vimrc
Normal file
|
@ -0,0 +1,54 @@
|
|||
|
||||
" Use Vim settings, rather than Vi settings (much better!).
|
||||
" This must be first, because it changes other options as a side effect.
|
||||
" Avoid side effects when it was already reset.
|
||||
if &compatible
|
||||
set nocompatible
|
||||
endif
|
||||
|
||||
" Convenient command to see the difference between the current buffer and the
|
||||
" file it was loaded from, thus the changes you made.
|
||||
" Only define it when not defined already.
|
||||
" Revert with: ":delcommand DiffOrig".
|
||||
if !exists(":DiffOrig")
|
||||
command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis
|
||||
\ | wincmd p | diffthis
|
||||
endif
|
||||
|
||||
" Don't wake up system with blinking cursor:
|
||||
" http://www.linuxpowertop.org/known.php
|
||||
let &guicursor = &guicursor . ",a:blinkon0"
|
||||
|
||||
|
||||
|
||||
|
||||
""""""""""""""""""""""""""
|
||||
" Design Settings
|
||||
""""""""""""""""""""""""""
|
||||
set background=dark
|
||||
colorscheme elflord
|
||||
|
||||
""""""""""""""""""""""""""
|
||||
" Other Settings
|
||||
""""""""""""""""""""""""""
|
||||
set ignorecase " Ignore search case
|
||||
set autoindent " Newline with automatic text indent
|
||||
set ruler " Show current position
|
||||
set pastetoggle=<F2>
|
||||
set ignorecase
|
||||
set hidden
|
||||
|
||||
set splitbelow
|
||||
set splitright
|
||||
|
||||
set tabstop=2
|
||||
set shiftwidth=2
|
||||
set softtabstop=2
|
||||
set expandtab
|
||||
|
||||
set listchars="eol:¬,tab:>·,trail:~,extends:>,precedes:<,space:␣"
|
||||
set grepprg=ack\ -k
|
||||
|
||||
filetype plugin indent on
|
||||
syntax on
|
||||
|
12
nixos-modules/system/overlays.nix
Normal file
12
nixos-modules/system/overlays.nix
Normal file
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
options,
|
||||
...
|
||||
}:
|
||||
|
||||
{
|
||||
nixpkgs.overlays = [ (import ../../overlays) ];
|
||||
nix.nixPath = options.nix.nixPath.default;
|
||||
}
|
37
nixos-modules/system/security.nix
Normal file
37
nixos-modules/system/security.nix
Normal file
|
@ -0,0 +1,37 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
{
|
||||
|
||||
# ###########################################################################
|
||||
# Options taken from hardened kernel profile, see
|
||||
# https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/profiles/hardened.nix
|
||||
# ###########################################################################
|
||||
# Enable strict reverse path filtering (that is, do not attempt to route
|
||||
# packets that "obviously" do not belong to the iface's network; dropped
|
||||
# packets are logged as martians).
|
||||
boot.kernel.sysctl."net.ipv4.conf.all.log_martians" = mkDefault true;
|
||||
boot.kernel.sysctl."net.ipv4.conf.all.rp_filter" = mkDefault "1";
|
||||
boot.kernel.sysctl."net.ipv4.conf.default.log_martians" = mkDefault true;
|
||||
boot.kernel.sysctl."net.ipv4.conf.default.rp_filter" = mkDefault "1";
|
||||
|
||||
# Ignore broadcast ICMP (mitigate SMURF)
|
||||
boot.kernel.sysctl."net.ipv4.icmp_echo_ignore_broadcasts" = mkDefault true;
|
||||
|
||||
# Ignore incoming ICMP redirects (note: default is needed to ensure that the
|
||||
# setting is applied to interfaces added after the sysctls are set)
|
||||
boot.kernel.sysctl."net.ipv4.conf.all.accept_redirects" = mkDefault false;
|
||||
boot.kernel.sysctl."net.ipv4.conf.all.secure_redirects" = mkDefault false;
|
||||
boot.kernel.sysctl."net.ipv4.conf.default.accept_redirects" = mkDefault false;
|
||||
boot.kernel.sysctl."net.ipv4.conf.default.secure_redirects" = mkDefault false;
|
||||
boot.kernel.sysctl."net.ipv6.conf.all.accept_redirects" = mkDefault false;
|
||||
boot.kernel.sysctl."net.ipv6.conf.default.accept_redirects" = mkDefault false;
|
||||
|
||||
# Ignore outgoing ICMP redirects (this is ipv4 only)
|
||||
boot.kernel.sysctl."net.ipv4.conf.all.send_redirects" = mkDefault false;
|
||||
boot.kernel.sysctl."net.ipv4.conf.default.send_redirects" = mkDefault false;
|
||||
}
|
22
nixos-modules/system/unfree.nix
Normal file
22
nixos-modules/system/unfree.nix
Normal file
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
{
|
||||
nixpkgs.config.allowUnfreePredicate =
|
||||
pkg:
|
||||
builtins.elem (lib.getName pkg) [
|
||||
"corefonts"
|
||||
"camingo-code"
|
||||
"helvetica-neue-lt-std"
|
||||
#"kochi-substitute-naga10"
|
||||
"ttf-envy-code-r"
|
||||
"vista-fonts"
|
||||
"vista-fonts-chs"
|
||||
"xkcd-font-unstable"
|
||||
"ricty"
|
||||
];
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue