This commit is contained in:
Jimbo 2024-08-24 22:21:30 -04:00
parent 5e0b713756
commit 0d4700e56f
12 changed files with 0 additions and 4940 deletions

1
.gitignore vendored
View file

@ -1 +0,0 @@
nixos/common/secrets.nix

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 314 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 MiB

View file

@ -1,470 +0,0 @@
{
config,
pkgs,
options,
lib,
...
}: let
# Set common boot paramaters
commonKernelParams = [
# Nvidia settings
"nvidia_drm.fbdev=1"
# VM/GPU passthrough
"amd_iommu=on"
"iommu=pt"
"nested=1"
# Virtualization nonsense
"transparent_hugepage=never"
# Isolate devices into IOMMU groups
"pcie_acs_override=downstream,multifunction"
"pci=routeirq"
];
in {
# Import other nix files and firmware
imports = let
homeManager =
fetchTarball
"https://github.com/nix-community/home-manager/archive/release-24.05.tar.gz";
in [
./hardware-configuration.nix
./jimbo.nix
"${homeManager}/nixos"
];
# Allow unfree packages and accept packages from the Nix User Repos
nixpkgs = {
config = {
allowUnfree = true;
packageOverrides = pkgs: {
unstable =
import (
fetchTarball
"https://github.com/NixOS/nixpkgs/archive/nixos-unstable.tar.gz"
) {
inherit pkgs;
config.allowUnfree = true;
};
nur = import (
fetchTarball
"https://github.com/nix-community/NUR/archive/master.tar.gz"
) {inherit pkgs;};
};
};
# Package overlays/patches
overlays = [
# MPV scripts
(self: super: {
mpv = super.mpv.override {
scripts = with self.mpvScripts; [mpris sponsorblock thumbnail];
};
})
];
};
# Allow flakes and enable garbage collection
nix = {
settings.experimental-features = ["nix-command" "flakes"];
gc = {
automatic = true;
dates = "weekly";
options = "--delete-older-than 14d";
};
};
# Set all boot options
boot = {
# Set a kernel version and load/blacklist drivers
kernelPackages = pkgs.unstable.linuxPackages_zen;
blacklistedKernelModules = ["pcspkr"];
kernelParams = commonKernelParams ++ ["vfio-pci.ids=10de:1f82,10de:10fa"];
initrd.kernelModules = ["vfio" "vfio_pci" "vfio_iommu_type1"];
kernel.sysctl."vm.max_map_count" = 2147483642;
# Manage supported filesystems
supportedFilesystems = {
ntfs = true;
zfs = lib.mkForce false;
};
# Modprobe settings
extraModprobeConfig = ''
options hid_apple fnmode=2
'';
# Use the Systemd-Boot bootloader
loader.systemd-boot = {
enable = true;
netbootxyz.enable = true;
};
};
# Additional entry to boot from the second GPU
specialisation = {
gputwo.configuration = {
boot.kernelParams = commonKernelParams ++ ["vfio-pci.ids=10de:2504,10de:228e"];
};
};
# Allow binary firmware
hardware.enableRedistributableFirmware = true;
# Enable video drivers
services.xserver.videoDrivers = ["nvidia"];
hardware.nvidia = {
modesetting.enable = true;
nvidiaSettings = false;
package = config.boot.kernelPackages.nvidiaPackages.beta;
open = true;
};
# Enable a permissioning system
security = {
sudo.enable = false;
doas = {
enable = true;
extraRules = [
# Give wheel root access, allow persistant session
{
groups = ["wheel"];
keepEnv = true;
persist = true;
}
];
};
};
# Enable the ZSH shell
programs.zsh.enable = true;
# Disable Nano
programs.nano.enable = false;
# Timezone
time.timeZone = "America/New_York";
# Define user accounts
users.users.jimbo = {
description = "Jimbo Awesome";
isNormalUser = true;
hashedPassword = "$6$gYpE.pG/zPXgin06$2kydjDfd0K62Dhf9P0PFvJhRNz6xIC/bHYaf/XYqyKcLyZNzPQpy8uy9tCRcSYlj1wwBhzVtTRyItwajOHCEj0";
openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIKC8Uqxb09V3msBgDv6lD/nETMYr/X0OgtpDo8ldcMK jimbo@JimDebianServer"
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDLe/HioxCOkszFQdm1vb3ZwuzLzsOThqHNvEI4IXeXZ JimPhone"
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPeqiMCRXtpoP+BvKBmzvkL7oLKKCmbfdaQIF3yk/S8I jimbo@DV-JHAMPTON-NIXOS"
];
extraGroups = [
"wheel"
"audio"
"video"
"input"
"disk"
"dialout"
"networkmanager"
"rtkit"
"kvm"
"libvirtd"
"qemu-libvirtd"
];
uid = 1000;
shell = pkgs.zsh;
};
# Install programs system-wide
environment.systemPackages = with pkgs; [
# Essential system tools
cifs-utils
parted
git
# Printer control
system-config-printer
# Virtual machines
virt-manager
virtiofsd
dnsmasq
spice-vdagent
looking-glass-client
];
# Disable the HTML documentation link
documentation = {
nixos.enable = false;
info.enable = false;
};
# Enable graphics
hardware.opengl = {
enable = true;
driSupport32Bit = true;
extraPackages = with pkgs; [
vulkan-loader
vulkan-validation-layers
vulkan-extension-layer
];
};
# Enable Steam hardware and gamemode
hardware.steam-hardware.enable = true;
programs.gamemode.enable = true;
# Networking settings
networking = {
# Set hostname
hostName = "JimNixPC";
# Choose networking method
dhcpcd.enable = true;
wireless.enable = false;
#networkmanager.enable = true;
#enableB43Firmware = true;
# Enable firewall
firewall = {
allowPing = false;
extraInputRules = ''
ip saddr 10.0.0.2 accept comment "Accept Server Connections"
'';
};
# Enable nftables over iptables
nftables.enable = true;
# Set hostnames
hosts = {
"10.0.0.2" = ["server"];
"10.0.0.3" = ["pc"];
};
};
# Enable Bluetooth
hardware.bluetooth = {
enable = true;
settings = {
General.Experimental = "true";
Policy.AutoEnable = "true";
};
};
# Enable lingering for Bluetooth and allow Looking-Glass permissions
systemd.tmpfiles.rules = [
"f /var/lib/systemd/linger/jimbo"
"f /dev/shm/looking-glass 0660 jimbo libvirtd -"
];
# Make udev rules to make PDP controller and Oculus Rift CV1 work
services.udev = let
oculusRules = pkgs.writeTextFile {
name = "10-oculus.rules";
text = ''
KERNEL=="hidraw*", ATTRS{idVendor}=="0e6f", ATTRS{idProduct}=="0184", MODE="0660", TAG+="uaccess"
'';
destination = "/etc/udev/rules.d/10-oculus.rules";
};
pdpRules = pkgs.writeTextFile {
name = "10-pdp.rules";
text = ''
SUBSYSTEM=="usb", ATTR{idVendor}=="2833", MODE="0666"
'';
destination = "/etc/udev/rules.d/10-pdp.rules";
};
in {
packages = [oculusRules pdpRules];
};
# Enable audio
security.rtkit.enable = true;
hardware.pulseaudio.enable = false;
services.pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
#jack.enable = true;
wireplumber.configPackages = [
(pkgs.writeTextDir "share/wireplumber/wireplumber.conf.d/11-bluetooth-policy.conf" ''
wireplumber.settings = { bluetooth.autoswitch-to-headset-profile = false }
'')
];
};
# Fonts
fonts = {
packages = with pkgs; [
liberation_ttf
twitter-color-emoji
ubuntu_font_family
noto-fonts
sarasa-gothic
orbitron
(nerdfonts.override {fonts = ["UbuntuMono"];})
];
fontconfig.defaultFonts.emoji = ["Twitter Color Emoji"];
};
# Enable Dconf and some portals
services.dbus.enable = true;
programs.dconf.enable = true;
programs.light.enable = true;
security.pam.services.swaylock = {};
xdg.portal = {
enable = true;
config.common.default = "*";
wlr = {
enable = true;
settings = {
screencast = {
max_fps = 60;
chooser_type = "simple";
chooser_cmd = "${pkgs.slurp}/bin/slurp -f %o -or -B 00000066 -b 00000099";
};
};
};
extraPortals = with pkgs; [xdg-desktop-portal-gtk];
};
# Configure greetd for remote login
services.greetd = let
startSway = pkgs.writeScript "startsway" ''
# Use NVIDIA variables if drivers are in use
if lspci -k | grep "Kernel driver in use: nvidia" &> /dev/null; then
# NVIDIA/AMD variables
export LIBVA_DRIVER_NAME=nvidia
export GBM_BACKEND=nvidia-drm
export __GLX_VENDOR_LIBRARY_NAME=nvidia
export WLR_NO_HARDWARE_CURSORS=1
else
:
fi
# Sway/Wayland
export XDG_CURRENT_DESKTOP=sway
export QT_QPA_PLATFORM="wayland;xcb"
# Start Sway
sway --unsupported-gpu
'';
in {
enable = true;
restart = true;
settings = {
terminal = {
vt = 2;
switch = true;
};
default_session = {
command = "${startSway}";
user = "jimbo";
};
};
};
# Enable printing
services = {
printing = {
enable = true;
drivers = with pkgs; [hplip];
webInterface = false;
};
avahi = {
enable = true;
nssmdns4 = true;
openFirewall = true;
};
};
# Enable virtualization
virtualisation = {
libvirtd = {
enable = true;
onBoot = "ignore";
onShutdown = "shutdown";
qemu = {
ovmf = {
enable = true;
packages = [pkgs.OVMFFull.fd];
};
swtpm.enable = true;
};
};
spiceUSBRedirection.enable = true;
};
# Enable SSH
services.openssh = {
enable = true;
settings = {
LogLevel = "VERBOSE";
PermitRootLogin = "no";
PrintLastLog = "no";
PasswordAuthentication = false;
};
};
# Block SSH connections after numerous attempts
services.fail2ban = {
enable = true;
maxretry = 5;
bantime = "5m";
};
# Enable AppImages
programs.appimage = {
enable = true;
binfmt = true;
};
# Enable Sunshine as a service
services.sunshine = {
enable = true;
settings.port = 57989;
autoStart = false;
};
# Enable MPD
services.mpd = {
enable = true;
user = "jimbo";
group = "users";
musicDirectory = "/home/jimbo/JimboNFS/Music";
playlistDirectory = "/home/jimbo/JimboNFS/Music/Playlists";
extraConfig = ''
audio_output {
type "pipewire"
name "Local Pipewire"
}
'';
};
systemd.services.mpd.environment = {
XDG_RUNTIME_DIR = "/run/user/${toString config.users.users.jimbo.uid}";
};
# Enable AppArmor
security.apparmor.enable = true;
# Enable a keying agent
services.gnome.gnome-keyring.enable = true;
# Enable Polkit for authentication
security.polkit.enable = true;
# Battery saver for laptops
services.tlp.enable = true;
# Enable extra functionality in file managers
services.gvfs.enable = true;
# Attempt to automount USB drives
services.udisks2.enable = true;
# Enable school VPN
services.globalprotect.enable = true;
# Define the initial install version and allow auto-upgrades
system.stateVersion = "23.11";
system.autoUpgrade.enable = true;
}

View file

@ -1,76 +0,0 @@
# This file was generated by 'nixos-generate-config', try not to modify too much
{
config,
lib,
pkgs,
modulesPath,
...
}: {
imports = [
(modulesPath + "/installer/scan/not-detected.nix")
];
# Load kernel modules on boot
boot = {
initrd = {
availableKernelModules = ["nvme" "xhci_pci" "ahci" "usbhid" "usb_storage" "sd_mod"];
kernelModules = [];
};
kernelModules = ["kvm-amd"];
extraModulePackages = [];
};
# Mount everything as necessary
fileSystems = {
"/" = {
device = "/dev/disk/by-uuid/f0786b07-8303-416f-87ff-276bfd696387";
fsType = "bcachefs";
};
"/boot" = {
device = "/dev/disk/by-uuid/EF6D-9009";
fsType = "vfat";
};
"/etc/libvirt" = {
device = "/dev/disk/by-label/Qemu";
options = ["nosuid" "nodev" "nofail"];
};
"/var/lib/libvirt" = {
depends = ["/etc/libvirt"];
device = "/etc/libvirt/varlibvirt";
options = ["bind" "rw"];
};
"/mnt/Linux1" = {
device = "/dev/disk/by-label/Linux1";
options = ["nosuid" "nodev" "nofail" "x-gvfs-show"];
};
"/mnt/Linux2" = {
device = "/dev/disk/by-label/Linux2";
options = ["nosuid" "nodev" "nofail" "x-gvfs-show"];
};
"/mnt/Windows1" = {
device = "/dev/disk/by-label/Windows1";
options = ["nosuid" "nodev" "noauto"];
};
"/mnt/Windows2" = {
device = "/dev/disk/by-label/Windows2";
options = ["nosuid" "nodev" "noauto"];
};
"/home/jimbo/JimboNFS" = {
device = "server:/export/JimboNFS";
fsType = "nfs4";
options = ["x-systemd.automount" "_netdev" "nofail" "noauto"];
};
};
# Set the swap partition
swapDevices = [
{device = "/dev/disk/by-uuid/2e4c5120-716d-4cdc-84a0-c9e6391760db";}
];
# Enables DHCP on each ethernet and wireless interface.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.enp42s0.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

File diff suppressed because it is too large Load diff

View file

@ -1,781 +0,0 @@
{ config, pkgs, options, lib, ... }:
let
# Import home manager
homeManager = fetchTarball
"https://github.com/nix-community/home-manager/archive/release-24.05.tar.gz";
# IPs
netInt = ''eno1'';
localSpan = ''10.0.0'';
serverIP = ''${localSpan}.2'';
pcIP = ''${localSpan}.3'';
vmIP = ''${localSpan}.4'';
# Secrets and passwords
secrets = import ./secrets.nix;
in
{
# Import other nix files and firmware
imports = [
./hardware-configuration.nix
./jimbo.nix
"${homeManager}/nixos"
# Mail server import
(fetchTarball
"https://gitlab.com/simple-nixos-mailserver/nixos-mailserver/-/archive/nixos-24.05/nixos-mailserver-nixos-24.05.tar.gz"
)
];
# Allow unfree packages
nixpkgs.config.allowUnfree = true;
# Allow flakes (I have no clue how they work yet)
nix.settings.experimental-features = [ "nix-command" "flakes" ];
# Allow unfree firmware
hardware.enableRedistributableFirmware = true;
# Choose Grub as the bootloader
boot = {
loader.systemd-boot = {
enable = true;
netbootxyz.enable = true;
};
};
# Enable a permissioning system
security = {
sudo.enable = false;
doas = {
enable = true;
extraRules = [
# Give wheel root access, allow persistant session
{ groups = [ "wheel" ]; keepEnv = true; persist = true; }
];
};
};
# Enable the ZSH shell
programs.zsh.enable = true;
# Disable Nano
programs.nano.enable = false;
# Define user account.
users.users.jimbo = {
isNormalUser = true;
hashedPassword = secrets.jimboAccPass;
openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDLe/HioxCOkszFQdm1vb3ZwuzLzsOThqHNvEI4IXeXZ JimPhone"
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJPjBdQrL23pDbcsNCLMvJhcNF7+u95ZV7o1QemOmegf jimbo@JimNixPC"
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPeqiMCRXtpoP+BvKBmzvkL7oLKKCmbfdaQIF3yk/S8I jimbo@DV-JHAMPTON-NIXOS"
];
extraGroups = [ "wheel" "docker" "nfsShare" ];
uid = 1000;
shell = pkgs.zsh;
};
# Add service users to extra groups
users.users = {
nginx = {
extraGroups = [ "turnserver" "virtualMail" ];
isSystemUser = true;
};
nextcloud = {
extraGroups = [ "nfsShare" ];
isSystemUser = true;
};
};
# Define custom groups
users.groups = {
nfsShare = {};
};
# Installed programs to the system profile.
environment.systemPackages = with pkgs; [
# Essential system tools
git parted mdadm
];
# Define timezone and networking settings
time.timeZone = secrets.timeZone;
networking = {
hostName = "JimNixServer";
# Choose networking method
dhcpcd.enable = true;
wireless.enable = false;
# Configure firewall
firewall = {
allowPing = false;
allowedTCPPorts = [
80 443 # Nginx
25565 19132 5657 # Pufferpanel
2299 # Gitea SSH
3478 5349 # Coturn
];
allowedTCPPortRanges = [
{ from = 8100; to = 8150; } # Azuracast
];
allowedUDPPorts = [
25565 19132 # Minecraft Voicechat and Bedrock
3478 5349 # Coturn UDP
];
allowedUDPPortRanges = [
{ from = 49000; to = 50000; } # Coturn range
];
# Add extra input rules using nftables
extraInputRules = ''
ip saddr ${localSpan}.0/24 tcp dport 2049 accept comment "Accept NFS"
ip saddr ${localSpan}.0/24 udp dport 53 accept comment "Accept DNS"
ip saddr { ${pcIP}, ${secrets.lunaIP}, ${secrets.cornIP}, ${secrets.vertIP} } tcp dport { 1935, 1945 } accept comment "Accept RTMP"
'';
};
# Enable nftables and forwarding
nftables = {
enable = true;
tables = {
forwarding = {
family = "ip";
content = ''
chain PREROUTING {
type nat hook prerouting priority dstnat; policy accept;
tcp dport 2211 dnat to ${pcIP}:22 comment "SSH to PC"
udp dport { 27005, 27015, 7777 } dnat to ${pcIP} comment "Games to PC"
tcp dport { 58010, 57989, 57984 } dnat to ${pcIP} comment "Sunshine TCP to PC"
udp dport { 57998, 57999, 58000 } dnat to ${pcIP} comment "Sunshine UDP to PC"
tcp dport { 38010, 37989, 37984 } dnat to ${vmIP} comment "Sunshine TCP to VM"
udp dport { 37998, 37999, 38000 } dnat to ${vmIP} comment "Sunshine UDP to VM"
ip saddr ${secrets.cornIP} tcp dport { 9943, 9944 } dnat to ${vmIP} comment "ALVR TCP to VM"
ip saddr ${secrets.cornIP} udp dport { 9943, 9944 } dnat to ${vmIP} comment "ALVR UDP to VM"
}
chain POSTROUTING {
type nat hook postrouting priority 100; policy accept;
oifname "${netInt}" masquerade
}
'';
};
};
};
};
# Boot with compatibility for IP forwarding
boot.kernel.sysctl."net.ipv4.ip_forward" = 1;
# Enable AppArmor
security.apparmor.enable = true;
# Enable all manner of services
services = {
# SSH
openssh = {
enable = true;
settings = {
LogLevel = "VERBOSE";
PermitRootLogin = "no";
PrintLastLog = "no";
PasswordAuthentication = false;
};
ports = [ 2222 ];
};
# Login attempt lockout
fail2ban = {
enable = true;
maxretry = 5;
bantime = "5m";
ignoreIP = [ "${pcIP}" "${vmIP}" ];
};
# NFS server
nfs.server = {
enable = true;
exports = ''
/export/JimboNFS ${localSpan}.0/24(rw,no_subtree_check)
'';
};
# DDClient for Dynamic IPs
ddclient = {
enable = true;
protocol = "cloudflare";
use = "web, web=https://ipinfo.io/ip";
zone = "${secrets.jimDomain}";
username = "token";
passwordFile = "${pkgs.writeText "cloudflareapikey" secrets.flareApiKey}";
domains = [
"${secrets.jimDomain}"
"*.${secrets.jimDomain}"
"beta.${secrets.jimDomain}"
"git.${secrets.jimDomain}"
"john.${secrets.jimDomain}"
"mc.${secrets.jimDomain}"
"mx.${secrets.jimDomain}"
"panel.${secrets.jimDomain}"
"rtmp.${secrets.jimDomain}"
];
};
# Nginx reverse proxy
nginx = {
enable = true;
package = (pkgs.nginx.override {
modules = with pkgs.nginxModules; [ rtmp ];
});
recommendedTlsSettings = true;
recommendedOptimisation = true;
recommendedGzipSettings = true;
recommendedProxySettings = true;
virtualHosts = {
# Homepage redirect
"${secrets.jimDomain}" = {
enableACME = true;
addSSL = true;
root = "/var/www/jimweb";
locations = {
"/.well-known/matrix/client" = {
extraConfig = ''
default_type application/json;
return 200 '
{
"m.homeserver": {
"base_url": "https://matrix.${secrets.jimDomain}"
},
"m.identity_server": {
"base_url": "https://matrix.org"
},
"org.matrix.msc3575.proxy": {
"url": "https://matrix.${secrets.jimDomain}"
}
}';
'';
};
"/.well-known/matrix/server" = {
extraConfig = ''
default_type application/json;
return 200 '{"m.server": "matrix.${secrets.jimDomain}:443"}';
'';
};
};
};
# Nextcloud Proxy
"cloud.${secrets.jimDomain}" = {
enableACME = true;
addSSL = true;
locations."/" = {
proxyWebsockets = true;
extraConfig = "
location /.well-known/carddav {
return 301 $scheme://$host/remote.php/dav;
}
location /.well-known/caldav {
return 301 $scheme://$host/remote.php/dav;
}
";
};
};
# Vaultwarden Proxy
"warden.${secrets.jimDomain}" = {
enableACME = true;
forceSSL = true;
locations."/" = {
proxyPass = "http://127.0.0.1:8222";
proxyWebsockets = true;
};
};
# Recipes Proxy
"recipes.${secrets.jimDomain}" = {
enableACME = true;
forceSSL = true;
locations."/" = {
proxyPass = "http://127.0.0.1:5030";
proxyWebsockets = true;
};
};
# Bluemap Proxy
"bluemap.${secrets.jimDomain}" = {
enableACME = true;
forceSSL = true;
locations."/" = {
proxyPass = "http://127.0.0.1:31010";
proxyWebsockets = true;
};
};
# Gitea Proxy
"git.${secrets.jimDomain}" = {
enableACME = true;
forceSSL = true;
locations."/" = {
proxyPass = "http://127.0.0.1:3110";
proxyWebsockets = true;
};
};
# Pufferpanel Proxy
"panel.${secrets.jimDomain}" = {
enableACME = true;
forceSSL = true;
locations."/" = {
proxyPass = "http://127.0.0.1:5010";
proxyWebsockets = true;
};
};
# Matrix Proxy
"matrix.${secrets.jimDomain}" = {
enableACME = true;
forceSSL = true;
locations = {
"/".extraConfig = ''return 403;'';
"/client".proxyPass = "http://127.0.0.1:8009";
"/_matrix".proxyPass = "http://127.0.0.1:8008";
"/_matrix/client/unstable/org.matrix.msc3575/sync".proxyPass = "http://127.0.0.1:8009";
"/_synapse/client".proxyPass = "http://127.0.0.1:8008";
};
};
# Element Proxy
"chat.${secrets.jimDomain}" = {
enableACME = true;
addSSL = true;
root = "${pkgs.element-web}";
};
# Coturn Proxy
"turn.${secrets.jimDomain}" = {
enableACME = true;
forceSSL = true;
listen = [
{ addr = "0.0.0.0"; port = 80; ssl = false; }
];
locations."/".proxyPass = "http://127.0.0.1:1380";
};
# Radio Proxy
"radio.${secrets.jimDomain}" = {
enableACME = true;
forceSSL = true;
locations."/" = {
proxyPass = "http://127.0.0.1:255";
proxyWebsockets = true;
};
};
# Streaming proxy
"live.${secrets.jimDomain}" = {
enableACME = true;
forceSSL = true;
locations."/" = {
proxyPass = "http://127.0.0.1:8060";
proxyWebsockets = true;
};
};
# Mail certificate proxy
"mx.${secrets.jimDomain}" = {
enableACME = true;
forceSSL = true;
locations."/" = {
proxyPass = "http://127.0.0.1:1390";
proxyWebsockets = true;
};
};
# Add SSL to Lemmy
"lemmy.${secrets.jimDomain}" = {
enableACME = true;
forceSSL = true;
};
};
appendConfig = ''
rtmp {
server {
listen 1935;
chunk_size 4096;
allow publish all;
application stream {
record off;
live on;
allow play all;
hls on;
hls_path /var/www/jimweb/streams/hls;
hls_fragment_naming system;
hls_fragment 3;
hls_playlist_length 40;
}
}
}
'';
};
# Nextcloud server
nextcloud = {
enable = true;
package = pkgs.nextcloud29;
hostName = "cloud.${secrets.jimDomain}";
datadir = "/mnt/nextcloud";
https = true;
config = {
adminuser = "jimbo";
adminpassFile = "/mnt/nextcloud/password.txt";
};
settings = {
trusted_proxies = [ "127.0.0.1" ];
trusted_domains = [ "cloud.${secrets.jimDomain}" ];
overwriteprotocol = "https";
# Mailserver settings
mail_smtphost = "mx.${secrets.jimDomain}";
mail_domain = "${secrets.jimDomain}";
mail_from_address = "noreply";
mail_smtpauth = "true";
mail_smtpname = "noreply@${secrets.jimDomain}";
mail_smtppassword = secrets.noreplyPassword;
mail_smtpmode = "smtp";
mail_smtpport = 587;
};
};
# Vaultwarden password manager
vaultwarden = {
enable = true;
config = {
DOMAIN = "https://warden.${secrets.jimDomain}";
SIGNUPS_ALLOWED = false;
ROCKET_ADDRESS = "127.0.0.1";
ROCKET_PORT = 8222;
ROCKET_LOG = "critical";
# Smtp email
SMTP_HOST = "mx.${secrets.jimDomain}";
SMTP_FROM = "Jimbo's Vaultwarden <noreply@${secrets.jimDomain}>";
SMTP_FROM_NAME = "Vaultwarden";
SMTP_USERNAME = "noreply@${secrets.jimDomain}";
SMTP_PASSWORD = secrets.noreplyPassword;
SMTP_SECURITY = "starttls";
SMTP_PORT = 587;
SMTP_TIMEOUT = 15;
};
};
# Recipes
tandoor-recipes = {
enable = true;
port = 5030;
};
# Gitea
gitea = {
enable = true;
settings = {
server = {
DOMAIN = "git.${secrets.jimDomain}";
ROOT_URL = "https://git.${secrets.jimDomain}:443";
HTTP_PORT = 3110;
SSH_PORT = 2299;
START_SSH_SERVER = true;
};
mailer = {
ENABLED = true;
SMTP_ADDR = "mx.${secrets.jimDomain}";
FROM = "Jimbo's Git <noreply@${secrets.jimDomain}>";
USER = "noreply@${secrets.jimDomain}";
PASSWD = secrets.noreplyPassword;
PROTOCOL = "smtps";
};
service.REGISTER_EMAIL_CONFIRM = true;
};
};
# Pufferpannel for Minecraft
pufferpanel = {
enable = true;
environment = {
PUFFER_WEB_HOST = ":5010";
PUFFER_PANEL_SETTINGS_MASTERURL = "https://panel.${secrets.jimDomain}";
PUFFER_PANEL_EMAIL_PROVIDER = "smtp";
PUFFER_PANEL_EMAIL_HOST = "mx.${secrets.jimDomain}:587";
PUFFER_PANEL_EMAIL_FROM = "noreply@${secrets.jimDomain}";
PUFFER_PANEL_EMAIL_USERNAME = "noreply@${secrets.jimDomain}";
PUFFER_PANEL_EMAIL_PASSWORD = secrets.noreplyPassword;
};
extraPackages = with pkgs; [ bash curl gawk gnutar gzip ];
package = pkgs.buildFHSEnv {
name = "pufferpanel-fhs";
meta.mainProgram = "pufferpanel-fhs";
runScript = lib.getExe pkgs.pufferpanel;
targetPkgs = pkgs': with pkgs'; [ icu openssl zlib ];
};
};
# MariaDB
mysql = {
enable = true;
package = pkgs.mariadb;
dataDir = "/var/lib/mysql";
initialDatabases = [
{ name = "minecraft"; }
];
ensureUsers = [
{
name = "minecraft";
ensurePermissions = {
"minecraft.*" = "ALL PRIVILEGES";
};
}
];
};
# Owncast
owncast = {
enable = true;
port = 8060;
rtmp-port = 1945;
listen = "0.0.0.0";
};
# Coturn for VC
coturn = rec {
enable = true;
no-cli = true;
no-tcp-relay = true;
min-port = 49000;
max-port = 50000;
use-auth-secret = true;
realm = "turn.${secrets.jimDomain}";
static-auth-secret = "will be world readable for local users :(";
cert = "${config.security.acme.certs.${realm}.directory}/full.pem";
pkey = "${config.security.acme.certs.${realm}.directory}/key.pem";
};
# Synapse for Matrix clients
matrix-synapse = with config.services.coturn; {
enable = true;
settings = {
server_name = "${secrets.jimDomain}";
public_baseurl = "https://matrix.${secrets.jimDomain}";
suppress_key_server_warning = true;
# Set the network config
listeners = [{
# Client config
port = 8008;
bind_addresses = [ "::" "0.0.0.0" ];
resources = [ { compress = false; names = [ "client" "federation" ]; } ];
type = "http";
tls = false;
x_forwarded = true;
}];
# Enable smtp for password resets
email = {
notif_from = "Jimbo's Matrix <noreply@${secrets.jimDomain}>";
smtp_host = "mx.${secrets.jimDomain}";
smtp_user = "noreply@${secrets.jimDomain}";
smtp_pass = secrets.noreplyPassword;
enable_tls = true;
smtp_port = 587;
require_transport_security = true;
};
# Disable registration without email
registrations_require_3pid = [ "email" ];
# Allow only this range of emails
allowed_local_3pids = [{
medium = "email";
pattern = "^[^@]+@jimbosfiles\\.com$";
}];
# Set the type of database
database.name = "sqlite3";
# Allow account registration
enable_registration = true;
# General settings
url_preview_enabled = true;
max_upload_size = "50M";
report_stats = false;
# Turn settings
turn_uris = [
"turn:${realm}:3478?transport=udp"
"turn:${realm}:3478?transport=tcp"
];
turn_shared_secret = static-auth-secret;
turn_user_lifetime = "1h";
# Ratelimiting
burst_count = 15;
};
};
# Sliding sync proxy for Matrix
matrix-sliding-sync = let
matrixSecretFile = pkgs.writeText "matrixsecret" ''
SYNCV3_SECRET=${secrets.matrixSecret}
'';
in {
enable = true;
settings = {
SYNCV3_SERVER = "https://matrix.${secrets.jimDomain}";
SYNCV3_BINDADDR = "0.0.0.0:8009";
};
environmentFile = "${matrixSecretFile}";
};
# Mastodon
mastodon = {
enable = true;
localDomain = "social.${secrets.jimDomain}";
streamingProcesses = 4;
configureNginx = true;
smtp = {
createLocally = false;
host = "mx.${secrets.jimDomain}";
port = 587;
authenticate = true;
fromAddress = "Jimbo's Mastodon <noreply@${secrets.jimDomain}>";
user = "noreply@${secrets.jimDomain}";
passwordFile = pkgs.writeText "smtp_pass.txt" secrets.noreplyPassword;
};
};
# Lemmy forums
lemmy = {
enable = true;
nginx.enable = true;
database.createLocally = true;
settings = {
hostname = "lemmy.${secrets.jimDomain}";
email = {
smtp_server = "mx.${secrets.jimDomain}:587";
smtp_login = "noreply@${secrets.jimDomain}";
smtp_from_address = "Jimbo's Lemmy <noreply@${secrets.jimDomain}>";
smtp_password = secrets.noreplyPassword;
tls_type = "starttls";
};
};
};
# Roundcube mail server
roundcube = {
enable = true;
hostName = "mail.${secrets.jimDomain}";
extraConfig = ''
$config['smtp_server'] = "tls://${config.mailserver.fqdn}";
$config['smtp_user'] = "%u";
$config['smtp_pass'] = "%p";
'';
};
# Snowflake proxy for Tor
snowflake-proxy.enable = true;
# Fix a nonbuilding issue
logrotate.checkConfig = false;
# Force the mailserver to use a different redis port
redis.servers.rspamd.port = 1515;
};
# Force Nginx to work and be able to read+write the hls path
security.pam.services.nginx.setEnvironment = false;
systemd.services.nginx.serviceConfig = {
SupplementaryGroups = [ "shadow" ];
ReadWritePaths = [ "/var/www/jimweb/streams/hls/" ];
};
# Get certificates for Coturn
security.acme = {
acceptTerms = true;
defaults.email = secrets.jimEmail;
certs = {
${config.services.coturn.realm} = {
group = "turnserver";
postRun = "systemctl restart coturn.service";
};
};
};
# Configure the Element web server
nixpkgs.config.element-web.conf = {
default_server_config = {
"m.homeserver" = {
base_url = "https://matrix.${secrets.jimDomain}";
server_name = "matrix.${secrets.jimDomain}";
};
};
branding = {
#welcome_background_url = "https://staging.${secrets.jimDomain}/images/backgrounds/bloxelcom-sunset.jpg";
#auth_header_logo_url = "https://staging.${secrets.jimDomain}/images/logos/bloxelcom.png";
};
embedded_pages = {
home_url = "https://www.${secrets.jimDomain}/";
};
disable_custom_urls = true;
disable_guests = true;
default_theme = "dark";
};
# Enable Docker
virtualisation.docker = {
enable = true;
daemon.settings.log-driver = "json-file";
};
# Mail server
mailserver = rec {
enable = true;
enableManageSieve = true;
domains = [ "${secrets.jimDomain}" ];
fqdn = "mx.${secrets.jimDomain}";
certificateScheme = "acme-nginx";
localDnsResolver = false;
redis.port = 1515;
# A list of accounts.
# Generate passwords with nix-shell -p mkpasswd --run 'mkpasswd -sm bcrypt'
loginAccounts = {
"noreply@${secrets.jimDomain}" = {
hashedPasswordFile = pkgs.writeText "noreply" secrets.noreplyMailHash;
sendOnly = true;
};
"jimbo@${secrets.jimDomain}" = {
hashedPasswordFile = pkgs.writeText "jimbo" secrets.jimboMailHash;
aliases = [ "canada@${secrets.jimDomain}" "contact@${secrets.jimDomain}" ];
};
"lunamoonlight@${secrets.jimDomain}" = {
hashedPasswordFile = pkgs.writeText "luna" secrets.lunaMailHash;
aliases = [ "us@${secrets.jimDomain}" "contact@${secrets.jimDomain}" ];
};
"freecorn1854@${secrets.jimDomain}" = {
hashedPasswordFile = pkgs.writeText "freecorn" secrets.freecornMailHash;
aliases = [ "canada@${secrets.jimDomain}" "contact@${secrets.jimDomain}" ];
};
"tinyattack09@${secrets.jimDomain}" = {
hashedPasswordFile = pkgs.writeText "tiny" secrets.tinyMailHash;
};
};
};
# Determine the release version and allow auto-upgrades
system.stateVersion = "23.11";
system.autoUpgrade.enable = false;
}

View file

@ -1,88 +0,0 @@
{ config, lib, pkgs, modulesPath, ... }:
{
imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];
boot.initrd.availableKernelModules = [ "xhci_pci" "ehci_pci" "ahci" "nvme" "usbhid" "sd_mod" "sr_mod" ];
boot.kernelModules = [ "kvm-intel" ];
# Mounting options
fileSystems = {
"/" = {
device = "/dev/disk/by-uuid/8f81cab7-9381-4950-b77f-b85c5fdbad16";
fsType = "ext4";
};
"/boot" = {
device = "/dev/disk/by-uuid/2034-754A";
fsType = "vfat";
};
"/export/JimboNFS" = {
device = "/dev/disk/by-uuid/713fcd92-534c-4153-8e04-e0c6fe5f6a51";
fsType = "ext4";
noCheck = true;
};
"/home/jimbo/JimboNFS" = {
device = "/export/JimboNFS";
fsType = "none";
options = [ "bind" ];
};
# Atrocity of var bindmounts
"/mnt/nextcloud/data/JimboNFS" = {
device = "/export/JimboNFS";
fsType = "none";
options = [ "bind" ];
};
"/var/lib/bitwarden_rs" = {
device = "/export/JimboNFS/System/var/lib/bitwarden_rs";
fsType = "none";
options = [ "bind" ];
};
"/var/lib/gitea" = {
device = "/export/JimboNFS/System/var/lib/gitea";
fsType = "none";
options = [ "bind" ];
};
"/var/lib/matrix-synapse" = {
device = "/export/JimboNFS/System/var/lib/matrix-synapse";
fsType = "none";
options = [ "bind" ];
};
"/var/lib/nextcloud" = {
device = "/export/JimboNFS/System/var/lib/nextcloud";
fsType = "none";
options = [ "bind" ];
};
"/var/lib/owncast" = {
device = "/export/JimboNFS/System/var/lib/owncast";
fsType = "none";
options = [ "bind" ];
};
"/var/lib/docker/volumes/azuracast_station_data/_data/jimbops/media/Music" = {
device = "/export/JimboNFS/Music";
fsType = "none";
options = [ "bind" ];
};
"/var/lib/private/pufferpanel/servers" = {
device = "/export/JimboNFS/System/var/lib/pufferpanel/servers";
fsType = "none";
options = [ "bind" ];
};
"/var/lib/mastodon" = {
device = "/export/JimboNFS/System/var/lib/mastodon";
fsType = "none";
options = [ "bind" ];
};
};
swapDevices = [
{ device = "/dev/disk/by-uuid/ec422cad-bf93-4b15-b989-2c807f1073a4"; }
];
# Enables DHCP on each ethernet and wireless interface.
networking.useDHCP = lib.mkDefault true;
# Hardware settings
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
boot.swraid.enable = true;
}

View file

@ -1,544 +0,0 @@
{ config, pkgs, options, ... }:
let
# Terminal authenticator
auth = ''doas'';
# Neofetch main config
neoConf = ''
{
"$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json",
"logo": {
"source": "xenia",
"color": {
"1": "1;97",
"2": "red",
"3": "yellow"
}
},
"display": {
"separator": " \u001b[33m ",
"color": "red"
},
"modules": [
{
"type": "custom",
"format": "\u001b[1m"
},
{
"type": "host",
"format": "{5} {2}",
"key": "󰌢 "
},
{
"type": "cpu",
"key": " "
},
{
"type": "gpu",
"key": "󰢮 "
},
{
"type": "disk",
"folders": "/",
"key": " "
},
{
"type": "memory",
"format": "{/1}{-}{/}{/2}{-}{/}{} / {}",
"key": " "
},
{
"type": "display",
"compactType": "original",
"key": "󰍹 "
},
{
"type": "custom",
"format": "\u001b[1m"
},
{
"type": "os",
"format": "{3} {12}",
"key": "󰍛 "
},
{
"type": "kernel",
"format": "{1} {2}",
"key": " "
},
{
"type": "wm",
"key": " "
},
{
"type": "shell",
"key": " "
},
{
"type": "terminal",
"key": " "
},
{
"type": "packages",
"key": "󰆧 "
},
{
"type": "uptime",
"key": "󰅐 "
},
{
"type": "command",
"text": "date -d @$(stat -c %W /) '+%a %b %d %r %Z %Y'",
"key": "󰶡 "
},
{
"type": "custom",
"format": "\u001b[1m"
},
{
"type": "custom",
"format": "\u001b[90m󰮯 \u001b[31m󰊠 \u001b[32m󰊠 \u001b[33m󰊠 \u001b[34m󰊠 \u001b[35m󰊠 \u001b[36m󰊠 \u001b[37m󰊠"
}
]
}
'';
# Small Neofetch config
pFetch = let
smallConf = pkgs.writeText "smallconf.jsonc" ''
{
"$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json",
"logo": {
"source": "debian_small"
},
"modules": [
{
"type": "os",
"format": "{3} {12}",
"key": "󰍛 "
},
{
"type": "host",
"format": "{5}",
"key": "󰌢 "
},
{
"type": "kernel",
"format": "{1} {2}",
"key": " "
},
{
"type": "uptime",
"key": "󰅐 "
},
{
"type": "packages",
"key": "󰊠 "
},
{
"type": "memory",
"format": "{/1}{-}{/}{/2}{-}{/}{} / {}",
"key": " "
}
]
}
'';
in pkgs.writeScriptBin "pfetch"
''fastfetch --config ${smallConf}'';
# Rofi (terminal file browser) config
rangerConf = ''
set preview_script ~/.config/ranger/scope.sh
set preview_images true
set preview_images_method kitty
set dirname_in_tabs true
set cd_tab_fuzzy true
set autosave_bookmarks false
set show_hidden true
set wrap_scroll true
set column_ratios 2,2,4
set hidden_filter ^\.|\.(?:pyc|pyo|bak|swp)$|^lost\+found$|^__(py)?cache__$
default_linemode devicons
'';
# Choose how ranger opens stuff
rifleConf = ''
# Define the "editor" for text files as first action
mime ^text, label editor = nvim -- "$@"
mime ^text, label pager = "$PAGER" -- "$@"
!mime ^text, label editor, ext xml|json|csv|tex|py|pl|rb|js|sh|php = nvim -- "$@"
!mime ^text, label pager, ext xml|json|csv|tex|py|pl|rb|js|sh|php = "$PAGER" -- "$@"
# Websites
ext x?html?, has librewolf, X, flag f = librewolf -- "$@"
# Define the "editor" for text files as first action
mime ^text, label editor = "$EDITOR" -- "$@"
mime ^text, label pager = "$PAGER" -- "$@"
!mime ^text, label editor, ext xml|json|csv|tex|py|pl|rb|js|sh|php = "$EDITOR" -- "$@"
!mime ^text, label pager, ext xml|json|csv|tex|py|pl|rb|js|sh|php = "$PAGER" -- "$@"
# Misc files
ext 1 = man "$1"
ext exe = wine "$1"
ext msi = wine "$1"
name ^[mM]akefile$ = make
# Scripts
ext py = python -- "$1"
ext pl = perl -- "$1"
ext rb = ruby -- "$1"
ext js = node -- "$1"
ext sh = sh -- "$1"
ext php = php -- "$1"
# Audio and video
mime ^audio|ogg$, terminal, has mpv = mpv --no-audio-display -- "$@"
mime ^audio|ogg$, terminal, has mpv = mpv --shuffle --no-audio-display -- "$@"
mime ^video, has mpv, X, flag f = mpv -- "$@"
mime ^video, terminal, !X, has mpv = mpv -- "$@"
# Documents
ext pdf, has zathura, X, flag f = zathura -- "$@"
ext pdf, has xpdf, X, flag f = xpdf -- "$@"
ext pdf, has okular, X, flag f = okular -- "$@"
ext pptx?|od[dfgpst]|docx?|sxc|xlsx?|xlt|xlw|gnm|gnumeric, has libreoffice, X, flag f = libreoffice "$@"
# Images
mime ^image, has imv, X, flag f = imv -- "$@"
# Archives
ext 7z, has 7z = 7z -p l "$@" | "$PAGER"
ext 7z|ace|ar|arc|bz2?|cab|cpio|cpt|deb|dgc|dmg|gz, has 7z = 7z x -- "$@"
ext iso|jar|pkg|rar|shar|tar|tgz|xar|xpi|xz|zip, has 7z = 7z x -- "$@"
# Listing and extracting archives without atool:
ext tar|gz|bz2|xz, has tar = tar vvtf "$1" | "$PAGER"
ext tar|gz|bz2|xz, has tar = for file in "$@"; do tar vvxf "$file"; done
# Fonts
mime ^font, has fontforge, X, flag f = fontforge "$@"
# Generic file openers
label open, has xdg-open = xdg-open -- "$@"
# Define the editor for non-text files + pager as last action
!mime ^text, !ext xml|json|csv|tex|py|pl|rb|js|sh|php = ask
label editor, !mime ^text, !ext xml|json|csv|tex|py|pl|rb|js|sh|php = "$EDITOR" -- "$@"
label pager, !mime ^text, !ext xml|json|csv|tex|py|pl|rb|js|sh|php = "$PAGER" -- "$@"
# Execute a file as program/script.
mime application/x-executable = "$1"
'';
# Ranger's preview
rangerScope = ''
#!/usr/bin/env bash
set -o noclobber -o noglob -o nounset -o pipefail
IFS=$'\n'
# Script arguments
FILE_PATH="$1"
PV_WIDTH="$2"
PV_HEIGHT="$3"
IMAGE_CACHE_PATH="$4"
PV_IMAGE_ENABLED="$5"
FILE_EXTENSION=$(echo "$FILE_PATH" | rev | cut -d. -f1 | rev)
FILE_EXTENSION_LOWER=$(echo "$FILE_EXTENSION" | tr '[:upper:]' '[:lower:]')
# Settings
HIGHLIGHT_TABWIDTH=8
HIGHLIGHT_STYLE='pablo'
PYGMENTIZE_STYLE='autumn'
handle_extension() {
case "$FILE_EXTENSION_LOWER" in
# Archive
a|ace|alz|arc|arj|bz|bz2|cab|cpio|deb|gz|jar|lha|lz|lzh|lzma|lzo|\
rpm|rz|t7z|tar|tbz|tbz2|tgz|tlz|txz|tZ|tzo|war|xpi|xz|Z|zip)
atool --list -- "$FILE_PATH" && exit 5
bsdtar --list --file "$FILE_PATH" && exit 5
exit 1;;
rar)
unrar lt -p- -- "$FILE_PATH" && exit 5
exit 1;;
7z)
7z l -p -- "$FILE_PATH" && exit 5
exit 1;;
pdf)
pdftotext -l 10 -nopgbrk -q -- "$FILE_PATH" - && exit 5
exiftool "$FILE_PATH" && exit 5
exit 1;;
torrent)
transmission-show -- "$FILE_PATH" && exit 5
exit 1;;
# OpenDocument
odt|ods|odp|sxw)
odt2txt "$FILE_PATH" && exit 5
exit 1;;
esac
}
handle_image() {
local mimetype="$1"
case "$mimetype" in
# SVG
image/svg+xml)
convert "$FILE_PATH" "$IMAGE_CACHE_PATH" && exit 6
exit 1;;
# Image
image/*)
local orientation
orientation="$( identify -format '%[EXIF:Orientation]\n' -- "$FILE_PATH" )"
if [[ -n "$orientation" && "$orientation" != 1 ]]; then
convert -- "$FILE_PATH" -auto-orient "$IMAGE_CACHE_PATH" && exit 6
fi
exit 7;;
# Video
video/*)
# Thumbnail
ffmpegthumbnailer -i "$FILE_PATH" -o "$IMAGE_CACHE_PATH" -s 0 && exit 6
exit 1;;
# PDF
application/pdf)
pdftoppm -f 1 -l 1 \
-scale-to-x 1920 \
-scale-to-y -1 \
-singlefile \
-jpeg -tiffcompression jpeg \
-- "$FILE_PATH" "$(basename "$IMAGE_CACHE_PATH")" \
&& exit 6 || exit 1;;
esac
}
handle_mime() {
local mimetype="$1"
case "$mimetype" in
# Text
text/* | */xml)
exit 2;;
# Image
image/*)
exiftool "$FILE_PATH" && exit 5
exit 1;;
# Video and audio
video/* | audio/*)
mediainfo "$FILE_PATH" && exit 5
exiftool "$FILE_PATH" && exit 5
exit 1;;
esac
}
MIMETYPE="$( file --dereference --brief --mime-type -- "$FILE_PATH" )"
if [[ "$PV_IMAGE_ENABLED" == 'True' ]]; then
handle_image "$MIMETYPE"
fi
handle_extension
handle_mime "$MIMETYPE"
handle_fallback
exit 1
'';
# Ranger's bookmarks
rangerBookmarks = ''
# Local files
k:/home/jimbo/Downloads
c:/home/jimbo/.config
L:/home/jimbo/.local
D:/mnt
n:/etc/nixos
# Remote files
a:/home/jimbo/JimboNFS
K:/home/jimbo/JimboNFS/Downloads
p:/home/jimbo/JimboNFS/Photos
P:/home/jimbo/JimboNFS/Projects
V:/home/jimbo/JimboNFS/Videos/Random
m:/home/jimbo/JimboNFS/Music
s:/home/jimbo/JimboNFS/School
'';
in
{
# Define home manager programs and configs
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
users.jimbo = { config, pkgs, ... }: {
# Install user programs
home.packages = (with pkgs; [
fastfetch pFetch htop ranger tcptrack
]);
# Install Neovim and plugins
programs.neovim = {
enable = true;
defaultEditor = true;
vimAlias = true;
plugins = with pkgs.vimPlugins; [
# Vim theme
vim-airline vim-airline-themes
# Internal clipboard
vim-vsnip cmp-vsnip
# Autocomplete manager
lspkind-nvim
# Autocomplete plugins
cmp-nvim-lsp cmp-buffer cmp-path cmp-cmdline nvim-cmp
# Hex color visualizer and color theme
nvim-colorizer-lua vim-monokai-pro
];
extraConfig = ''
lua <<EOF
-- Set up nvim-cmp.
local cmp = require'cmp'
cmp.setup({
snippet = {
-- REQUIRED - you must specify a snippet engine
expand = function(args)
vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
end,
},
mapping = cmp.mapping.preset.insert({
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.abort(),
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
}),
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'vsnip' }
}, {
{ name = 'buffer' },
})
})
-- Use buffer source for `/` and `?`.
cmp.setup.cmdline({ '/', '?' }, {
mapping = cmp.mapping.preset.cmdline(),
sources = {
{ name = 'buffer' }
}
})
-- Use cmdline & path source for ':'.
cmp.setup.cmdline(':', {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = 'path' }
}, {
{ name = 'cmdline' }
})
})
EOF
colorscheme monokai_pro
let g:airline_theme='onedark'
let g:airline#extensions#tabline#enabled = 1
highlight Normal guibg=none ctermbg=235
highlight Visual guibg=#151515 ctermbg=238
highlight Pmenu guibg=#151515 ctermbg=238
highlight EndOfBuffer guibg=none ctermbg=235
highlight LineNr guibg=none ctermbg=none
lua require'colorizer'.setup()
set nu rnu
set termguicolors
set runtimepath+=/usr/share/vim/vimfiles
set mouse=a
set undofile
set undodir=$HOME/.local/share/nvim/undo
set undolevels=100
set undoreload=10000
nmap <C-x> :bnext<CR>
nmap <C-z> :bprev<CR>
'';
};
# Enable tmux
programs.tmux = {
enable = true;
extraConfig = ''
set -g mouse on
set -g base-index 1
set -g default-terminal "st-256color"
set -g history-limit 4096
set -g set-titles on
set -g set-titles-string "#T"
set -g status on
set -g status-left ""
set -g status-position bottom
set -g status-right "#[bg=brightblack]#[fg=dark_purple] #T "
set -g status-style "bg=black"
setw -g pane-base-index 1
setw -g window-status-format "#[bg=brightmagenta]#[fg=black] #I #[bg=brightblack]#[fg=white] #W "
setw -g window-status-current-format "#[bg=brightmagenta]#[fg=black] #I #[bg=white]#[fg=black] #W "
'';
};
# Start defining arbitrary files
home.file = {
# Fastfetch config
".config/fastfetch/config.jsonc".text = neoConf;
# Ranger config
".config/ranger/rc.conf".text = rangerConf;
".config/ranger/rifle.conf".text = rifleConf;
".config/ranger/scope.sh" = { text = rangerScope; executable = true; };
".config/ranger/plugins/devicons/devicons.py".source = "${pkgs.fetchurl {
url = "https://raw.githubusercontent.com/alexanderjeurissen/ranger_devicons/2c3c19dffb4238d01c74515c9eed5088066db243/devicons.py";
sha256 = "0girsranwhsgc6kcyh1mkwymx0bl14a2k5nzk3kyllb6ic48c33k";
}}";
".config/ranger/plugins/devicons/__init__.py".source = "${pkgs.fetchurl {
url = "https://raw.githubusercontent.com/alexanderjeurissen/ranger_devicons/2c3c19dffb4238d01c74515c9eed5088066db243/__init__.py";
sha256 = "1r086apw20ryxylqgnbynx7mzz779v1w0m40wghmmhlzw4x15fmr";
}}";
};
# Shell aliases
programs.zsh = {
enable = true;
autosuggestion.enable = true;
syntaxHighlighting.enable = true;
initExtra = ''
${pkgs.any-nix-shell}/bin/any-nix-shell zsh --info-right | source /dev/stdin; pfetch
setopt HIST_IGNORE_SPACE
setopt RM_STAR_WAIT
'';
oh-my-zsh = {
enable = true;
plugins = [ "git" ];
theme = "half-life";
};
shellAliases = {
# NixOS aliases
nixcfg = "nvim /etc/nixos/{configuration,jimbo,secrets,hardware-configuration}.nix";
nixswitch = "${auth} nixos-rebuild switch";
nixdate = "${auth} nixos-rebuild switch --upgrade-all";
nixclean = "${auth} nix-store --gc; nix-collect-garbage -d";
# Shortcut aliases
neo = "clear && fastfetch";
ip = "ip -c";
ls = "${pkgs.eza}/bin/eza -a --color=always --group-directories-first --icons";
cat = "${pkgs.bat}/bin/bat --paging never";
# Curl tools
myip = "curl ifconfig.co";
};
};
# Define current version
home.stateVersion = "23.11";
};
};
}