separated programs directory
This commit is contained in:
10
modules/home-manager/programs/bash.nix
Normal file
10
modules/home-manager/programs/bash.nix
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
flake.homeModules.bash = { pkgs, ... }:
|
||||
{
|
||||
programs.bash = {
|
||||
enable = true;
|
||||
enableCompletion = true;
|
||||
package = pkgs.bash;
|
||||
};
|
||||
};
|
||||
}
|
||||
22
modules/home-manager/programs/docker.nix
Normal file
22
modules/home-manager/programs/docker.nix
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
flake.homeModules.docker = { config, lib, pkgs, ... }:
|
||||
{
|
||||
options.docker = {
|
||||
enable = lib.mkEnableOption "Docker tools and utilities";
|
||||
};
|
||||
|
||||
config = lib.mkIf config.docker.enable {
|
||||
programs.lazydocker.enable = true;
|
||||
programs.docker-cli.enable = true;
|
||||
|
||||
home.packages = with pkgs; [
|
||||
docker
|
||||
docker-compose
|
||||
lazydocker
|
||||
(pkgs.writeShellScriptBin "test-docker" ''
|
||||
echo "Hello from docker.nix!"
|
||||
'')
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
14
modules/home-manager/programs/eza.nix
Normal file
14
modules/home-manager/programs/eza.nix
Normal file
@@ -0,0 +1,14 @@
|
||||
{ inputs, pkgs, lib, ... }:
|
||||
{
|
||||
flake.homeModules.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";
|
||||
};
|
||||
};
|
||||
}
|
||||
87
modules/home-manager/programs/ghostty.nix
Normal file
87
modules/home-manager/programs/ghostty.nix
Normal file
@@ -0,0 +1,87 @@
|
||||
{ inputs, ... }:
|
||||
{
|
||||
flake-file.inputs = {
|
||||
nixgl = {
|
||||
url = "github:nix-community/nixGL";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
|
||||
flake.homeModules.ghostty = { config, pkgs, lib, ... }:
|
||||
{
|
||||
home.sessionVariables = {
|
||||
TERMINAL = "ghostty";
|
||||
};
|
||||
|
||||
targets.genericLinux.nixGL = {
|
||||
packages = inputs.nixgl.packages.${pkgs.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 = 50;
|
||||
window-position-y = 50;
|
||||
|
||||
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"
|
||||
];
|
||||
|
||||
window-height = 40;
|
||||
window-width = 200;
|
||||
};
|
||||
};
|
||||
|
||||
# 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/home-manager/programs/git.nix
Normal file
18
modules/home-manager/programs/git.nix
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
flake.homeModules.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;
|
||||
};
|
||||
};
|
||||
}
|
||||
5
modules/home-manager/programs/onepassword.nix
Normal file
5
modules/home-manager/programs/onepassword.nix
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
flake.homeModules.onepassword = {
|
||||
# TODO: Port `_1password = true` behavior into an explicit Home Manager module.
|
||||
};
|
||||
}
|
||||
82
modules/home-manager/programs/sops.nix
Normal file
82
modules/home-manager/programs/sops.nix
Normal file
@@ -0,0 +1,82 @@
|
||||
{ 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.homeModules
|
||||
flake.homeModules.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" "exec ${lib.getExe' pkgs.age "age-keygen"} -y ${ageKeyFile}")
|
||||
(writeShellScriptBin "edit-secrets" "exec ${sopsBin} --config ${sopsConfigPath} ${sopsSecretsPath}")
|
||||
(writeShellScriptBin "ls-secrets" "exec ${lib.getExe pkgs.eza} -alT --follow-symlinks ~/.config/sops-nix/secrets")
|
||||
];
|
||||
|
||||
programs.zsh.shellAliases.sops = "exec ${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";
|
||||
|
||||
# Not sure any of these are necessary
|
||||
# age.sshKeyPaths = [ "${config.sshIdentityFile}" ];
|
||||
# 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" ]
|
||||
}
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
112
modules/home-manager/programs/ssh.nix
Normal file
112
modules/home-manager/programs/ssh.nix
Normal file
@@ -0,0 +1,112 @@
|
||||
{inputs, ... }:
|
||||
let
|
||||
userName = "john";
|
||||
in
|
||||
{
|
||||
flake.homeModules.ssh = { pkgs, config, lib, ... }:
|
||||
{
|
||||
options.ssh = {
|
||||
IdentityFile = lib.mkOption {
|
||||
# Intentionally not using a path type here because that will end up with the private key getting copied into the store
|
||||
type = lib.types.str;
|
||||
default = "${config.home.homeDirectory}/.ssh/id_ed25519";
|
||||
description = "Path to the SSH identity file.";
|
||||
};
|
||||
|
||||
matchSets = {
|
||||
appdaemon = lib.mkEnableOption "Enable AppDaemon SSH targets";
|
||||
certs = lib.mkEnableOption "Enable Janus and Soteria SSH targets";
|
||||
homelab = lib.mkEnableOption "Enable various Homelab targets";
|
||||
};
|
||||
};
|
||||
|
||||
# All this stuff has to be wrapped in a config attribute because of the presence of the options here?
|
||||
config = let
|
||||
identityFile = config.ssh.IdentityFile;
|
||||
publicKeyFile = "${identityFile}.pub";
|
||||
certificateFile = "${identityFile}-cert.pub";
|
||||
userKnownHostsFile = "${config.home.homeDirectory}/.ssh/known_hosts";
|
||||
in {
|
||||
home.packages = [
|
||||
(pkgs.writeShellScriptBin "sign-ssh-cert" ''
|
||||
echo "Signing ${publicKeyFile}"
|
||||
echo "Copy the Step-CA JWK Provisioner password from 1password"
|
||||
step ssh certificate --sign \
|
||||
--principal root \
|
||||
--principal ${userName} \
|
||||
--principal appdaemon \
|
||||
--provisioner admin \
|
||||
${userName} ${publicKeyFile}
|
||||
'')
|
||||
];
|
||||
|
||||
programs.ssh = {
|
||||
enable = true;
|
||||
enableDefaultConfig = false;
|
||||
extraConfig = ''
|
||||
SetEnv TERM="xterm-256color"
|
||||
IdentityAgent ~/.1password/agent.sock
|
||||
'';
|
||||
|
||||
matchBlocks = lib.mkMerge [
|
||||
{
|
||||
"*" = {
|
||||
user = "john";
|
||||
|
||||
compression = false;
|
||||
serverAliveInterval = 0;
|
||||
serverAliveCountMax = 3;
|
||||
|
||||
identitiesOnly = true;
|
||||
inherit identityFile certificateFile;
|
||||
|
||||
hashKnownHosts = false;
|
||||
userKnownHostsFile = "${userKnownHostsFile}";
|
||||
|
||||
addKeysToAgent = "yes";
|
||||
forwardAgent = false;
|
||||
};
|
||||
}
|
||||
(lib.mkIf config.ssh.matchSets.appdaemon {
|
||||
"appdaemon" = {
|
||||
hostname = "192.168.1.242";
|
||||
user = "appdaemon";
|
||||
};
|
||||
"ad-nix" = {
|
||||
hostname = "192.168.1.201";
|
||||
user = "appdaemon";
|
||||
};
|
||||
})
|
||||
(lib.mkIf config.ssh.matchSets.certs {
|
||||
"janus" = {
|
||||
hostname = "janus.john-stream.com";
|
||||
user = "root";
|
||||
};
|
||||
"soteria" = {
|
||||
hostname = "soteria.john-stream.com";
|
||||
user = "john";
|
||||
};
|
||||
})
|
||||
(lib.mkIf config.ssh.matchSets.homelab {
|
||||
"docs" = {
|
||||
hostname = "192.168.1.110";
|
||||
user = "root";
|
||||
};
|
||||
"gitea" = {
|
||||
hostname = "192.168.1.104";
|
||||
user = "john";
|
||||
};
|
||||
"hermes" = {
|
||||
hostname = "192.168.1.150";
|
||||
user = "root";
|
||||
};
|
||||
"panoptes" = {
|
||||
hostname = "192.168.1.107";
|
||||
user = "panoptes";
|
||||
};
|
||||
})
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
5
modules/home-manager/programs/sublime.nix
Normal file
5
modules/home-manager/programs/sublime.nix
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
flake.homeModules.sublime = {
|
||||
# TODO: Port `graphical.sublime = true` into an explicit Home Manager module.
|
||||
};
|
||||
}
|
||||
21
modules/home-manager/programs/vscode.nix
Normal file
21
modules/home-manager/programs/vscode.nix
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
flake.homeModules.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
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
38
modules/home-manager/programs/zsh.nix
Normal file
38
modules/home-manager/programs/zsh.nix
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
flake.homeModules.zsh = { pkgs, config, ... }:
|
||||
{
|
||||
programs.zsh = {
|
||||
enable = true;
|
||||
package = pkgs.zsh;
|
||||
enableCompletion = true;
|
||||
autosuggestion.enable = true;
|
||||
# syntaxHighlighting.enable = true;
|
||||
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"
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user