continuing dev

This commit is contained in:
Noah Masur 2025-01-29 21:12:48 -05:00
parent c7933f8502
commit 0ebd0bac2c
No known key found for this signature in database
55 changed files with 362 additions and 347 deletions

17
flake.lock generated
View File

@ -492,22 +492,6 @@
"type": "github"
}
},
"nixpkgs-caddy": {
"locked": {
"lastModified": 1699107987,
"narHash": "sha256-nWXETr4Oqy/vOfzgWyMY04qzEN2iREFJc5ycQ3XNu0A=",
"owner": "jpds",
"repo": "nixpkgs",
"rev": "a33b02fa9d664f31dadc8a874eb1a5dbaa9f4ecf",
"type": "github"
},
"original": {
"owner": "jpds",
"ref": "caddy-external-plugins",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-stable": {
"locked": {
"lastModified": 1735563628,
@ -697,7 +681,6 @@
"nix2vim": "nix2vim",
"nixos-generators": "nixos-generators",
"nixpkgs": "nixpkgs",
"nixpkgs-caddy": "nixpkgs-caddy",
"nixpkgs-stable": "nixpkgs-stable",
"nur": "nur",
"nvim-lint-src": "nvim-lint-src",

View File

@ -10,9 +10,6 @@
# Used for specific stable packages
nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-24.05";
# Used for caddy plugins
nixpkgs-caddy.url = "github:jpds/nixpkgs/caddy-external-plugins";
# Used for MacOS system config
darwin = {
url = "github:lnl7/nix-darwin/master";

View File

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

View File

@ -1,17 +0,0 @@
{
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,27 +0,0 @@
{
config,
pkgs,
lib,
...
}:
{
options.python.enable = lib.mkEnableOption "Python programming language.";
config = lib.mkIf config.python.enable {
home-manager.users.${config.user} = {
home.packages = with pkgs; [
# python310 # Standard Python interpreter
pyright # Python language server
black # Python formatter
python310Packages.flake8 # Python linter
];
programs.fish.shellAbbrs = {
py = "python3";
};
};
};
}

View File

@ -1,31 +0,0 @@
{
config,
pkgs,
lib,
...
}:
{
options.rust.enable = lib.mkEnableOption "Rust programming language.";
config = lib.mkIf config.rust.enable {
home-manager.users.${config.user} = {
programs.fish.shellAbbrs = {
ca = "cargo";
};
home.packages = with pkgs; [
gcc
rustc
cargo
cargo-watch
clippy
rustfmt
pkg-config
openssl
];
};
};
}

View File

@ -1,26 +0,0 @@
{
config,
pkgs,
lib,
...
}:
{
options.terraform.enable = lib.mkEnableOption "Terraform tools.";
config = lib.mkIf config.terraform.enable {
unfreePackages = [ "terraform" ];
home-manager.users.${config.user} = {
programs.fish.shellAbbrs = {
# Terraform
te = "terraform";
};
home.packages = with pkgs; [
terraform # Terraform executable
terraform-ls # Language server
tflint # Linter
];
};
};
}

View File

@ -1,22 +0,0 @@
{
config,
pkgs,
lib,
...
}:
{
home-manager.users.${config.user} = lib.mkIf pkgs.stdenv.isDarwin {
home.packages = with pkgs; [ nerd-fonts.victor-mono ];
programs.alacritty.settings = {
font.normal.family = "VictorMono";
};
programs.kitty.font = {
package = pkgs.nerd-fonts.victor-mono;
name = "VictorMono Nerd Font Mono";
};
};
}

View File

@ -1,60 +0,0 @@
{
config,
pkgs,
lib,
...
}:
let
home-packages = config.home-manager.users.${config.user}.home.packages;
in
{
options.gaming.legendary.enable = lib.mkEnableOption "Legendary Epic Games launcher.";
config = lib.mkIf config.gaming.legendary.enable {
environment.systemPackages = with pkgs; [
legendary-gl
wineWowPackages.stable # 32-bit and 64-bit wineWowPackages, see https://nixos.wiki/wiki/Wine
heroic # GUI launcher
];
home-manager.users.${config.user} = {
xdg.configFile."legendary/config.ini".text = ''
[Legendary]
; Disables the automatic update check
disable_update_check = false
; Disables the notice about an available update on exit
disable_update_notice = true
; Set install directory
install_dir = ${config.homePath}/media/games
; Make output quiet
log_level = error
'';
home.file =
let
ignorePatterns = ''
.wine/
drive_c/'';
in
{
".rgignore".text = ignorePatterns;
".fdignore".text = ignorePatterns;
};
programs.fish.functions = lib.mkIf (builtins.elem pkgs.fzf home-packages) {
epic-games = {
body = ''
set game (legendary list 2>/dev/null \
| awk '/^ \* / { print $0; }' \
| sed -e 's/ (.*)$//' -e 's/ \* //' \
| fzf)
and legendary launch "$game" &> /dev/null
'';
};
};
};
};
}

View File

@ -1,18 +0,0 @@
{
config,
pkgs,
lib,
...
}:
{
options.gaming.lutris.enable = lib.mkEnableOption "Lutris game installer.";
config = lib.mkIf config.gaming.lutris.enable {
environment.systemPackages = with pkgs; [
lutris
amdvlk # Vulkan drivers (probably already installed)
wineWowPackages.stable # 32-bit and 64-bit wineWowPackages
];
};
}

View File

@ -1,19 +0,0 @@
{
config,
pkgs,
lib,
...
}:
{
options.gaming.ryujinx.enable = lib.mkEnableOption "Ryujinx Nintendo Switch application.";
config = lib.mkIf config.gaming.ryujinx.enable {
environment.systemPackages = with pkgs; [ ryujinx ];
home-manager.users.${config.user}.xdg.desktopEntries.ryujinx = lib.mkIf pkgs.stdenv.isLinux {
name = "Ryujinx";
exec = "env DOTNET_EnableAlternateStackCheck=1 Ryujinx -r /home/${config.user}/media/games/ryujinx/ %f";
};
};
}

12
overlays/stable.nix Normal file
View File

@ -0,0 +1,12 @@
# Include stable packages
# Adapted from https://github.com/PsychoLlama/dotfiles/blob/dd41f8c60fdc85868dbd7d88cf933348b497dcf0/lib/overlays/latest-packages.nix
inputs: _final: prev: {
# Provides `pkgs.stable`.
stable = import inputs.nixpkgs-stable {
inherit (prev) system config;
overlays = [
# inputs.self.overlays.vim-plugins
];
};
}

View File

@ -0,0 +1,38 @@
{
config,
pkgs,
lib,
...
}:
let
cfg = config.nmasur.presets.fonts;
in
{
options.nmasur.presets.fonts.enable = lib.mkEnableOption "Font configuration";
config = lib.mkIf cfg.enable {
home.packages = [
pkgs.victor-mono # Used for Vim and Terminal
pkgs.nerd-fonts.hack # For Polybar, Rofi
];
fonts.fontconfig = {
enable = true;
defaultFonts.monospace = [ "Victor Mono" ];
};
xsession.windowManager.i3.config.fonts = {
names = [ "pango:Victor Mono" ];
# style = "Regular";
# size = 11.0;
};
services.polybar.config."bar/main".font-0 = "Hack Nerd Font:size=10;2";
programs.rofi.font = "Hack Nerd Font 14";
programs.alacritty.settings.font.normal.family = "VictorMono";
programs.kitty.font.name = "VictorMono Nerd Font Mono";
config.nmasur.presets.programs.wezterm.font = "VictorMono Nerd Font Mono";
services.dunst.settings.global.font = "Hack Nerd Font 14";
};
}

View File

@ -0,0 +1,32 @@
{
config,
pkgs,
lib,
...
}:
let
cfg = config.nmasur.presets.programs.cargo;
in
{
options.nmasur.presets.programs.cargo.enable = lib.mkEnableOption "Cargo for programming language.";
config = lib.mkIf cfg.enable {
programs.fish.shellAbbrs = {
ca = "cargo";
};
home.packages = with pkgs; [
gcc
rustc
cargo
cargo-watch
clippy
rustfmt
pkg-config
openssl
];
};
}

View File

@ -1,9 +1,13 @@
{ config, lib, ... }:
let
cfg = config.nmasur.presets.programs.haskell;
in
{
options.haskell.enable = lib.mkEnableOption "Haskell programming language.";
options.nmasur.presets.programs.haskell.enable =
lib.mkEnableOption "Haskell programming language config.";
config = lib.mkIf config.haskell.enable {
config = lib.mkIf cfg.enable {
# Binary Cache for Haskell.nix
nix.settings.trusted-public-keys = [ "hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=" ];

View File

@ -0,0 +1,21 @@
{
config,
pkgs,
lib,
...
}:
let
cfg = config.nmasur.presets.programs.lua;
in
{
options.nmasur.presets.programs.lua.enable = lib.mkEnableOption "Lua programming language.";
config = lib.mkIf cfg.enable {
home.packages = [
pkgs.stylua # Lua formatter
pkgs.sumneko-lua-language-server # Lua LSP
];
};
}

View File

@ -0,0 +1,27 @@
{
config,
pkgs,
lib,
...
}:
let
cfg = config.nmasur.presets.programs.python;
in
{
options.nmasur.presets.programs.python.enable = lib.mkEnableOption "Python programming language.";
config = lib.mkIf cfg.enable {
home.packages = [
pkgs.pyright # Python language server
pkgs.black # Python formatter
pkgs.python310Packages.flake8 # Python linter
];
programs.fish.shellAbbrs = {
py = "python3";
};
};
}

View File

@ -168,7 +168,7 @@ in
home.file.".local/share/rofi/themes" = {
recursive = true;
source = ./rofi/themes;
source = ./themes;
};
};

View File

@ -0,0 +1,30 @@
{
config,
pkgs,
lib,
...
}:
let
cfg = config.nmasur.presets.programs.terraform;
in
{
options.nmasur.presets.programs.terraform.enable =
lib.mkEnableOption "Terraform infrastructure management";
config = lib.mkIf cfg.enable {
unfreePackages = [ "terraform" ];
programs.fish.shellAbbrs = {
te = "terraform";
};
home.packages = with pkgs; [
terraform
terraform-ls
tflint
];
};
}

View File

@ -7,12 +7,17 @@
let
cfg = config.nmasur.presets.programs.wezterm;
font = config.programs.kitty.font.name;
in
{
options.nmasur.presets.programs.wezterm.enable = lib.mkEnableOption "WezTerm terminal";
options.nmasur.presets.programs.wezterm = {
enable = lib.mkEnableOption "WezTerm terminal";
font = lib.mkOption {
type = lib.types.str;
description = "Name of the font for WezTerm";
};
};
config = lib.mkIf cfg.enable {
# Set the i3 terminal
@ -99,7 +104,7 @@ in
bottom = 12,
}
config.font = wezterm.font('${font}', { weight = 'Bold'})
config.font = wezterm.font('${cfg.font}', { weight = 'Bold'})
config.font_size = ${if pkgs.stdenv.isLinux then "14.0" else "18.0"}
-- Fix color blocks instead of text
@ -108,7 +113,7 @@ in
-- Tab Bar
config.hide_tab_bar_if_only_one_tab = true
config.window_frame = {
font = wezterm.font('${font}', { weight = 'Bold'}),
font = wezterm.font('${cfg.font}', { weight = 'Bold'}),
font_size = ${if pkgs.stdenv.isLinux then "12.0" else "16.0"},
}

View File

@ -0,0 +1,25 @@
{ config, lib, ... }:
let
cfg = config.nmasur.presets.programs.wine;
in
{
options.nmasur.presets.programs.wine.enable = lib.mkEnableOption "Wine settings";
config = lib.mkIf cfg.enable {
# Ignore wine directories in searches
home.file =
let
ignorePatterns = ''
.wine/
drive_c/'';
in
{
".rgignore".text = ignorePatterns;
".fdignore".text = ignorePatterns;
};
};
}

View File

@ -15,20 +15,18 @@ in
lib.mkEnableOption "Hammerspoon macOS automation";
config = lib.mkIf cfg.enable {
xdg.configFile."hammerspoon/init.lua".source = ./hammerspoon/init.lua;
xdg.configFile."hammerspoon/Spoons/ControlEscape.spoon".source =
./hammerspoon/Spoons/ControlEscape.spoon;
xdg.configFile."hammerspoon/Spoons/DismissAlerts.spoon".source =
./hammerspoon/Spoons/DismissAlerts.spoon;
xdg.configFile."hammerspoon/init.lua".source = ./init.lua;
xdg.configFile."hammerspoon/Spoons/ControlEscape.spoon".source = ./Spoons/ControlEscape.spoon;
xdg.configFile."hammerspoon/Spoons/DismissAlerts.spoon".source = ./Spoons/DismissAlerts.spoon;
xdg.configFile."hammerspoon/Spoons/Launcher.spoon/init.lua".source = pkgs.substituteAll {
src = ./hammerspoon/Spoons/Launcher.spoon/init.lua;
src = ./Spoons/Launcher.spoon/init.lua;
firefox = "${pkgs.firefox-bin}/Applications/Firefox.app";
discord = "${pkgs.discord}/Applications/Discord.app";
wezterm = "${pkgs.wezterm}/Applications/WezTerm.app";
obsidian = "${pkgs.obsidian}/Applications/Obsidian.app";
slack = "${pkgs.slack}/Applications/Slack.app";
};
xdg.configFile."hammerspoon/Spoons/MoveWindow.spoon".source = ./hammerspoon/Spoons/MoveWindow.spoon;
xdg.configFile."hammerspoon/Spoons/MoveWindow.spoon".source = ./Spoons/MoveWindow.spoon;
home.activation.reloadHammerspoon =
config.home-manager.users.${config.user}.lib.dag.entryAfter [ "writeBoundary" ]

View File

@ -0,0 +1,33 @@
{
config,
pkgs,
lib,
...
}:
let
cfg = config.nmasur.presets.services.loadkey;
in
{
options.nmasur.presets.services.loadkey.enable =
lib.mkEnableOption "Load the private key as an SSH file";
config = lib.mkIf cfg.enable {
home.activation = {
# Always load the key if it doesn't exist
cloneDotfiles = config.lib.dag.entryAfter [ "writeBoundary" ] ''
if [ ! -f ~/.ssh/id_ed25519 ]; then
run mkdir -p ~/.ssh/
$DRY_RUN_CMD mkdir --parents $VERBOSE_ARG $(dirname "${config.dotfilesPath}")
$DRY_RUN_CMD ${pkgs.git}/bin/git \
clone ${config.dotfilesRepo} "${config.dotfilesPath}"
fi
'';
};
};
}

View File

@ -15,10 +15,12 @@ in
config = lib.mkIf cfg.enable {
home.packages = with pkgs; [
pgcli # Postgres client with autocomplete
home.packages = lib.mkDefault [
pkgs.pgcli # Postgres client with autocomplete
];
programs.helix.enable = lib.mkDefault true;
};
}

View File

@ -15,14 +15,14 @@ in
config = lib.mkIf cfg.enable {
home.packages = with pkgs; [
home.packages = lib.mkDefault [
# Charm tools
glow # Markdown previews
skate # Key-value store
charm # Manage account and filesystem
pop # Send emails from a TUI
pkgs.glow # Markdown previews
pkgs.skate # Key-value store
pkgs.charm # Manage account and filesystem
pkgs.pop # Send emails from a TUI
];

View File

@ -16,28 +16,28 @@ in
config = lib.mkIf cfg.enable {
# Allow Nix to manage the default applications list
mimeApps.enable = true;
mimeApps.enable = lib.mkDefault true;
# Set directories for application defaults
userDirs = {
enable = true;
createDirectories = true;
documents = "$HOME/documents";
download = config.userDirs.download;
music = "$HOME/media/music";
pictures = "$HOME/media/images";
videos = "$HOME/media/videos";
desktop = "$HOME/other/desktop";
publicShare = "$HOME/other/public";
templates = "$HOME/other/templates";
enable = lib.mkDefault true;
createDirectories = lib.mkDefault true;
documents = lib.mkDefault "$HOME/documents";
download = lib.mkDefault config.userDirs.download;
music = lib.mkDefault "$HOME/media/music";
pictures = lib.mkDefault "$HOME/media/images";
videos = lib.mkDefault "$HOME/media/videos";
desktop = lib.mkDefault "$HOME/other/desktop";
publicShare = lib.mkDefault "$HOME/other/public";
templates = lib.mkDefault "$HOME/other/templates";
extraConfig = {
XDG_DEV_DIR = "$HOME/dev";
XDG_DEV_DIR = lib.mkDefault "$HOME/dev";
};
};
programs.fish.shellAliases = {
# Move files to XDG trash on the commandline
trash = "${pkgs.trash-cli}/bin/trash-put";
trash = lib.mkDefault "${pkgs.trash-cli}/bin/trash-put";
};
};
}

View File

@ -0,0 +1,25 @@
{
config,
pkgs,
lib,
...
}:
let
cfg = config.nmasur.profiles.linux-gaming;
in
{
options.nmasur.profiles.linux-gaming.enable = lib.mkEnableOption "Linux gaming home";
config = lib.mkIf cfg.enable {
config.nmasur.programs.wine.enable = lib.mkDefault true;
home.packages = lib.mkDefault [
pkgs.heroic
];
};
}

View File

@ -17,32 +17,34 @@ in
# Cursor
home.pointerCursor = {
name = "Adwaita";
package = pkgs.adwaita-icon-theme;
size = 24;
gtk.enable = true;
x11.enable = true;
name = lib.mkDefault "Adwaita";
package = lib.mkDefault pkgs.adwaita-icon-theme;
size = lib.mkDefault 24;
gtk.enable = lib.mkDefault true;
x11.enable = lib.mkDefault true;
};
# Enable num lock on login
xsession.numlock.enable = true;
xsession.numlock.enable = lib.mkDefault true;
# Dark theme
gtk =
let
gtkExtraConfig = {
gtk-application-prefer-dark-theme = config.theme.dark;
gtk-application-prefer-dark-theme = lib.mkDefault config.theme.dark;
};
in
{
enable = true;
enable = lib.mkDefault true;
theme = {
name = config.gtk.theme.name;
package = config.gtk.theme.package;
name = lib.mkDefault config.gtk.theme.name;
package = lib.mkDefault config.gtk.theme.package;
};
gtk3.extraConfig = gtkExtraConfig;
gtk4.extraConfig = gtkExtraConfig;
gtk3.extraConfig = lib.mkDefault gtkExtraConfig;
gtk4.extraConfig = lib.mkDefault gtkExtraConfig;
};
programs.zed-editor.enable = lib.mkDefault true;
};
}

View File

@ -58,6 +58,12 @@ in
text = builtins.readFile ../../modules/common/shell/bash/scripts/terraform-init.sh;
})
];
programs.helix.enable = lib.mkDefault true;
programs.zed-editor.enable = lib.mkDefault true;
config.nmasur.presets.programs.terraform.enable = lib.mkDefault true;
};
}

View File

@ -22,5 +22,10 @@ in
"notunes" # Don't launch Apple Music with the play button
];
# Add homebrew paths to CLI path
home.sessionPath = [
"/opt/homebrew/opt/trash/bin"
];
};
}

View File

@ -34,7 +34,7 @@ in
# Normally I block all requests not coming from Cloudflare, so I have to also
# allow my local network.
caddy.cidrAllowlist = [ "192.168.0.0/16" ];
config.nmasur.presets.services.caddy.cidrAllowlist = [ "192.168.0.0/16" ];
services.bind = {

View File

@ -50,10 +50,10 @@ in
config = lib.mkIf cfg.enable {
# Force Caddy to 403 if not coming from allowlisted source
caddy.cidrAllowlist = lib.mkDefault [ "127.0.0.1/32" ];
caddy.routes = lib.mkBefore [
cfg.cidrAllowlist = lib.mkDefault [ "127.0.0.1/32" ];
cfg.routes = lib.mkBefore [
{
match = [ { not = [ { remote_ip.ranges = config.caddy.cidrAllowlist; } ]; } ];
match = [ { not = [ { remote_ip.ranges = cfg.cidrAllowlist; } ]; } ];
handle = [
{
handler = "static_response";

View File

@ -11,13 +11,14 @@
{
config,
pkgs,
pkgs-caddy,
lib,
...
}:
let
cfg = config.nmasur.presets.services.cloudflare;
cloudflareIpRanges = [
# Cloudflare IPv4: https://www.cloudflare.com/ips-v4
@ -49,29 +50,25 @@ let
in
{
options.cloudflare.enable = lib.mkEnableOption "Use Cloudflare.";
options.nmasur.presets.services.cloudflare = {
enable = lib.mkEnableOption "Cloudflare proxy configuration";
options.cloudflare.noProxyDomains = lib.mkOption {
noProxyDomains = lib.mkOption {
type = lib.types.listOf lib.types.str;
description = "Domains to use for dyndns without CDN proxying.";
default = [ ];
};
};
config = lib.mkIf config.cloudflare.enable {
config = lib.mkIf cfg.enable {
# Forces Caddy to error if coming from a non-Cloudflare IP
caddy.cidrAllowlist = cloudflareIpRanges;
config.nmasur.presets.services.caddy.cidrAllowlist = cloudflareIpRanges;
# Tell Caddy to use Cloudflare DNS for ACME challenge validation
services.caddy.package = pkgs-caddy.caddy.override {
externalPlugins = [
{
name = "cloudflare";
repo = "github.com/caddy-dns/cloudflare";
version = "master";
}
];
vendorHash = "sha256-C7JOGd4sXsRZL561oP84V2/pTg7szEgF4OFOw35yS1s=";
services.caddy.package = pkgs.caddy.withPlugins {
plugins = [ "github.com/caddy-dns/cloudflare@master" ];
hash = "sha256-C7JOGd4sXsRZL561oP84V2/pTg7szEgF4OFOw35yS1s=";
};
caddy.tlsPolicies = [
{

View File

@ -25,5 +25,6 @@ in
programs.gamemode.enable = true;
environment.systemPackages = with pkgs; [ moonlight-qt ];
};
}

View File

@ -18,7 +18,7 @@ in
# Run a second copy of dyn-dns for non-proxied domains
# Adapted from: https://github.com/NixOS/nixpkgs/blob/nixos-unstable/nixos/modules/services/networking/cloudflare-dyndns.nix
systemd.services.cloudflare-dyndns-noproxy =
lib.mkIf ((builtins.length config.cloudflare.noProxyDomains) > 0)
lib.mkIf ((builtins.length config.nmasur.presets.services.cloudflare.noProxyDomains) > 0)
{
description = "CloudFlare Dynamic DNS Client (no proxy)";
after = [
@ -30,7 +30,7 @@ in
startAt = "*:0/5";
environment = {
CLOUDFLARE_DOMAINS = toString config.cloudflare.noProxyDomains;
CLOUDFLARE_DOMAINS = toString config.nmasur.presets.services.cloudflare.noProxyDomains;
};
serviceConfig = {

View File

@ -18,6 +18,8 @@
let
cfg = config.services.honeypot;
portsToBlock = [
25545
25565
@ -47,9 +49,10 @@ let
in
{
options.honeypot.enable = lib.mkEnableOption "Honeypot fail2ban system.";
options.services.honeypot.enable = lib.mkEnableOption "Honeypot fail2ban system.";
config.networking.firewall = lib.mkIf config.honeypot.enable {
config = lib.mkIf cfg.enable {
networking.firewall = {
extraPackages = [ pkgs.ipset ];
# allowedTCPPorts = portsToBlock;
@ -78,4 +81,5 @@ in
${delete-rules}
'';
};
};
}