nixos-config/config/profile-config/common.nix

167 lines
3.7 KiB
Nix
Raw Normal View History

{ config, lib, pkgs, ... }:
with lib;
let
2022-03-16 09:49:35 -07:00
hostname = config.instance.hostname;
# Available to all users on the system. Keep it minimal.
global-packages = with pkgs; [
bind
cryptsetup
git
heimdal
2021-11-13 10:30:58 -08:00
mosh
openssh_gssapi
tldr
vim
wget
];
2022-03-16 09:49:35 -07:00
import-paths = [ ./build ./host ./user ];
2021-11-05 07:06:08 -07:00
in {
2021-11-05 07:06:08 -07:00
imports = let
is-regular-file = filename: type: type == "regular" || type == "link";
regular-files = path:
attrNames (filterAttrs is-regular-file (builtins.readDir path));
2022-03-16 09:49:35 -07:00
is-nix-file = filename: (builtins.match "^(.+).nix$" filename) != null;
2021-11-05 07:06:08 -07:00
nix-files = path:
2022-03-16 09:49:35 -07:00
map (file: path + "/${file}") (filter is-nix-file (regular-files path));
2021-11-05 07:06:08 -07:00
in concatMap nix-files import-paths;
config = {
2022-03-16 09:49:35 -07:00
fudo.hosts.${hostname}.local-networks = [ "::1/128" ];
2021-11-05 07:06:08 -07:00
system.autoUpgrade.enable = false;
2021-11-05 07:06:08 -07:00
nix = {
package = pkgs.nixFlakes;
extraOptions = ''
2022-03-16 09:49:35 -07:00
experimental-features = nix-command flakes
'';
2021-11-05 07:06:08 -07:00
};
2021-11-05 07:06:08 -07:00
nixpkgs.config.allowUnfree = true;
2022-03-16 09:49:35 -07:00
2021-11-05 07:06:08 -07:00
hardware.enableRedistributableFirmware = true;
2021-11-05 07:06:08 -07:00
krb5 = {
enable = true;
2021-11-05 07:06:08 -07:00
appdefaults = {
forwardable = true;
proxiable = true;
encrypt = true;
forward = true;
};
2021-11-05 07:06:08 -07:00
libdefaults = {
allow_weak_crypto = true;
dns_lookup_kdc = true;
dns_lookup_realm = true;
forwardable = true;
proxiable = true;
};
2021-11-05 07:06:08 -07:00
kerberos = pkgs.heimdalFull;
};
2021-11-05 07:06:08 -07:00
services = {
openssh = {
enable = true;
startWhenNeeded = true;
useDns = true;
permitRootLogin = "prohibit-password";
extraConfig = ''
2022-03-16 09:49:35 -07:00
GSSAPIAuthentication yes
GSSAPICleanupCredentials yes
GSSAPIKeyExchange yes
GSSAPIStoreCredentialsOnRekey yes
'';
2021-11-05 07:06:08 -07:00
};
2022-03-16 09:49:35 -07:00
fail2ban =
let domain-name = config.fudo.hosts.${config.instance.hostname}.domain;
in {
enable = config.networking.firewall.enable;
bantime-increment.enable = true;
};
2021-11-05 07:06:08 -07:00
xserver = {
layout = "us";
xkbVariant = "dvp";
xkbOptions = "ctrl:nocaps";
};
2022-03-16 09:49:35 -07:00
btrfs.autoScrub.enable = let
btrfsFilesystems = filter (fsOpts: fsOpts.fsType == "btrfs")
(attrValues config.fileSystems);
in length btrfsFilesystems > 0;
2021-11-05 07:06:08 -07:00
# pcscd.enable = true;
# udev.packages = with pkgs; [ yubikey-personalization ];
};
2021-11-05 07:06:08 -07:00
networking.firewall = {
# Allow mosh connections if the firewall is enabled
allowedUDPPortRanges = [{
from = 60000;
to = 60100;
}];
};
2021-11-05 07:06:08 -07:00
console.useXkbConfig = true;
2021-11-05 07:06:08 -07:00
i18n.defaultLocale = "en_US.UTF-8";
2021-11-05 07:06:08 -07:00
programs = {
mosh.enable = true;
2021-11-05 07:06:08 -07:00
bash.enableCompletion = true;
2021-11-05 07:06:08 -07:00
fish.enable = true;
2021-11-05 07:06:08 -07:00
gnupg.agent = {
enable = true;
# enableSSHSupport = true;
# pinentryFlavor = if cfg.enable-gui then "gnome3" else "curses";
};
2021-11-05 07:06:08 -07:00
ssh = {
startAgent = true;
2021-11-05 07:06:08 -07:00
package = pkgs.openssh_gssapi;
2021-11-05 07:06:08 -07:00
extraConfig = ''
2021-11-17 17:32:27 -08:00
GSSAPIAuthentication yes
GSSAPIDelegateCredentials yes
'';
2021-11-05 07:06:08 -07:00
};
};
2022-03-16 09:49:35 -07:00
security = {
2022-03-16 09:49:35 -07:00
acme.acceptTerms = true;
sudo.extraConfig = ''
# rollback results in sudo lectures after each reboot
Defaults lecture = never
'';
pam = {
enableSSHAgentAuth = true;
services = {
sshd = {
makeHomeDir = true;
sshAgentAuth = true;
# This isn't supposed to ask for a code unless ~/.google_authenticator exists...but it does
# googleAuthenticator.enable = true;
};
2021-11-05 07:06:08 -07:00
};
};
};
2021-11-05 07:06:08 -07:00
2022-03-16 09:49:35 -07:00
home-manager = { useGlobalPkgs = true; };
};
}