convert to proper module layout

This commit is contained in:
Noah Masur 2022-12-21 14:18:03 -07:00
parent bf1d2f1e9e
commit d040077d3a
95 changed files with 1196 additions and 895 deletions

View File

@ -59,9 +59,8 @@
program = "${
(import ../modules/neovim/package {
inherit pkgs;
colors = import ../modules/colorscheme/gruvbox/neovim-gruvbox.nix {
inherit pkgs;
};
colors =
import ../colorscheme/gruvbox/neovim-gruvbox.nix { inherit pkgs; };
})
}/bin/nvim";
};

View File

@ -104,7 +104,7 @@
fullName = "Noah Masur";
gitName = fullName;
gitEmail = "7386960+nmasur@users.noreply.github.com";
mailServer = "noahmasur.com";
mail.server = "noahmasur.com";
dotfilesRepo = "git@github.com:nmasur/dotfiles";
};
@ -154,9 +154,8 @@
neovim = let pkgs = import nixpkgs { inherit system overlays; };
in import ./modules/neovim/package {
inherit pkgs;
colors = import ./modules/colorscheme/gruvbox/neovim-gruvbox.nix {
inherit pkgs;
};
colors =
import ./colorscheme/gruvbox/neovim-gruvbox.nix { inherit pkgs; };
};
});

View File

@ -10,6 +10,7 @@ nixpkgs.lib.nixosSystem {
globals
home-manager.nixosModules.home-manager
{
physical = true;
networking.hostName = "desktop";
nixpkgs.overlays = [ nur.overlay ];
# Set registry to flake packages, used for nix X commands
@ -17,32 +18,32 @@ nixpkgs.lib.nixosSystem {
identityFile = "/home/${globals.user}/.ssh/id_ed25519";
gui.enable = true;
theme = {
colors = (import ../../modules/colorscheme/gruvbox).dark;
colors = (import ../../colorscheme/gruvbox).dark;
dark = true;
};
wallpaper = "${wallpapers}/gruvbox/road.jpg";
gtk.theme.name = nixpkgs.lib.mkDefault "Adwaita-dark";
passwordHash = nixpkgs.lib.fileContents ../../private/password.sha512;
media.enable = true;
firefox.enable = true;
kitty.enable = true;
"1password".enable = true;
discord.enable = true;
nautilus.enable = true;
obsidian.enable = true;
mail.aerc.enable = true;
mail.himalaya.enable = true;
gaming.enable = true;
gaming.steam.enable = true;
gaming.legendary.enable = true;
keybase.enable = true;
mullvad.enable = true;
nixlang.enable = true;
dotfiles.enable = true;
}
./hardware-configuration.nix
../common.nix
../../modules/hardware
../../modules/nixos
../../modules/graphical
../../modules/applications/media.nix
../../modules/applications/firefox.nix
../../modules/applications/kitty.nix
../../modules/applications/1password.nix
../../modules/applications/discord.nix
../../modules/applications/nautilus.nix
../../modules/applications/obsidian.nix
../../modules/mail
../../modules/gaming/steam.nix
../../modules/gaming/legendary.nix
../../modules/repositories/notes.nix
../../modules/services/keybase.nix
../../modules/services/mullvad.nix
../../modules/programming/nix.nix
../../modules
];
}

View File

@ -7,6 +7,7 @@ darwin.lib.darwinSystem {
system = "x86_64-darwin";
specialArgs = { };
modules = [
../../modules
(globals // {
user = "Noah.Masur";
gitName = "Noah-Masur_1701";
@ -14,30 +15,30 @@ darwin.lib.darwinSystem {
})
home-manager.darwinModules.home-manager
{
networking.hostName = "noah-masur-mac";
identityFile = "/Users/Noah.Masur/.ssh/id_ed25519";
gui.enable = true;
theme = {
colors = (import ../../modules/colorscheme/gruvbox).dark;
colors = (import ../../colorscheme/gruvbox).dark;
dark = true;
};
mailUser = globals.user;
networking.hostName = "noah-masur-mac";
mail.user = globals.user;
nixpkgs.overlays = [ firefox-darwin.overlay ] ++ overlays;
# Set registry to flake packages, used for nix X commands
nix.registry.nixpkgs.flake = nixpkgs;
mail.aerc.enable = true;
mail.himalaya.enable = true;
kitty.enable = true;
discord.enable = true;
firefox.enable = true;
dotfiles.enable = true;
nixlang.enable = true;
terraform.enable = true;
python.enable = true;
lua.enable = true;
kubernetes.enable = true;
"1password".enable = true;
}
../common.nix
../../modules/darwin
../../modules/mail
../../modules/applications/alacritty.nix
../../modules/applications/kitty.nix
../../modules/applications/discord.nix
../../modules/applications/firefox.nix
../../modules/repositories/notes.nix
../../modules/programming/nix.nix
../../modules/programming/terraform.nix
../../modules/programming/python.nix
../../modules/programming/lua.nix
../../modules/programming/kubernetes.nix
];
}

View File

@ -11,11 +11,14 @@ nixpkgs.lib.nixosSystem {
system = "aarch64-linux";
specialArgs = { };
modules = [
(removeAttrs globals [ "mailServer" ])
./hardware-configuration.nix
../../modules
(removeAttrs globals [ "mail.server" ])
home-manager.nixosModules.home-manager
{
server = true;
gui.enable = false;
theme = { colors = (import ../../modules/colorscheme/gruvbox).dark; };
theme = { colors = (import ../../colorscheme/gruvbox).dark; };
nixpkgs.overlays = overlays;
# FQDNs for various services
@ -33,7 +36,7 @@ nixpkgs.lib.nixosSystem {
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB+AbmjGEwITk5CK9y7+Rg27Fokgj9QEjgc9wST6MA3s";
# Nextcloud backup config
backupS3 = {
backup.s3 = {
endpoint = "s3.us-west-002.backblazeb2.com";
bucket = "noahmasur-backup";
accessKeyId = "0026b0e73b2e2c80000000005";
@ -72,20 +75,16 @@ nixpkgs.lib.nixosSystem {
# Grant access to Transmission directories from Jellyfin
users.users.jellyfin.extraGroups = [ "transmission" ];
# Proxy traffic with Cloudflare
cloudflare.enable = true;
# Setup Minecraft server
gaming.minecraft-server.enable = true;
# Clone dotfiles
dotfiles.enable = true;
}
./hardware-configuration.nix
../common.nix
../../modules/nixos
../../modules/hardware/server.nix
../../modules/services/sshd.nix
../../modules/services/calibre.nix
../../modules/services/jellyfin.nix
../../modules/services/nextcloud.nix
../../modules/services/cloudflare.nix
../../modules/services/transmission.nix
../../modules/services/prometheus.nix
../../modules/services/vaultwarden.nix
../../modules/services/gitea.nix
../../modules/gaming/minecraft-server.nix
];
}

View File

@ -10,6 +10,7 @@ nixpkgs.lib.nixosSystem {
globals
wsl.nixosModules.wsl
home-manager.nixosModules.home-manager
../../modules
{
networking.hostName = "wsl";
# Set registry to flake packages, used for nix X commands
@ -17,7 +18,7 @@ nixpkgs.lib.nixosSystem {
identityFile = "/home/${globals.user}/.ssh/id_ed25519";
gui.enable = false;
theme = {
colors = (import ../../modules/colorscheme/gruvbox).dark;
colors = (import ../../colorscheme/gruvbox).dark;
dark = true;
};
passwordHash = nixpkgs.lib.fileContents ../../private/password.sha512;
@ -30,13 +31,12 @@ nixpkgs.lib.nixosSystem {
interop.includePath =
false; # Including Windows PATH will slow down Neovim command mode
};
mail.aerc.enable = true;
mail.himalaya.enable = true;
dotfiles.enable = true;
nixlang.enable = true;
lua.enable = true;
}
../common.nix
../../modules/wsl
../../modules/nixos
../../modules/mail
../../modules/repositories/notes.nix
../../modules/programming/nix.nix
../../modules/programming/lua.nix
];
}

View File

@ -1,6 +1,16 @@
{ config, pkgs, lib, ... }: {
config = lib.mkIf config.gui.enable {
options = {
"1password" = {
enable = lib.mkEnableOption {
description = "Enable 1Password.";
default = false;
};
};
};
config = lib.mkIf
(config.gui.enable && config."1password".enable && pkgs.stdenv.isLinux) {
unfreePackages = [ "1password" "_1password-gui" ];
home-manager.users.${config.user} = {
home.packages = with pkgs; [ _1password-gui ];

View File

@ -1,6 +1,15 @@
{ config, pkgs, lib, ... }: {
config = lib.mkIf config.gui.enable {
options = {
alacritty = {
enable = lib.mkEnableOption {
description = "Enable Alacritty.";
default = false;
};
};
};
config = lib.mkIf (config.gui.enable && config.alacritty.enable) {
home-manager.users.${config.user} = {
xsession.windowManager.i3.config.terminal = "alacritty";
programs.rofi.terminal = "${pkgs.alacritty}/bin/alacritty";

View File

@ -1,6 +1,15 @@
{ config, pkgs, lib, ... }: {
config = lib.mkIf config.gui.enable {
options = {
calibre = {
enable = lib.mkEnableOption {
description = "Enable Calibre.";
default = false;
};
};
};
config = lib.mkIf (config.gui.enable && config.calibre.enable) {
home-manager.users.${config.user} = {
home.packages = with pkgs; [ calibre ];
# home.sessionVariables = { CALIBRE_USE_DARK_PALETTE = 1; };

View File

@ -1,6 +1,15 @@
{ config, pkgs, lib, ... }: {
config = lib.mkIf config.gui.enable {
options = {
discord = {
enable = lib.mkEnableOption {
description = "Enable Discord.";
default = false;
};
};
};
config = lib.mkIf (config.gui.enable && config.discord.enable) {
unfreePackages = [ "discord" ];
home-manager.users.${config.user} = {
home.packages = with pkgs; [ discord ];

View File

@ -1,13 +1,26 @@
{ config, pkgs, lib, ... }:
{
config = lib.mkIf config.gui.enable {
unfreePackages = [ "onepassword-password-manager" "okta-browser-plugin" ];
options = {
firefox = {
enable = lib.mkEnableOption {
description = "Enable Firefox.";
default = false;
};
};
};
config = lib.mkIf (config.gui.enable && config.firefox.enable) {
unfreePackages = [
(lib.mkIf config."1password".enable "onepassword-password-manager")
"okta-browser-plugin"
];
home-manager.users.${config.user} = {
programs.firefox = rec {
programs.firefox = {
enable = true;
package =
if pkgs.stdenv.isDarwin then pkgs.firefox-bin else pkgs.firefox;
@ -17,7 +30,7 @@
multi-account-containers
facebook-container
temporary-containers
onepassword-password-manager
(lib.mkIf config."1password".enable onepassword-password-manager)
okta-browser-plugin
sponsorblock
reddit-enhancement-suite

View File

@ -1,6 +1,15 @@
{ config, pkgs, lib, ... }: {
config = lib.mkIf config.gui.enable {
options = {
kitty = {
enable = lib.mkEnableOption {
description = "Enable Kitty.";
default = false;
};
};
};
config = lib.mkIf (config.gui.enable && config.kitty.enable) {
home-manager.users.${config.user} = {
# xsession.windowManager.i3.config.terminal = "kitty";
# programs.rofi.terminal = "${pkgs.kitty}/bin/kitty";

View File

@ -1,6 +1,15 @@
{ config, pkgs, lib, ... }: {
config = lib.mkIf config.gui.enable {
options = {
media = {
enable = lib.mkEnableOption {
description = "Enable media programs.";
default = false;
};
};
};
config = lib.mkIf (config.gui.enable && config.media.enable) {
home-manager.users.${config.user}.home.packages = with pkgs; [
mpv # Video viewer
sxiv # Image viewer

View File

@ -1,7 +1,16 @@
{ config, pkgs, lib, ... }: {
options = {
nautilus = {
enable = lib.mkEnableOption {
description = "Enable Nautilus file manager.";
default = false;
};
};
};
# Install Nautilus file manager
config = lib.mkIf config.gui.enable {
config = lib.mkIf (config.gui.enable && config.nautilus.enable) {
home-manager.users.${config.user} = {
home.packages = with pkgs; [
gnome.nautilus

View File

@ -1,6 +1,15 @@
{ config, pkgs, lib, ... }: {
config = lib.mkIf config.gui.enable {
options = {
obsidian = {
enable = lib.mkEnableOption {
description = "Enable Obsidian.";
default = false;
};
};
};
config = lib.mkIf (config.gui.enable && config.obsidian.enable) {
unfreePackages = [ "obsidian" ];
home-manager.users.${config.user} = {
home.packages = with pkgs; [ obsidian ];

View File

@ -1,6 +1,15 @@
{ config, pkgs, lib, ... }: {
config = lib.mkIf config.gui.enable {
options = {
qbittorrent = {
enable = lib.mkEnableOption {
description = "Enable qBittorrent.";
default = false;
};
};
};
config = lib.mkIf (config.gui.enable && config.qbittorrent.enable) {
home-manager.users.${config.user} = {

View File

@ -1,13 +0,0 @@
local M = {}
M.packer = function(use)
use({
"lifepillar/vim-gruvbox8",
config = function()
vim.g.gruvbox_italicize_strings = 0
vim.cmd("colorscheme gruvbox8")
end,
})
end
return M

View File

@ -1,7 +1,7 @@
{ config, pkgs, lib, ... }: {
# MacOS-specific settings for Alacritty
home-manager.users.${config.user} = {
home-manager.users.${config.user} = lib.mkIf pkgs.stdenv.isDarwin {
programs.alacritty.settings = {
font.size = lib.mkForce 20.0;
shell.program = "${pkgs.fish}/bin/fish";

View File

@ -1,6 +1,6 @@
{ config, pkgs, ... }: {
{ config, pkgs, lib, ... }: {
home-manager.users.${config.user} = {
home-manager.users.${config.user} = lib.mkIf pkgs.stdenv.isDarwin {
home.packages = with pkgs;
[ (nerdfonts.override { fonts = [ "VictorMono" ]; }) ];

View File

@ -1,7 +1,9 @@
{ config, pkgs, ... }: {
{ config, pkgs, lib, ... }: {
# Hammerspoon - MacOS custom automation scripting
config = lib.mkIf pkgs.stdenv.isDarwin {
home-manager.users.${config.user} = {
xdg.configFile."hammerspoon/init.lua".source = ./hammerspoon/init.lua;
xdg.configFile."hammerspoon/Spoons/ControlEscape.spoon".source =
@ -25,4 +27,6 @@
defaults write org.hammerspoon.Hammerspoon MJConfigFile "~/.config/hammerspoon/init.lua"
'';
};
}

View File

@ -1,6 +1,7 @@
{ config, ... }: {
{ config, pkgs, lib, ... }: {
# Homebrew - Mac-specific packages that aren't in Nix
config = lib.mkIf pkgs.stdenv.isDarwin {
# Requires Homebrew to be installed
system.activationScripts.preUserActivation.text = ''
@ -50,4 +51,6 @@
};
};
}

View File

@ -1,7 +1,7 @@
{ config, pkgs, lib, ... }: {
# MacOS-specific settings for Kitty
home-manager.users.${config.user} = {
home-manager.users.${config.user} = lib.mkIf pkgs.stdenv.isDarwin {
programs.kitty = {
darwinLaunchOptions = [ "--start-as=fullscreen" ];
font.size = lib.mkForce 20;

View File

@ -1,9 +1,11 @@
{ config, ... }: {
{ config, pkgs, lib, ... }: {
config = lib.mkIf pkgs.stdenv.isDarwin {
networking = {
computerName = "${config.fullName}'\\''s Mac";
# Adjust if necessary
# hostName = "";
};
};
}

View File

@ -1,6 +1,6 @@
{ config, pkgs, lib, ... }: {
home-manager.users.${config.user} = {
home-manager.users.${config.user} = lib.mkIf pkgs.stdenv.isDarwin {
programs.fish = {
shellAbbrs = {

View File

@ -1,4 +1,6 @@
{ pkgs, ... }: {
{ pkgs, lib, ... }: {
config = lib.mkIf pkgs.stdenv.isDarwin {
services.nix-daemon.enable = true;
@ -179,4 +181,6 @@
};
};
}

View File

@ -1,6 +1,8 @@
{ config, pkgs, ... }: {
{ config, pkgs, lib, ... }: {
home-manager.users.${config.user} = {
options.tmux.enable = lib.mkEnableOption "Tmux terminal multiplexer";
home-manager.users.${config.user} = lib.mkIf config.tmux.enable {
programs.tmux = {
enable = true;

View File

@ -1,5 +1,7 @@
{ config, pkgs, lib, ... }: {
config = lib.mkIf pkgs.stdenv.isDarwin {
users.users."${config.user}" = {
# macOS user
home = config.homePath;
@ -9,7 +11,11 @@
# Used for aerc
home-manager.users.${config.user} = {
home.sessionVariables = { XDG_CONFIG_HOME = "${config.homePath}/.config"; };
home.sessionVariables = {
XDG_CONFIG_HOME = "${config.homePath}/.config";
};
};
};
}

View File

@ -15,7 +15,7 @@ let
in {
home-manager.users.${config.user} = {
home-manager.users.${config.user} = lib.mkIf pkgs.stdenv.isDarwin {
home.packages = with pkgs; [
# visidata # CSV inspector

View File

@ -1,7 +1,20 @@
{ config, lib, pkgs, ... }: {
imports =
[ ../modules/shell ../modules/neovim ../modules/repositories/dotfiles.nix ];
imports = [
./applications
./darwin
./gaming
./graphical
./hardware
./mail
./neovim
./nixos
./programming
./repositories
./services
./shell
./wsl
];
options = {
user = lib.mkOption {
@ -36,7 +49,7 @@
colors = lib.mkOption {
type = lib.types.attrs;
description = "Base16 color scheme.";
default = (import ../modules/colorscheme/gruvbox).dark;
default = (import ../colorscheme/gruvbox).dark;
};
dark = lib.mkOption {
type = lib.types.bool;

View File

@ -1,6 +1,16 @@
{ config, ... }: {
{ config, pkgs, lib, ... }: {
config = {
imports = [
./leagueoflegends.nix
./legendary.nix
./lutris.nix
./minecraft-server.nix
./steam.nix
];
options.gaming.enable = lib.mkEnableOption "Enable gaming features.";
config = lib.mkIf (config.gaming.enable && pkgs.stdenv.isLinux) {
hardware.opengl = {
enable = true;
driSupport32Bit = true;

View File

@ -1,8 +1,10 @@
{ config, pkgs, lib, ... }: {
options.gaming.leagueoflegends = lib.mkEnableOption "League of Legends";
options.gaming.leagueoflegends.enable =
lib.mkEnableOption "League of Legends";
config = lib.mkIf config.gaming.leagueoflegends {
config =
lib.mkIf (config.gaming.leagueoflegends.enable && pkgs.stdenv.isLinux) {
# League of Legends anti-cheat requirement
boot.kernel.sysctl = { "abi.vsyscall32" = 0; };

View File

@ -4,9 +4,10 @@ let home-packages = config.home-manager.users.${config.user}.home.packages;
in {
imports = [ ./. ];
options.gaming.legendary.enable =
lib.mkEnableOption "Legendary Epic Games launcher.";
config = {
config = lib.mkIf config.gaming.legendary.enable {
environment.systemPackages = with pkgs; [
legendary-gl
rare # GUI for Legendary (not working)

View File

@ -1,8 +1,8 @@
{ config, pkgs, lib, ... }: {
options.gaming.lutris = lib.mkEnableOption "Lutris";
options.gaming.lutris.enable = lib.mkEnableOption "Lutris game installer.";
config = lib.mkIf config.gaming.lutris {
config = lib.mkIf config.gaming.lutris.enable {
environment.systemPackages = with pkgs; [
lutris
amdvlk # Vulkan drivers (probably already installed)

View File

@ -1,4 +1,4 @@
{ pkgs, ... }:
{ config, pkgs, lib, ... }:
let
@ -9,6 +9,11 @@ let
in {
options.gaming.minecraft-server.enable =
lib.mkEnableOption "Minecraft Server.";
config = lib.mkIf config.gaming.minecraft-server.enable {
unfreePackages = [ "minecraft-server" ];
services.minecraft-server = {
@ -142,4 +147,6 @@ in {
'';
};
};
}

View File

@ -1,8 +1,8 @@
{ config, pkgs, lib, ... }: {
imports = [ ./. ];
options.gaming.steam.enable = lib.mkEnableOption "Steam game launcher.";
config = {
config = lib.mkIf (config.gaming.steam.enable && pkgs.stdenv.isLinux) {
hardware.steam-hardware.enable = true;
unfreePackages = [ "steam" "steam-original" "steamcmd" "steam-run" ];
environment.systemPackages = with pkgs; [

View File

@ -2,7 +2,9 @@
{
config = lib.mkIf config.services.xserver.enable {
options.gui.dmenu.enable = lib.mkEnableOption "dmenu launcher.";
config = lib.mkIf (config.services.xserver.enable && config.dmenu.enable) {
home-manager.users.${config.user}.home.packages = [ pkgs.dmenu ];
gui.launcherCommand = "${pkgs.dmenu}/bin/dmenu_run";

View File

@ -4,7 +4,7 @@ let fontName = "Victor Mono";
in {
config = lib.mkIf config.gui.enable {
config = lib.mkIf (config.gui.enable && pkgs.stdenv.isLinux) {
fonts.fonts = with pkgs; [
victor-mono # Used for Vim and Terminal

View File

@ -9,7 +9,7 @@ let
in {
config = {
config = lib.mkIf pkgs.stdenv.isLinux {
services.xserver.windowManager = {
i3 = {

View File

@ -1,6 +1,6 @@
{ config, lib, ... }: {
{ config, pkgs, lib, ... }: {
config = lib.mkIf (config.services.xserver.enable) {
config = lib.mkIf (pkgs.stdenv.isLinux && config.services.xserver.enable) {
home-manager.users.${config.user} = {
services.picom = {

View File

@ -1,6 +1,6 @@
{ config, pkgs, lib, ... }: {
config = lib.mkIf config.services.xserver.enable {
config = lib.mkIf (pkgs.stdenv.isLinux && config.services.xserver.enable) {
toggleBarCommand = "polybar-msg cmd toggle";

View File

@ -2,7 +2,7 @@
{
config = lib.mkIf config.services.xserver.enable {
config = lib.mkIf (pkgs.stdenv.isLinux && config.services.xserver.enable) {
home-manager.users.${config.user} = {

View File

@ -15,11 +15,13 @@
};
config = let
gtkTheme = {
name = config.gtk.theme.name;
package = pkgs."${config.gtk.theme.package}";
};
in lib.mkIf config.gui.enable {
in lib.mkIf (pkgs.stdenv.isLinux && config.gui.enable) {
# Enable the X11 windowing system.
services.xserver = {

View File

@ -30,7 +30,7 @@ let
in {
config = lib.mkIf config.gui.enable {
config = lib.mkIf (pkgs.stdenv.isLinux && config.gui.enable) {
sound.enable = true;
# Enable PipeWire

View File

@ -1,6 +1,6 @@
{ config, ... }: {
{ config, pkgs, lib, ... }: {
boot.loader = {
boot.loader = lib.mkIf (config.physical && pkgs.stdenv.isLinux) {
grub = {
enable = true;

View File

@ -1,4 +1,4 @@
{ ... }: {
{ lib, ... }: {
imports = [
./audio.nix
@ -11,4 +11,9 @@
./wifi.nix
];
options = {
physical = lib.mkEnableOption "Whether this machine is a physical device.";
server = lib.mkEnableOption "Whether this machine is a server.";
};
}

View File

@ -3,7 +3,8 @@
# Timezone required for Redshift schedule
imports = [ ../nixos/timezone.nix ];
config = lib.mkIf config.gui.enable {
config =
lib.mkIf (config.gui.enable && config.physical && pkgs.stdenv.isLinux) {
environment.systemPackages = with pkgs;
[

View File

@ -1,6 +1,7 @@
{ config, pkgs, lib, ... }: {
config = lib.mkIf config.gui.enable {
config =
lib.mkIf (config.gui.enable && config.physical && pkgs.stdenv.isLinux) {
# Mouse customization
services.ratbagd.enable = true;

View File

@ -1,4 +1,6 @@
{ ... }: {
{ config, pkgs, lib, ... }: {
config = lib.mkIf (config.physical && pkgs.stdenv.isLinux) {
# The global useDHCP flag is deprecated, therefore explicitly set to false here.
# Per-interface useDHCP will be mandatory in the future, so this generated config
@ -7,4 +9,6 @@
networking.interfaces.enp0s31f6.useDHCP = true;
networking.interfaces.wlp3s0.useDHCP = true;
};
}

View File

@ -1,7 +1,11 @@
{ config, ... }: {
{ config, pkgs, lib, ... }: {
config = lib.mkIf (pkgs.stdenv.isLinux && config.server) {
# Servers need a bootloader or they won't start
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
};
}

View File

@ -1,8 +1,12 @@
{ ... }: {
{ config, pkgs, lib, ... }: {
config = lib.mkIf (config.physical && pkgs.stdenv.isLinux) {
# Prevent wake from keyboard
powerManagement.powerDownCommands = ''
for wakeup in /sys/bus/usb/devices/1-*/power/wakeup; do echo disabled > $wakeup; done
'';
};
}

View File

@ -1,4 +1,6 @@
{ ... }: {
{ config, pkgs, lib, ... }: {
config = lib.mkIf (config.physical && config.isLinux) {
# Enables wireless support via wpa_supplicant.
networking.wireless.enable = true;
@ -6,4 +8,6 @@
# Allows the user to control the WiFi settings.
networking.wireless.userControlled.enable = true;
};
}

View File

@ -1,6 +1,8 @@
{ config, pkgs, ... }: {
{ config, pkgs, lib, ... }: {
config = {
options.mail.aerc.enable = lib.mkEnableOption "Aerc email.";
config = lib.mkIf config.mail.aerc.enable {
home-manager.users.${config.user} = {

View File

@ -3,18 +3,18 @@
imports = [ ./himalaya.nix ./aerc.nix ];
options = {
mailUser = lib.mkOption {
mail.user = lib.mkOption {
type = lib.types.str;
description = "User name for the email address.";
default = config.user;
};
mailServer = lib.mkOption {
mail.server = lib.mkOption {
type = lib.types.str;
description = "Server name for the email address.";
};
};
config = {
config = lib.mkIf (config.mail.user != null && config.mail.server != null) {
home-manager.users.${config.user} = {
programs.mbsync = { enable = true; };
@ -25,13 +25,13 @@
accounts.email = {
maildirBasePath = "${config.homePath}/mail";
accounts = {
home = let address = "${config.mailUser}@${config.mailServer}";
home = let address = "${config.mail.user}@${config.mail.server}";
in {
userName = address;
realName = config.fullName;
primary = true;
inherit address;
aliases = map (mailUser: "${mailUser}@${config.mailServer}") [
aliases = map (user: "${user}@${config.mail.server}") [
"me"
"hey"
"admin"

View File

@ -1,6 +1,8 @@
{ config, ... }: {
{ config, lib, ... }: {
config = {
options.mail.himalaya.enable = lib.mkEnableOption "Himalaya email.";
config = lib.mkIf config.mail.himalaya.enable {
home-manager.users.${config.user} = {

View File

@ -9,6 +9,9 @@ let
in {
options.neovim.enable = lib.mkEnableOption "Neovim.";
config = lib.mkIf config.neovim.enable {
home-manager.users.${config.user} =
{
@ -36,4 +39,6 @@ in {
# # Used for icons in Vim
# fonts.fonts = with pkgs; [ nerdfonts ];
};
}

View File

@ -1,9 +1,13 @@
{ config, ... }: {
{ config, pkgs, lib, ... }: {
imports = [ ./user.nix ./timezone.nix ./doas.nix ];
config = lib.mkIf pkgs.stdenv.isLinux {
# Pin a state version to prevent warnings
system.stateVersion =
config.home-manager.users.${config.user}.home.stateVersion;
};
}

View File

@ -1,6 +1,8 @@
# Replace sudo with doas
{ config, ... }: {
{ config, pkgs, lib, ... }: {
config = lib.mkIf pkgs.stdenv.isLinux {
security = {
@ -27,4 +29,7 @@
home-manager.users.${config.user}.programs.fish.shellAliases = {
sudo = "doas";
};
};
}

View File

@ -1,4 +1,6 @@
{ ... }: {
{ config, pkgs, lib, ... }: {
config = lib.mkIf pkgs.stdenv.isLinux {
# Service to determine location for time zone
services.geoclue2.enable = true;
@ -12,4 +14,6 @@
services.geoclue2.appConfig.localtimed.isSystem = true;
services.geoclue2.appConfig.localtimed.isAllowed = true;
};
}

View File

@ -1,4 +1,4 @@
{ config, lib, ... }: {
{ config, pkgs, lib, ... }: {
options = {
@ -11,7 +11,7 @@
};
config = {
config = lib.mkIf (pkgs.stdenv.isLinux) {
# Allows us to declaritively set password
users.mutableUsers = false;

View File

@ -0,0 +1,12 @@
{ config, pkgs, lib, ... }: {
imports = [
./haskell.nix
./kubernetes.nix
./lua.nix
./nix.nix
./python.nix
./terraform.nix
];
}

View File

@ -1,8 +1,14 @@
{ ... }: {
{ config, pkgs, lib, ... }: {
options.haskell.enable = lib.mkEnableOption "Haskell programming language.";
config = lib.mkIf config.haskell.enable {
# Binary Cache for Haskell.nix
nix.settings.trusted-public-keys =
[ "hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=" ];
nix.settings.substituters = [ "https://cache.iog.io" ];
};
}

View File

@ -1,5 +1,8 @@
{ config, pkgs, ... }: {
{ config, pkgs, lib, ... }: {
options.kubernetes.enable = lib.mkEnableOption "Kubernetes tools.";
config = lib.mkIf config.kubernetes.enable {
home-manager.users.${config.user} = {
home.packages = with pkgs; [
@ -137,4 +140,6 @@
};
};
}

View File

@ -1,8 +1,12 @@
{ config, pkgs, ... }: {
{ config, pkgs, lib, ... }: {
options.lua.enable = lib.mkEnableOption "Lua programming language.";
config = lib.mkIf config.lua.enable {
home-manager.users.${config.user}.home.packages = with pkgs; [
stylua # Lua formatter
sumneko-lua-language-server # Lua LSP
];
};
}

View File

@ -1,4 +1,8 @@
{ config, pkgs, ... }: {
{ config, pkgs, lib, ... }: {
options.nixlang.enable = lib.mkEnableOption "Nix programming language.";
config = lib.mkIf config.nixlang.enable {
home-manager.users.${config.user} = {
@ -9,4 +13,6 @@
};
};
}

View File

@ -1,4 +1,8 @@
{ config, pkgs, ... }: {
{ config, pkgs, lib, ... }: {
options.python.enable = lib.mkEnableOption "Python programming language.";
config = lib.mkIf config.python.enable {
home-manager.users.${config.user} = {
@ -13,4 +17,6 @@
};
};
}

View File

@ -1,4 +1,8 @@
{ config, pkgs, ... }: {
{ config, pkgs, lib, ... }: {
options.terraform.enable = lib.mkEnableOption "Terraform tools.";
config = lib.mkIf config.terraform.enable {
home-manager.users.${config.user} = {
programs.fish.shellAbbrs = {
@ -13,4 +17,6 @@
};
};
}

View File

@ -0,0 +1,5 @@
{ ... }: {
imports = [ ./dotfiles.nix ./notes.nix ];
}

View File

@ -1,5 +1,9 @@
{ config, pkgs, lib, ... }: {
options.dotfiles.enable = lib.mkEnableOption "Clone dotfiles.";
config = lib.mkIf config.dotfiles.enable {
home-manager.users.${config.user} = {
home.activation = {
@ -21,4 +25,6 @@
};
};
}

View File

@ -1,21 +1,22 @@
{ config, pkgs, lib, ... }: {
imports = [ ./secrets.nix ];
options = {
backupS3 = {
backup.s3 = {
endpoint = lib.mkOption {
type = lib.types.str;
description = "S3 endpoint for backups";
default = null;
};
bucket = lib.mkOption {
type = lib.types.str;
description = "S3 bucket for backups";
default = null;
};
accessKeyId = lib.mkOption {
type = lib.types.str;
description = "S3 access key ID for backups";
default = null;
};
};

View File

@ -1,18 +1,20 @@
{ config, pkgs, lib, ... }: {
options = {
caddyRoutes = lib.mkOption {
caddy.enable = lib.mkEnableOption "Caddy reverse proxy.";
caddy.routes = lib.mkOption {
type = lib.types.listOf lib.types.attrs;
description = "Caddy JSON routes for http servers";
default = [ ];
};
caddyBlocks = lib.mkOption {
caddy.blocks = lib.mkOption {
type = lib.types.listOf lib.types.attrs;
description = "Caddy JSON error blocks for http servers";
default = [ ];
};
};
config = {
config = lib.mkIf (config.caddy.enable && config.caddy.routes != [ ]) {
services.caddy = {
enable = true;
@ -20,8 +22,8 @@
configFile = pkgs.writeText "Caddyfile" (builtins.toJSON {
apps.http.servers.main = {
listen = [ ":443" ];
routes = config.caddyRoutes;
errors.routes = config.caddyBlocks;
routes = config.caddy.routes;
errors.routes = config.caddy.blocks;
};
});

View File

@ -1,15 +1,14 @@
{ config, pkgs, lib, ... }: {
imports = [ ./caddy.nix ./backups.nix ];
options = {
bookServer = lib.mkOption {
type = lib.types.str;
description = "Hostname for Calibre library";
default = null;
};
};
config = {
config = lib.mkIf config.bookServer != null {
services.calibre-web = {
enable = true;
@ -31,7 +30,7 @@
})
];
caddyRoutes = [{
caddy.routes = [{
match = [{ host = [ config.bookServer ]; }];
handle = [{
handler = "reverse_proxy";

View File

@ -1,6 +1,6 @@
# This module is necessary for hosts that are serving through Cloudflare.
{ ... }:
{ config, lib, ... }:
let
@ -36,12 +36,12 @@ let
in {
imports = [ ./caddy.nix ];
options.cloudflare.enable = lib.mkEnableOption "Use Cloudflare.";
config = {
config = lib.mkIf config.cloudflare.enable {
# Forces Caddy to error if coming from a non-Cloudflare IP
caddyBlocks = [{
caddy.blocks = [{
match = [{ not = [{ remote_ip.ranges = cloudflareIpRanges; }]; }];
handle = [{
handler = "static_response";

View File

@ -0,0 +1,25 @@
{ ... }: {
imports = [
./backups.nix
./caddy.nix
./calibre.nix
./cloudflare.nix
./gitea.nix
./gnupg.nix
./honeypot.nix
./jellyfin.nix
./keybase.nix
./mullvad.nix
./n8n.nix
./netdata.nix
./nextcloud.nix
./prometheus.nix
./secrets.nix
./sshd.nix
./transmission.nix
./vaultwarden.nix
./wireguard.nix
];
}

View File

@ -4,18 +4,17 @@ let giteaPath = "/var/lib/gitea"; # Default service directory
in {
imports = [ ./caddy.nix ./backups.nix ];
options = {
giteaServer = lib.mkOption {
description = "Hostname for Gitea.";
type = lib.types.str;
default = null;
};
};
config = {
config = lib.mkIf config.giteaServer != null {
services.gitea = {
enable = true;
httpPort = 3001;
@ -47,7 +46,7 @@ in {
networking.firewall.allowedTCPPorts = [ 122 ];
caddyRoutes = [{
caddy.routes = [{
match = [{ host = [ config.giteaServer ]; }];
handle = [{
handler = "reverse_proxy";

View File

@ -1,6 +1,8 @@
{ config, pkgs, lib, ... }: {
home-manager.users.${config.user} = {
options.gpg.enable = lib.mkEnableOption "GnuPG encryption.";
home-manager.users.${config.user} = lib.mkIf config.gpg.enable {
programs.gpg.enable = true;
services.gpg-agent = {
enable = true;

View File

@ -1,4 +1,4 @@
{ lib, pkgs, ... }:
{ config, lib, pkgs, ... }:
# Currently has some issues that don't make this viable.
@ -38,7 +38,9 @@ let
in {
networking.firewall = {
options.honeypot.enable = lib.mkEnableOption "Honeypot fail2ban system.";
networking.firewall = lib.mkIf config.honeypot.enable {
extraPackages = [ pkgs.ipset ];
# allowedTCPPorts = portsToBlock;

View File

@ -4,14 +4,15 @@
streamServer = lib.mkOption {
type = lib.types.str;
description = "Hostname for Jellyfin library";
default = null;
};
};
config = {
config = lib.mkIf config.streamServer != null {
services.jellyfin.enable = true;
caddyRoutes = [{
caddy.routes = [{
match = [{ host = [ config.streamServer ]; }];
handle = [{
handler = "reverse_proxy";

View File

@ -1,5 +1,9 @@
{ config, pkgs, lib, ... }: {
options.keybase.enable = lib.mkEnableOption "Keybase.";
config = lib.mkIf config.keybase.enable {
services.keybase.enable = true;
services.kbfs = {
enable = true;
@ -25,4 +29,6 @@
};
};
};
}

View File

@ -1,6 +1,12 @@
{ pkgs, ... }: {
{ config, pkgs, lib, ... }: {
options.mullvad.enable = lib.mkEnableOption "Mullvad VPN.";
config = lib.mkIf config.mullvad.enable {
services.mullvad-vpn.enable = true;
environment.systemPackages = [ pkgs.mullvad-vpn ];
};
}

View File

@ -1,4 +1,14 @@
{ ... }: {
{ config, pkgs, lib, ... }: {
options = {
n8nServer = lib.mkOption {
type = lib.types.str;
description = "Hostname for n8n automation";
default = null;
};
};
config = lib.mkIf config.n8nServer != null {
services.n8n = {
enable = true;
@ -10,7 +20,7 @@
};
};
caddyRoutes = [{
caddy.routes = [{
match = [{ host = [ config.n8nServer ]; }];
handle = [{
handler = "reverse_proxy";
@ -18,4 +28,6 @@
}];
}];
};
}

View File

@ -1,6 +1,8 @@
{ config, pkgs, lib, ... }: {
config = {
options.netdata.enable = lib.mkEnableOption "Netdata metrics.";
config = lib.mkIf config.netdata.enable {
services.netdata = {
enable = true;

View File

@ -1,17 +1,16 @@
{ config, pkgs, lib, ... }: {
imports = [ ./caddy.nix ./secrets.nix ./backups.nix ];
options = {
nextcloudServer = lib.mkOption {
type = lib.types.str;
description = "Hostname for Nextcloud";
default = null;
};
};
config = {
config = lib.mkIf config.nextcloudServer != null {
services.nextcloud = {
enable = true;
@ -32,7 +31,7 @@
}];
# Point Caddy to Nginx
caddyRoutes = [{
caddy.routes = [{
match = [{ host = [ config.nextcloudServer ]; }];
handle = [{
handler = "reverse_proxy";

View File

@ -3,9 +3,10 @@
options.metricsServer = lib.mkOption {
type = lib.types.str;
description = "Hostname of the Grafana server.";
default = null;
};
config = {
config = lib.mkIf config.metricsServer != null {
services.grafana.enable = true;
@ -21,7 +22,7 @@
}];
};
caddyRoutes = [{
caddy.routes = [{
match = [{ host = [ config.metricsServer ]; }];
handle = [{
handler = "reverse_proxy";

View File

@ -47,7 +47,7 @@
};
config = {
config = lib.mkIf (pkgs.stdenv.isLinux && !config.wsl.enable) {
# Create a default directory to place secrets

View File

@ -12,7 +12,7 @@
};
};
config = {
config = lib.mkIf (pkgs.stdenv.isLinux && !config.wsl.enable) {
services.openssh = {
enable = true;
ports = [ 22 ];

View File

@ -1,11 +1,10 @@
{ config, pkgs, lib, ... }: {
imports = [ ./wireguard.nix ./secrets.nix ];
options = {
transmissionServer = lib.mkOption {
type = lib.types.str;
description = "Hostname for Transmission";
default = null;
};
};
@ -13,7 +12,7 @@
namespace = config.networking.wireguard.interfaces.wg0.interfaceNamespace;
vpnIp = lib.strings.removeSuffix "/32"
(builtins.head config.networking.wireguard.interfaces.wg0.ips);
in {
in lib.mkIf (config.wireguard.enable && config.transmissionServer != null) {
# Setup transmission
services.transmission = {

View File

@ -4,18 +4,17 @@ let vaultwardenPath = "/var/lib/bitwarden_rs"; # Default service directory
in {
imports = [ ./caddy.nix ./secrets.nix ./backups.nix ];
options = {
vaultwardenServer = lib.mkOption {
description = "Hostname for Vaultwarden.";
type = lib.types.str;
default = null;
};
};
config = {
config = lib.mkIf config.vaultwardenServer != null {
services.vaultwarden = {
enable = true;
config = {

View File

@ -1,8 +1,8 @@
{ config, pkgs, lib, ... }: {
imports = [ ./secrets.nix ];
options.wireguard.enable = lib.mkEnableOption "Wireguard VPN setup.";
config = {
config = lib.mkIf (pkgs.stdenv.isLinux && config.wireguard.enable) {
networking.wireguard = {
enable = true;

View File

@ -1,6 +1,8 @@
{ config, pkgs, ... }: {
{ config, pkgs, lib, ... }: {
home-manager.users.${config.user} = {
options.charm.enable = lib.mkEnableOption "Charm utilities.";
home-manager.users.${config.user} = lib.mkIf config.charm.enable {
home.packages = with pkgs; [
glow # Markdown previews

View File

@ -1,4 +1,6 @@
{ config, lib, ... }: {
{ config, pkgs, lib, ... }: {
config = lib.mkIf (pkgs.stdenv.isLinux && config.wsl.enable) {
# Systemd doesn't work in WSL so these must be disabled
services.geoclue2.enable = lib.mkForce false;
@ -16,4 +18,6 @@
ln --symbolic --no-dereference --force ${config.dotfilesPath} /etc/nixos
'';
};
}