stockholm/tv/2configs/default.nix

191 lines
4.8 KiB
Nix
Raw Normal View History

2015-07-11 14:55:22 +00:00
{ config, lib, pkgs, ... }:
with lib;
{
krebs.enable = true;
2015-11-06 21:36:01 +00:00
krebs.build = {
user = config.krebs.users.tv;
target = mkDefault "root@${config.krebs.build.host.name}";
source-version = 2;
source = mapAttrs (_: mkDefault) ({
nixos-config = "symlink:stockholm-private/1systems/${config.krebs.build.host.name}.nix";
nixpkgs = symlink:stockholm-nixpkgs;
secrets = "/home/tv/secrets/${config.krebs.build.host.name}";
secrets-common = "/home/tv/secrets/common";
stockholm-krebs = "/home/tv/stockholm/krebs";
stockholm-nixpkgs = "/home/tv/stockholm/nixpkgs";
stockholm-private = "/home/tv/stockholm/tv";
upstream-nixpkgs = {
url = https://github.com/NixOS/nixpkgs;
rev = "77f8f35d57618c1ba456d968524f2fb2c3448295";
dev = "/home/tv/nixpkgs";
2015-11-06 21:36:01 +00:00
};
} // optionalAttrs config.krebs.build.host.secure {
secrets-master = "/home/tv/secrets/master";
});
2015-11-06 21:36:01 +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
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 = {
isNormalUser = true;
uid = 1337;
};
2015-07-11 14:55:22 +00:00
};
};
}
{
security.sudo.extraConfig = ''
2015-07-24 23:06:13 +00:00
Defaults mailto="${config.krebs.users.tv.mail}"
2015-07-11 14:55:22 +00:00
'';
time.timeZone = "Europe/Berlin";
}
{
# TODO check if both are required:
nix.chrootDirs = [ "/etc/protocols" pkgs.iana_etc.outPath ];
nix.trustedBinaryCaches = [
"https://cache.nixos.org"
"http://cache.nixos.org"
"http://hydra.nixos.org"
];
nix.useChroot = true;
}
{
environment.profileRelativeEnvVars.PATH = mkForce [ "/bin" ];
environment.systemPackages = with pkgs; [
rxvt_unicode.terminfo
];
2015-07-16 04:26:41 +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 = {
NIX_PATH = mkForce "/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
${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\] '
;;
1337)
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;
};
}
{
services.openssh = {
enable = true;
hostKeys = [
{ type = "ed25519"; path = "/etc/ssh/ssh_host_ed25519_key"; }
];
};
}
{
# TODO: exim
security.setuidPrograms = [
"sendmail" # for sudo
];
}
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
];
}