2015-07-11 14:55:22 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
2016-02-14 15:43:44 +00:00
|
|
|
with config.krebs.lib;
|
2015-07-11 14:55:22 +00:00
|
|
|
|
|
|
|
{
|
2015-07-24 19:27:19 +00:00
|
|
|
krebs.enable = true;
|
|
|
|
|
2015-11-06 21:36:01 +00:00
|
|
|
krebs.build = {
|
|
|
|
user = config.krebs.users.tv;
|
2016-02-01 02:00:48 +00:00
|
|
|
source = mapAttrs (_: mkDefault) ({
|
2016-02-04 02:07:47 +00:00
|
|
|
nixos-config = "symlink:stockholm/tv/1systems/${config.krebs.build.host.name}.nix";
|
2016-02-01 02:00:48 +00:00
|
|
|
secrets = "/home/tv/secrets/${config.krebs.build.host.name}";
|
|
|
|
secrets-common = "/home/tv/secrets/common";
|
2016-02-04 02:07:47 +00:00
|
|
|
stockholm = "/home/tv/stockholm";
|
2016-02-15 15:27:11 +00:00
|
|
|
nixpkgs = {
|
2016-02-01 02:00:48 +00:00
|
|
|
url = https://github.com/NixOS/nixpkgs;
|
2016-06-07 21:11:03 +00:00
|
|
|
rev = "87fe38fd0e19ca83fc3ea338f8e0e7b12971d204";
|
2015-11-06 21:36:01 +00:00
|
|
|
};
|
2016-02-01 02:00:48 +00:00
|
|
|
} // optionalAttrs config.krebs.build.host.secure {
|
|
|
|
secrets-master = "/home/tv/secrets/master";
|
|
|
|
});
|
2015-11-06 21:36:01 +00:00
|
|
|
};
|
|
|
|
|
2015-07-24 23:38:26 +00:00
|
|
|
networking.hostName = config.krebs.build.host.name;
|
|
|
|
|
2015-07-11 14:55:22 +00:00
|
|
|
imports = [
|
2015-11-08 10:53:29 +00:00
|
|
|
<secrets>
|
2015-12-28 18:43:31 +00:00
|
|
|
./backup.nix
|
2016-03-05 11:57:46 +00:00
|
|
|
./nginx
|
2015-11-01 12:28:16 +00:00
|
|
|
./vim.nix
|
2015-10-21 23:25:02 +00:00
|
|
|
{
|
|
|
|
# stockholm dependencies
|
|
|
|
environment.systemPackages = with pkgs; [
|
|
|
|
git
|
|
|
|
];
|
|
|
|
}
|
2015-07-11 14:55:22 +00:00
|
|
|
{
|
2015-11-08 10:53:29 +00:00
|
|
|
users = {
|
|
|
|
defaultUserShell = "/run/current-system/sw/bin/bash";
|
|
|
|
mutableUsers = false;
|
|
|
|
users = {
|
|
|
|
tv = {
|
2016-02-21 05:56:57 +00:00
|
|
|
inherit (config.krebs.users.tv) home uid;
|
2015-11-08 10:53:29 +00:00
|
|
|
isNormalUser = true;
|
2016-02-13 18:57:45 +00:00
|
|
|
extraGroups = [ "tv" ];
|
2015-11-08 10:53:29 +00:00
|
|
|
};
|
2015-07-11 14:55:22 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
{
|
|
|
|
security.sudo.extraConfig = ''
|
2016-02-25 12:45:23 +00:00
|
|
|
Defaults env_keep+="SSH_CLIENT"
|
2015-07-24 23:06:13 +00:00
|
|
|
Defaults mailto="${config.krebs.users.tv.mail}"
|
2016-02-17 21:28:02 +00:00
|
|
|
Defaults !lecture
|
2015-07-11 14:55:22 +00:00
|
|
|
'';
|
|
|
|
time.timeZone = "Europe/Berlin";
|
|
|
|
}
|
2016-02-27 14:13:44 +00:00
|
|
|
|
2015-07-11 14:55:22 +00:00
|
|
|
{
|
|
|
|
# TODO check if both are required:
|
|
|
|
nix.chrootDirs = [ "/etc/protocols" pkgs.iana_etc.outPath ];
|
|
|
|
|
2016-02-27 14:13:44 +00:00
|
|
|
nix.requireSignedBinaryCaches = true;
|
|
|
|
|
|
|
|
nix.binaryCaches = ["https://cache.nixos.org"];
|
2015-07-11 14:55:22 +00:00
|
|
|
|
|
|
|
nix.useChroot = true;
|
|
|
|
}
|
2016-02-02 19:12:06 +00:00
|
|
|
{
|
|
|
|
nixpkgs.config.allowUnfree = false;
|
|
|
|
}
|
2015-07-16 04:35:19 +00:00
|
|
|
{
|
2015-11-06 20:54:53 +00:00
|
|
|
environment.profileRelativeEnvVars.PATH = mkForce [ "/bin" ];
|
|
|
|
|
2015-07-16 04:35:19 +00:00
|
|
|
environment.systemPackages = with pkgs; [
|
|
|
|
rxvt_unicode.terminfo
|
|
|
|
];
|
2015-07-16 04:26:41 +00:00
|
|
|
|
2015-07-29 13:31:34 +00:00
|
|
|
environment.shellAliases = mkForce {
|
2015-07-11 14:55:22 +00:00
|
|
|
# alias cal='cal -m3'
|
|
|
|
gp = "${pkgs.pari}/bin/gp -q";
|
|
|
|
df = "df -h";
|
|
|
|
du = "du -h";
|
|
|
|
# alias grep='grep --color=auto'
|
|
|
|
|
|
|
|
# TODO alias cannot contain #\'
|
|
|
|
# "ps?" = "ps ax | head -n 1;ps ax | fgrep -v ' grep --color=auto ' | grep";
|
|
|
|
|
|
|
|
# alias la='ls -lA'
|
|
|
|
lAtr = "ls -lAtr";
|
|
|
|
# alias ll='ls -l'
|
|
|
|
ls = "ls -h --color=auto --group-directories-first";
|
|
|
|
dmesg = "dmesg -L --reltime";
|
2015-11-01 12:28:16 +00:00
|
|
|
view = "vim -R";
|
2015-11-10 11:44:30 +00:00
|
|
|
|
|
|
|
reload = "systemctl reload";
|
|
|
|
restart = "systemctl restart";
|
|
|
|
start = "systemctl start";
|
|
|
|
status = "systemctl status";
|
|
|
|
stop = "systemctl stop";
|
2015-07-11 14:55:22 +00:00
|
|
|
};
|
|
|
|
|
2015-11-08 11:28:53 +00:00
|
|
|
environment.variables = {
|
2016-02-04 04:40:26 +00:00
|
|
|
NIX_PATH = mkForce "secrets=/var/src/stockholm/null:/var/src";
|
2015-11-08 11:28:53 +00:00
|
|
|
};
|
|
|
|
|
2015-07-11 14:55:22 +00:00
|
|
|
programs.bash = {
|
|
|
|
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
|
|
|
|
|
2015-07-18 10:36:26 +00:00
|
|
|
${readFile ./bash_completion.sh}
|
|
|
|
|
2015-07-11 14:55:22 +00:00
|
|
|
# TODO source bridge
|
|
|
|
'';
|
|
|
|
promptInit = ''
|
|
|
|
case $UID in
|
|
|
|
0)
|
|
|
|
PS1='\[\e[1;31m\]\w\[\e[0m\] '
|
|
|
|
;;
|
2016-02-21 05:56:57 +00:00
|
|
|
${toString config.krebs.users.tv.uid})
|
2015-07-11 14:55:22 +00:00
|
|
|
PS1='\[\e[1;32m\]\w\[\e[0m\] '
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
PS1='\[\e[1;35m\]\u \[\e[1;32m\]\w\[\e[0m\] '
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
if test -n "$SSH_CLIENT"; then
|
|
|
|
PS1='\[\e[35m\]\h'" $PS1"
|
|
|
|
fi
|
|
|
|
if test -n "$SSH_AGENT_PID"; then
|
|
|
|
PS1="ssh-agent[$SSH_AGENT_PID] $PS1"
|
|
|
|
fi
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2016-01-14 15:31:48 +00:00
|
|
|
programs.ssh = {
|
|
|
|
extraConfig = ''
|
|
|
|
UseRoaming no
|
|
|
|
'';
|
|
|
|
startAgent = false;
|
|
|
|
};
|
2015-07-11 14:55:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
services.cron.enable = false;
|
|
|
|
services.nscd.enable = false;
|
|
|
|
services.ntp.enable = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
boot.kernel.sysctl = {
|
|
|
|
# Enable IPv6 Privacy Extensions
|
|
|
|
"net.ipv6.conf.all.use_tempaddr" = 2;
|
|
|
|
"net.ipv6.conf.default.use_tempaddr" = 2;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2016-02-01 16:40:25 +00:00
|
|
|
{
|
|
|
|
tv.iptables.enable = true;
|
2016-02-07 02:09:14 +00:00
|
|
|
tv.iptables.accept-echo-request = "internet";
|
2016-02-01 16:40:25 +00:00
|
|
|
}
|
|
|
|
|
2015-07-11 14:55:22 +00:00
|
|
|
{
|
|
|
|
services.openssh = {
|
|
|
|
enable = true;
|
|
|
|
hostKeys = [
|
|
|
|
{ type = "ed25519"; path = "/etc/ssh/ssh_host_ed25519_key"; }
|
|
|
|
];
|
|
|
|
};
|
2016-02-01 16:40:25 +00:00
|
|
|
tv.iptables.input-internet-accept-new-tcp = singleton "ssh";
|
2015-07-11 14:55:22 +00:00
|
|
|
}
|
|
|
|
|
2016-02-13 16:58:02 +00:00
|
|
|
{
|
|
|
|
environment.systemPackages = [
|
|
|
|
pkgs.get
|
|
|
|
pkgs.krebszones
|
|
|
|
pkgs.nix-prefetch-scripts
|
|
|
|
pkgs.push
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2015-11-10 11:44:05 +00:00
|
|
|
{
|
|
|
|
systemd.tmpfiles.rules = let
|
|
|
|
forUsers = flip map users;
|
2016-02-01 02:31:24 +00:00
|
|
|
isUser = { name, group, ... }:
|
|
|
|
name == "root" || hasSuffix "users" group;
|
2015-11-10 11:44:05 +00:00
|
|
|
users = filter isUser (mapAttrsToList (_: id) config.users.users);
|
|
|
|
in forUsers (u: "d /run/xdg/${u.name} 0700 ${u.name} ${u.group} -");
|
|
|
|
environment.variables.XDG_RUNTIME_DIR = "/run/xdg/$LOGNAME";
|
|
|
|
}
|
2015-07-11 14:55:22 +00:00
|
|
|
];
|
|
|
|
}
|