189 lines
4.9 KiB
Nix
189 lines
4.9 KiB
Nix
{ config, lib, pkgs, meta, ... }:
|
||
|
||
{
|
||
imports = [ ];
|
||
|
||
nix.settings.experimental-features = [ "nix-command" "flakes" ];
|
||
nixpkgs.config.allowUnfree = true;
|
||
|
||
# Secret Management
|
||
sops = {
|
||
age.keyFile = "./age/keys.txt"; # Make sure to gitignore, contains private key.
|
||
defaultSopsFormat = "json";
|
||
|
||
secrets = {
|
||
"clusterPassword" = {
|
||
sopsFile = ./secrets/build.json;
|
||
};
|
||
"cloudflare-credentials" = {
|
||
sopsFile = ./secrets/cloudflare.json;
|
||
};
|
||
};
|
||
};
|
||
|
||
systemd.user.services.mbsync.unitConfig.After = [ "sops-nix.service" ];
|
||
|
||
environment.variables = {
|
||
SECRETKEY = "${config.sops.secrets."clusterPassword".path}";
|
||
};
|
||
|
||
# set up DNS with nginx
|
||
security.acme = {
|
||
acceptTerms = true;
|
||
defaults = {
|
||
email = "roydumblauskas@gmail.com";
|
||
dnsProvider = "cloudflare";
|
||
environmentFile = config.sops.secrets."cloudflare-credentials".path;
|
||
};
|
||
};
|
||
|
||
services.nginx = {
|
||
enable = true;
|
||
virtualHosts = {
|
||
"roypository.com" = {
|
||
forceSSL = true;
|
||
enableACME = true;
|
||
acmeRoot = false;
|
||
addSSL = true;
|
||
};
|
||
"*.roypository.com" = {
|
||
forceSSL = true;
|
||
enableACME = true;
|
||
acmeRoot = false;
|
||
addSSL = true;
|
||
};
|
||
};
|
||
};
|
||
|
||
services.nginx.virtualHosts."test.roypository.com" = {
|
||
forceSSL = true;
|
||
enableACME = true;
|
||
addSSL = true;
|
||
acmeRoot = false;
|
||
|
||
locations."/" = {
|
||
proxyPass = "http://localhost:3000";
|
||
proxyWebsockets = true; # optional: if using websockets
|
||
extraConfig = ''
|
||
proxy_set_header Host $host;
|
||
proxy_set_header X-Real-IP $remote_addr;
|
||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||
proxy_set_header X-Forwarded-Proto $scheme;
|
||
'';
|
||
};
|
||
};
|
||
|
||
# Grub Boot Loader Setup
|
||
boot.loader.grub = {
|
||
enable = true;
|
||
zfsSupport = true;
|
||
efiSupport = true;
|
||
efiInstallAsRemovable = true;
|
||
mirroredBoots = [
|
||
{ devices = [ "nodev" ]; path = "/boot"; }
|
||
];
|
||
};
|
||
|
||
networking.hostName = meta.hostname;
|
||
|
||
networking.interfaces.eth0.ipv4.addresses = [
|
||
{
|
||
address = config.ipAddrs.${meta.hostname};
|
||
prefixLength = 24;
|
||
}
|
||
];
|
||
|
||
networking.defaultGateway = "192.168.1.1";
|
||
networking.nameservers = [ "1.1.1.1" "1.0.0.1" ];
|
||
|
||
# Open ports in the firewall.
|
||
# networking.firewall.allowedTCPPorts = [ ... ];
|
||
# networking.firewall.allowedUDPPorts = [ ... ];
|
||
networking.firewall = {
|
||
enable = true;
|
||
allowedTCPPorts = [ 22 80 443 ];
|
||
};
|
||
|
||
# Set your time zone.
|
||
time.timeZone = "America/Chicago";
|
||
|
||
# Configure network proxy if necessary
|
||
# networking.proxy.default = "http://user:password@proxy:port/";
|
||
# networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";
|
||
|
||
# Select internationalisation properties.
|
||
# i18n.defaultLocale = "en_US.UTF-8";
|
||
# console = {
|
||
# font = "Lat2-Terminus16";
|
||
# keyMap = "us";
|
||
# useXkbConfig = true; # use xkb.options in tty.
|
||
# };
|
||
|
||
# Enable the X11 windowing system.
|
||
# services.xserver.enable = true;
|
||
|
||
# Configure keymap in X11
|
||
# services.xserver.xkb.layout = "us";
|
||
# services.xserver.xkb.options = "eurosign:e,caps:escape";
|
||
|
||
# Enable CUPS to print documents.
|
||
services.printing.enable = true;
|
||
|
||
# Enable sound.
|
||
# hardware.pulseaudio.enable = true;
|
||
# OR
|
||
# services.pipewire = {
|
||
# enable = true;
|
||
# pulse.enable = true;
|
||
# };
|
||
|
||
|
||
# Define a user account. Don't forget to set a password with ‘passwd’.
|
||
users.users.sysAdmin = {
|
||
isNormalUser = true;
|
||
extraGroups = [ "wheel" "networkManager" ];
|
||
# created with mkpasswd
|
||
hashedPassword = "$6$8KRJ44z15XsQALM.$J4geTLaph7ynaLimlYXMGafqPOP6DONLSlTbRowH7JF7WJ4cWyMSTYQQB4OwsAgPpLCTYDzpqn6a/pfIizWFA.";
|
||
openssh.authorizedKeys.keys = [
|
||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICNkZ5Xr75thR/tEgsASzYAtaA/kbsv2PKI8ux9rgpTe roydumblauskas@gmail.com"
|
||
];
|
||
};
|
||
|
||
users.users.root = {
|
||
hashedPassword = "$y$j9T$IjaP0KIfdpEvlLtOn.u0T/$0MJDaFEdSu6zSJ04CF1dtorD6IVgbN3vmDiiwGwwqr5";
|
||
openssh.authorizedKeys.keys = [
|
||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICNkZ5Xr75thR/tEgsASzYAtaA/kbsv2PKI8ux9rgpTe roydumblauskas@gmail.com"
|
||
];
|
||
};
|
||
|
||
# List packages installed in system profile. To search, run:
|
||
# $ nix search wget
|
||
environment.systemPackages = with pkgs; [
|
||
curl
|
||
vim
|
||
wget
|
||
];
|
||
|
||
|
||
# Some programs need SUID wrappers, can be configured further or are
|
||
# started in user sessions.
|
||
# programs.mtr.enable = true;
|
||
# programs.gnupg.agent = {
|
||
# enable = true;
|
||
# enableSSHSupport = true;
|
||
# };
|
||
|
||
# List services that you want to enable:
|
||
# Enable the OpenSSH daemon.
|
||
services.openssh.enable = true;
|
||
|
||
# Copy the NixOS configuration file and link it from the resulting system
|
||
# (/run/current-system/configuration.nix). This is useful in case you
|
||
# accidentally delete configuration.nix.
|
||
# system.copySystemConfiguration = true;
|
||
|
||
# INITIAL system version
|
||
system.stateVersion = "24.11";
|
||
|
||
}
|