This commit is contained in:
John Lancaster
2026-03-11 08:49:07 -05:00
parent dac3b84ffb
commit cf2ba8731d
19 changed files with 56 additions and 9 deletions

10
modules/programs/base.nix Normal file
View File

@@ -0,0 +1,10 @@
{ inputs, pkgs, ... }:
{
flake.modules.homeManager.base = { pkgs, ... }:
{
imports = with inputs.self.modules.homeManager; [
git
shell-tools
];
};
}

10
modules/programs/bash.nix Normal file
View File

@@ -0,0 +1,10 @@
{
flake.modules.homeManager.bash = { pkgs, ... }:
{
programs.bash = {
enable = true;
enableCompletion = true;
package = pkgs.bash;
};
};
}

View File

@@ -0,0 +1,12 @@
# This module is for programs with GUIs that run in a desktop environment
{ inputs, ... }:
{
flake.modules.homeManager.desktop =
{
imports = with inputs.self.modules.homeManager; [
onepassword
ghostty
sublime
];
};
}

14
modules/programs/eza.nix Normal file
View File

@@ -0,0 +1,14 @@
{ inputs, pkgs, lib, ... }:
{
flake.modules.homeManager.eza = { pkgs, lib, ... }: {
programs.eza = {
enable = true;
package = pkgs.eza;
enableBashIntegration = true;
enableZshIntegration = true;
};
home.shellAliases = {
ls = "${lib.getExe pkgs.eza} -lgos type --no-time --follow-symlinks";
};
};
}

View File

@@ -0,0 +1,15 @@
{
flake.modules.homeManager.files = { pkgs, ... }:
{
programs.lf.enable = true;
programs.lf.cmdKeybindings = {
"D" = "delete";
};
home.packages = with pkgs; [
gdu
lf
# TODO: find a CLI file editor that's not insane
];
};
}

View File

@@ -0,0 +1,87 @@
{ inputs, ... }:
{
flake-file.inputs = {
nixgl = {
url = "github:nix-community/nixGL";
inputs.nixpkgs.follows = "nixpkgs";
};
};
flake.modules.homeManager.ghostty = { config, pkgs, lib, ... }:
{
home.sessionVariables = {
TERMINAL = "ghostty";
};
targets.genericLinux.nixGL = {
packages = inputs.nixgl.packages.${pkgs.stdenv.hostPlatform.system};
defaultWrapper = "mesa";
installScripts = [ "mesa" ];
};
programs.ghostty = {
enable = true;
enableZshIntegration = true;
package = config.lib.nixGL.wrap pkgs.ghostty;
settings = {
command = "TERM=xterm-256color ${lib.getExe pkgs.zsh}";
font-size = 12;
font-family = "Source Code Pro";
theme = "Catppuccin Mocha";
copy-on-select = true;
shell-integration = "zsh";
shell-integration-features = [ "no-title" "sudo" ];
gtk-single-instance = true;
window-position-x = 25;
window-position-y = 25;
# window-height = 40;
# window-width = 200;
# window-padding-balance = true;
# window-padding-x = 5;
# window-padding-y = 5;
initial-window = true;
resize-overlay = "never";
keybind = [
"ctrl+s>n=new_split:down"
"ctrl+t>n=new_tab"
"ctrl+t>1=goto_tab:1"
"ctrl+t>2=goto_tab:2"
"ctrl+t>3=goto_tab:3"
"ctrl+s>i=goto_split:up"
"ctrl+s>k=goto_split:down"
];
};
};
# https://github.com/ghostty-org/ghostty/discussions/3763#discussioncomment-11699970
xdg.desktopEntries."com.mitchellh.ghostty" = {
name = "Ghostty";
type = "Application";
comment = "A terminal emulator";
exec = "nixGLMesa ghostty";
icon = "com.mitchellh.ghostty";
terminal = false;
startupNotify = true;
categories = [ "System" "TerminalEmulator" ];
settings = {
Keywords = "terminal;tty;pty;";
X-GNOME-UsesNotifications = "true";
X-TerminalArgExec = "-e";
X-TerminalArgTitle = "--title=";
X-TerminalArgAppId = "--class=";
X-TerminalArgDir = "--working-directory=";
X-TerminalArgHold = "--wait-after-command";
};
actions = {
new-window = {
name = "New Window";
exec = "nixGLMesa ghostty";
};
};
};
};
}

18
modules/programs/git.nix Normal file
View File

@@ -0,0 +1,18 @@
{
flake.modules.homeManager.git = { config, lib, ... }:
{
programs.git = {
enable = true;
settings = {
credential.helper = "store --file ~/.git-credentials";
init.defaultBranch = "main";
push.autoSetupRemote = true;
};
};
programs.lazygit = {
enable = true;
enableBashIntegration = true;
enableZshIntegration = true;
};
};
}

View File

@@ -0,0 +1,5 @@
{
flake.modules.homeManager.onepassword = {
# TODO: Port `_1password = true` behavior into an explicit Home Manager module.
};
}

View File

@@ -0,0 +1,38 @@
# This module provides all the shell options
{ inputs, lib, ... }:
{
flake.modules.homeManager.shell-tools = { config, pkgs, ... }: {
options.shell.program = lib.mkOption {
type = lib.types.enum [ "bash" "zsh" ];
default = "zsh";
description = "Which interactive shell configuration to enable.";
};
imports = with inputs.self.modules.homeManager; [
bash
# zsh
# Tools
eza
files
];
config = {
programs.bash.enable = lib.mkForce (config.shell.program == "bash");
programs.zsh.enable = lib.mkForce (config.shell.program == "zsh");
home.shell.enableShellIntegration = true;
home.packages = with pkgs; [
wget
curl
cacert
busybox
gnugrep
dig
btop
uv
xclip
];
};
};
}

80
modules/programs/sops.nix Normal file
View File

@@ -0,0 +1,80 @@
{ inputs, ... }:
let
inputs' = inputs; # save a reference before it's shadowed
in
{
flake-file.inputs = {
# Adding sops-nix to the flake-file inputs causes it to get added to the inputs in flake.nix when it gets generated.
# This also makes the sops-nix module available
sops-nix.url = "github:Mic92/sops-nix";
sops-nix.inputs.nixpkgs.follows = "nixpkgs";
};
# Define the homeModules that are used by flake-parts
# https://flake.parts/options/home-manager.html#opt-flake.modules.homeManager
flake.modules.homeManager.sops = { inputs, config, pkgs, lib, ... }:
let
sopsBin = lib.getExe pkgs.sops;
sopsConfigPath = ../../.sops.yaml;
sopsSecretsPath = ../../keys/secrets.yaml;
ageKeyFile = "${config.xdg.configHome}/sops/age/keys.txt";
in
{
home.packages = with pkgs; [
eza
age
sops # This is necessary to make the sops binary available
ssh-to-age
(writeShellScriptBin "gen-age-key" ''
${lib.getExe pkgs.ssh-to-age} -i ${config.ssh.IdentityFile} -private-key > ${ageKeyFile}
echo -n "Created ${ageKeyFile}: "
echo $(show-age-key)
'')
(writeShellScriptBin "show-age-key" "${lib.getExe' pkgs.age "age-keygen"} -y ${ageKeyFile}")
(writeShellScriptBin "edit-secrets" "${sopsBin} --config ${sopsConfigPath} ${sopsSecretsPath}")
(writeShellScriptBin "ls-secrets" "${lib.getExe pkgs.eza} -alT --follow-symlinks ~/.config/sops-nix/secrets")
];
home.shellAliases.sops = "${sopsBin} --config ${sopsConfigPath}";
imports = [
# This import makes the sops config attribute available below
inputs'.sops-nix.homeManagerModules.sops
];
home.sessionVariables = {
GMAIL_CREDS_PATH = "${config.xdg.configHome}/sops-nix/gmail_api_credentials.json";
};
# Option definitions for the sops home-manager module:
# https://github.com/Mic92/sops-nix/blob/master/modules/home-manager/sops.nix
sops = {
defaultSopsFile = sopsSecretsPath;
defaultSopsFormat = "yaml";
age.sshKeyPaths = [ "${config.ssh.IdentityFile}" ];
# age.keyFile = "${ageKeyFile}";
# age.generateKey = true;
secrets."api/gmail_client_secret" = {
path = "${config.xdg.configHome}/resticprofile/dendrite.txt";
};
templates."gmail_creds" = {
path = "${config.xdg.configHome}/sops-nix/gmail_api_credentials.json";
content = ''
{
"installed": {
"client_id": "499012320469-vtml6emu6bmujpsj9lud2b44jqu7h26j.apps.googleusercontent.com",
"project_id": "python-apis-423500",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_secret": "${config.sops.placeholder."api/gmail_client_secret"}",
"redirect_uris": [ "http://localhost" ]
}
}
'';
};
};
};
}

View File

@@ -0,0 +1,8 @@
{ inputs, pkgs, ... }:
{
flake.modules.homeManager.sublime = { pkgs, lib, ... }: {
home.packages = with pkgs; [
sublime4
];
};
}

View File

@@ -0,0 +1,21 @@
{
flake.modules.homeManager.vscode = { pkgs, ... }:
{
programs.vscode = {
enable = true;
package = pkgs.vscode;
profiles.default.extensions = with pkgs.vscode-extensions; [
mhutchie.git-graph
ms-vscode-remote.vscode-remote-extensionpack
ms-python.python
ms-python.vscode-pylance
ms-toolsai.jupyter
charliermarsh.ruff
github.vscode-pull-request-github
github.vscode-github-actions
github.copilot
catppuccin.catppuccin-vsc
];
};
};
}

53
modules/programs/zsh.nix Normal file
View File

@@ -0,0 +1,53 @@
{ inputs, ... }:
let
username = "john";
in
{
flake.modules = {
nixos.zsh = { pkgs, ... }: {
users.users."${username}".shell = pkgs.zsh;
programs.zsh.enable = true;
home-manager.sharedModules = [
inputs.self.modules.homeManager.zsh
];
};
homeManager.zsh = { pkgs, config, ... }: {
programs.zsh = {
enable = true;
package = pkgs.zsh;
enableCompletion = true;
autosuggestion.enable = true;
# syntaxHighlighting.enable = true;
initContent = "HOST=$(hostname -s)";
dotDir = "${config.xdg.configHome}/zsh";
history = {
append = true;
ignoreAllDups = true;
ignorePatterns = [
"history"
"ls"
"eza"
"clear"
];
save = 1000;
size = 1000;
share = true;
};
oh-my-zsh = {
enable = true;
# theme = "risto";
theme = "agnoster";
plugins = [
"sudo"
"dotenv"
"git"
"ssh"
"ssh-agent"
];
};
};
};
};
}