stockholm/lass/2configs/default.nix

220 lines
5.5 KiB
Nix
Raw Normal View History

2017-02-26 00:02:06 +01:00
{ config, pkgs, ... }:
2016-10-20 20:54:38 +02:00
with import <stockholm/lib>;
2015-07-16 15:51:01 +02:00
{
imports = [
2016-07-19 00:02:34 +02:00
../2configs/audit.nix
2016-06-25 18:56:39 +02:00
../2configs/binary-cache/client.nix
2016-06-25 19:41:49 +02:00
../2configs/gc.nix
2016-07-19 00:02:34 +02:00
../2configs/mc.nix
../2configs/vim.nix
2017-01-30 22:58:54 +01:00
../2configs/monitoring/client.nix
2017-03-07 22:57:21 +01:00
./htop.nix
2016-04-11 16:52:15 +02:00
./backups.nix
2017-02-26 00:02:06 +01:00
./security-workarounds.nix
2015-07-16 15:51:01 +02:00
{
users.extraUsers =
mapAttrs (_: h: { hashedPassword = h; })
2016-03-23 13:44:21 +01:00
(import <secrets/hashedPasswords.nix>);
2015-07-16 15:51:01 +02:00
}
2015-07-21 18:57:58 +02:00
{
users.extraUsers = {
root = {
2015-10-31 15:09:43 +01:00
openssh.authorizedKeys.keys = [
config.krebs.users.lass.pubkey
2016-05-21 13:51:06 +02:00
config.krebs.users.lass-shodan.pubkey
2016-12-29 18:13:46 +01:00
config.krebs.users.lass-icarus.pubkey
2015-07-21 18:57:58 +02:00
];
};
mainUser = {
name = "lass";
uid = 1337;
home = "/home/lass";
group = "users";
createHome = true;
useDefaultShell = true;
extraGroups = [
2016-12-21 00:17:20 +01:00
"audio"
2016-06-01 00:10:53 +02:00
"fuse"
2017-07-11 17:34:36 +02:00
"wheel"
2015-07-21 18:57:58 +02:00
];
2015-10-31 15:09:43 +01:00
openssh.authorizedKeys.keys = [
config.krebs.users.lass.pubkey
2016-05-21 13:51:06 +02:00
config.krebs.users.lass-shodan.pubkey
2016-12-29 18:13:46 +01:00
config.krebs.users.lass-icarus.pubkey
2015-07-21 18:57:58 +02:00
];
};
};
}
2016-08-05 00:00:43 +02:00
{
environment.variables = {
NIX_PATH = mkForce "secrets=/var/src/stockholm/null:/var/src";
};
}
2016-10-27 12:50:03 +02:00
(let ca-bundle = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"; in {
environment.variables = {
CURL_CA_BUNDLE = ca-bundle;
GIT_SSL_CAINFO = ca-bundle;
SSL_CERT_FILE = ca-bundle;
};
})
2017-01-10 17:27:07 +01:00
{
#for sshuttle
environment.systemPackages = [
pkgs.pythonPackages.python
];
}
2015-07-16 15:51:01 +02:00
];
2015-10-19 14:00:15 +02:00
networking.hostName = config.krebs.build.host.name;
nix.maxJobs = config.krebs.build.host.cores;
2015-07-27 17:03:20 +02:00
krebs = {
enable = true;
2017-04-12 21:05:42 +02:00
search-domain = "r";
build.user = config.krebs.users.lass;
2015-07-27 17:03:20 +02:00
};
2016-10-11 17:41:03 +02:00
nix.useSandbox = true;
2015-07-16 15:51:01 +02:00
users.mutableUsers = false;
2016-03-15 14:30:23 +01:00
services.timesyncd.enable = true;
2015-08-22 16:49:37 +02:00
#why is this on in the first place?
2015-09-23 15:00:13 +02:00
services.nscd.enable = false;
2015-08-22 16:49:37 +02:00
2015-07-16 15:51:01 +02:00
systemd.tmpfiles.rules = [
"d /tmp 1777 root root - -"
];
# multiple-definition-problem when defining environment.variables.EDITOR
environment.extraInit = ''
EDITOR=vim
'';
2016-04-09 14:16:21 +02:00
nixpkgs.config.allowUnfree = true;
2015-07-16 15:51:01 +02:00
environment.systemPackages = with pkgs; [
2015-10-01 22:57:15 +02:00
#stockholm
2015-07-16 15:51:01 +02:00
git
gnumake
2015-10-01 22:57:15 +02:00
jq
parallel
proot
2016-10-11 17:42:08 +02:00
populate
2015-10-01 22:57:15 +02:00
#style
2015-07-16 15:51:01 +02:00
most
rxvt_unicode.terminfo
2015-11-13 11:10:34 +01:00
#monitoring tools
htop
iotop
2015-07-16 15:51:01 +02:00
#network
iptables
2016-04-20 13:58:10 +02:00
iftop
2015-10-21 01:34:27 +02:00
#stuff for dl
aria2
2016-02-27 15:51:25 +01:00
#neat utils
2017-04-11 21:41:20 +02:00
kpaste
2016-02-27 15:51:25 +01:00
krebspaste
2017-03-04 20:04:39 +01:00
mosh
2016-06-11 00:28:09 +02:00
pciutils
2016-07-10 18:06:35 +02:00
pop
2016-05-04 17:20:15 +02:00
psmisc
2016-06-25 13:18:46 +02:00
q
2016-06-13 23:01:56 +02:00
rs
2016-06-11 00:28:09 +02:00
tmux
2016-05-20 00:12:43 +02:00
untilport
2016-06-11 00:28:09 +02:00
usbutils
2017-04-27 18:58:23 +02:00
logify
2017-05-02 20:13:07 +02:00
goify
2016-04-09 14:16:21 +02:00
#unpack stuff
p7zip
unzip
unrar
2017-04-16 23:34:25 +02:00
(pkgs.writeDashBin "sshn" ''
${pkgs.openssh}/bin/ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "$@"
'')
2015-07-16 15:51:01 +02:00
];
programs.bash = {
enableCompletion = true;
interactiveShellInit = ''
HISTCONTROL='erasedups:ignorespace'
HISTSIZE=65536
HISTFILESIZE=$HISTSIZE
shopt -s checkhash
shopt -s histappend histreedit histverify
shopt -s no_empty_cmd_completion
complete -d cd
2017-02-16 00:06:38 +01:00
LS_COLORS=$LS_COLORS:'di=1;31:' ; export LS_COLORS
2015-07-16 15:51:01 +02:00
'';
promptInit = ''
if test $UID = 0; then
PS1='\[\033[1;31m\]\w\[\033[0m\] '
2017-01-17 15:57:38 +01:00
PROMPT_COMMAND='echo -ne "\033]0;$$ $USER@$PWD\007"'
2015-07-16 15:51:01 +02:00
elif test $UID = 1337; then
PS1='\[\033[1;32m\]\w\[\033[0m\] '
2017-01-17 15:57:38 +01:00
PROMPT_COMMAND='echo -ne "\033]0;$$ $PWD\007"'
2015-07-16 15:51:01 +02:00
else
PS1='\[\033[1;33m\]\u@\w\[\033[0m\] '
2017-01-17 15:57:38 +01:00
PROMPT_COMMAND='echo -ne "\033]0;$$ $USER@$PWD\007"'
2015-07-16 15:51:01 +02:00
fi
if test -n "$SSH_CLIENT"; then
PS1='\[\033[35m\]\h'" $PS1"
2017-01-17 15:57:38 +01:00
PROMPT_COMMAND='echo -ne "\033]0;$$ $HOSTNAME $USER@$PWD\007"'
2015-07-16 15:51:01 +02:00
fi
'';
};
services.openssh = {
enable = true;
hostKeys = [
# XXX bits here make no science
{ bits = 8192; type = "ed25519"; path = "/etc/ssh/ssh_host_ed25519_key"; }
];
};
services.journald.extraConfig = ''
SystemMaxUse=1G
RuntimeMaxUse=128M
'';
2015-10-01 22:13:40 +02:00
krebs.iptables = {
2015-07-16 15:51:01 +02:00
enable = true;
tables = {
nat.PREROUTING.rules = [
{ predicate = "! -i retiolum -p tcp -m tcp --dport 22"; target = "REDIRECT --to-ports 0"; precedence = 100; }
{ predicate = "-p tcp -m tcp --dport 45621"; target = "REDIRECT --to-ports 22"; precedence = 99; }
];
nat.OUTPUT.rules = [
{ predicate = "-o lo -p tcp -m tcp --dport 45621"; target = "REDIRECT --to-ports 22"; precedence = 100; }
];
2015-07-16 15:51:01 +02:00
filter.INPUT.policy = "DROP";
filter.FORWARD.policy = "DROP";
filter.INPUT.rules = [
2017-08-24 17:34:46 +02:00
{ predicate = "-i retiolum -p udp --dport 60000:61000"; target = "ACCEPT";}
{ predicate = "-m conntrack --ctstate RELATED,ESTABLISHED"; target = "ACCEPT"; precedence = 10001; }
{ predicate = "-p icmp"; target = "ACCEPT"; precedence = 10000; }
2017-02-09 16:57:54 +01:00
{ predicate = "-p ipv6-icmp"; target = "ACCEPT"; v4 = false; precedence = 10000; }
{ predicate = "-i lo"; target = "ACCEPT"; precedence = 9999; }
{ predicate = "-p tcp --dport 22"; target = "ACCEPT"; precedence = 9998; }
{ predicate = "-p tcp -i retiolum"; target = "REJECT --reject-with tcp-reset"; precedence = -10000; }
{ predicate = "-p udp -i retiolum"; target = "REJECT --reject-with icmp-port-unreachable"; v6 = false; precedence = -10000; }
{ predicate = "-i retiolum"; target = "REJECT --reject-with icmp-proto-unreachable"; v6 = false; precedence = -10000; }
2015-07-16 15:51:01 +02:00
];
};
};
2015-09-13 16:37:11 +02:00
networking.dhcpcd.extraConfig = ''
noipv4ll
'';
2015-07-16 15:51:01 +02:00
}