2023-08-02 01:59:06 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
let
|
2023-08-02 02:37:29 +00:00
|
|
|
inherit (lib) mkDefault mkIf mkMerge mkOption mkOverride types;
|
2023-08-02 01:59:06 +00:00
|
|
|
cfg = config.beatific;
|
2023-08-02 15:18:26 +00:00
|
|
|
mkFlag = description: mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
inherit description;
|
|
|
|
default = true;
|
|
|
|
};
|
2023-08-02 01:59:06 +00:00
|
|
|
in {
|
|
|
|
options = {
|
2023-08-02 02:17:10 +00:00
|
|
|
beatific = {
|
2023-08-02 02:28:32 +00:00
|
|
|
# The host name is reused for beatific-specific configuration.
|
|
|
|
# The bulk of common config is handled in beatific.defaults below, but
|
|
|
|
# having one option without a default ensures that the module cannot be
|
|
|
|
# imported accidentally.
|
2023-08-02 02:17:10 +00:00
|
|
|
hostName = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
description = "Hostname";
|
|
|
|
};
|
|
|
|
|
2023-08-02 02:28:32 +00:00
|
|
|
# Groups of related defaults can be disabled by flipping off the switches here:
|
|
|
|
# beatific.defaults.${category} = false;
|
|
|
|
# They default to true because the point is to do these things by default.
|
2023-08-02 02:17:10 +00:00
|
|
|
defaults = {
|
2023-08-02 15:19:57 +00:00
|
|
|
time = mkFlag "Default time zone and NTP";
|
|
|
|
i18n = mkFlag "Default locale settings";
|
|
|
|
programs = mkFlag "Default installed programs";
|
2023-08-02 15:18:26 +00:00
|
|
|
ssh = mkFlag "Enable openssh";
|
2023-08-02 15:19:57 +00:00
|
|
|
tvb = mkFlag "Default tvb account";
|
2023-08-02 02:17:10 +00:00
|
|
|
};
|
2023-08-02 01:59:06 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-08-02 02:17:10 +00:00
|
|
|
config = mkMerge [
|
|
|
|
{
|
2023-08-02 02:28:32 +00:00
|
|
|
# Options to always set
|
2023-08-02 02:17:10 +00:00
|
|
|
networking.hostName = cfg.hostName;
|
2023-08-02 02:19:18 +00:00
|
|
|
nix.extraOptions = "experimental-features = nix-command flakes";
|
2023-08-02 02:17:10 +00:00
|
|
|
}
|
2023-08-02 02:28:32 +00:00
|
|
|
|
2023-08-02 02:17:10 +00:00
|
|
|
(mkIf cfg.defaults.time {
|
2023-08-02 02:28:32 +00:00
|
|
|
# mkDefault time zone to make it easy to configure it to non-UTC
|
|
|
|
time.timeZone = mkDefault "UTC";
|
2023-08-02 02:17:10 +00:00
|
|
|
services.ntp.enable = true;
|
|
|
|
services.ntp.servers = [ "time.nist.gov" ];
|
|
|
|
})
|
2023-08-02 02:28:32 +00:00
|
|
|
|
|
|
|
(mkIf cfg.defaults.i18n {
|
|
|
|
# en_US.UTF-8
|
|
|
|
i18n.defaultLocale = "en_US.UTF-8";
|
|
|
|
i18n.extraLocaleSettings = {
|
|
|
|
LC_ADDRESS = "en_US.UTF-8";
|
|
|
|
LC_IDENTIFICATION = "en_US.UTF-8";
|
|
|
|
LC_MEASUREMENT = "en_US.UTF-8";
|
|
|
|
LC_MONETARY = "en_US.UTF-8";
|
|
|
|
LC_NAME = "en_US.UTF-8";
|
|
|
|
LC_NUMERIC = "en_US.UTF-8";
|
|
|
|
LC_PAPER = "en_US.UTF-8";
|
|
|
|
LC_TELEPHONE = "en_US.UTF-8";
|
|
|
|
LC_TIME = "en_US.UTF-8";
|
|
|
|
};
|
|
|
|
})
|
2023-08-02 02:37:29 +00:00
|
|
|
|
|
|
|
(mkIf cfg.defaults.programs {
|
|
|
|
environment.systemPackages = with pkgs; [
|
|
|
|
curl
|
|
|
|
git
|
|
|
|
htop
|
|
|
|
python3
|
|
|
|
vim
|
|
|
|
wget
|
|
|
|
];
|
|
|
|
# The nixpkgs default is "nano", so we go one priority higher
|
|
|
|
environment.variables.EDITOR = mkOverride 999 "vim";
|
|
|
|
})
|
2023-08-02 15:18:26 +00:00
|
|
|
|
|
|
|
(mkIf cfg.defaults.ssh {
|
|
|
|
services.openssh.enable = true;
|
2023-08-02 15:23:52 +00:00
|
|
|
services.openssh.banner = ''
|
|
|
|
____ ______ _______ _____ ______ _____ ______ ./|,,/|
|
|
|
|
| _ \| ____| /\ |__ __|_ _| ____|_ _|/ ____/ < o o|
|
|
|
|
| |_) | |__ / \ | | | | | |__ | | | | <\ ( |
|
|
|
|
| _ <| __| / /\ \ | | | | | __| | | | | <\\ |\ |
|
|
|
|
| |_) | |____/ ____ \ | | _| |_| | _| |_| |___<\\\ |(__)
|
|
|
|
|____/|_____/_/ \_\|_| |_____|_| |_____|\_____|\\ |
|
|
|
|
|
|
|
|
'';
|
|
|
|
networking.firewall.allowPing = true;
|
2023-08-02 15:18:26 +00:00
|
|
|
networking.firewall.allowedTCPPorts = [ 22 ];
|
|
|
|
})
|
|
|
|
|
|
|
|
(mkIf cfg.defaults.tvb {
|
|
|
|
users.groups.tvb = {};
|
|
|
|
users.users.tvb = {
|
|
|
|
isNormalUser = true;
|
|
|
|
group = "tvb";
|
|
|
|
extraGroups = [ "wheel" ];
|
|
|
|
initialPassword = "password";
|
|
|
|
openssh.authorizedKeys.keyFiles = [
|
|
|
|
../keys/tvb.catacomb.pub
|
|
|
|
../keys/tvb.empyrean.pub
|
|
|
|
../keys/tvb.palamas.pub
|
|
|
|
../keys/tvb.stagirite.pub
|
|
|
|
../keys/tvb.unfolder.pub
|
|
|
|
../keys/tvb.vagrant.pub
|
|
|
|
];
|
|
|
|
};
|
|
|
|
})
|
2023-08-02 02:17:10 +00:00
|
|
|
];
|
2023-08-02 01:59:06 +00:00
|
|
|
}
|