8 Commits
v1 ... v2

Author SHA1 Message Date
John Lancaster
1ae16e2971 fixed 2025-07-01 17:10:46 -05:00
John Lancaster
ee1f038f55 vault config 2025-06-30 23:31:34 -05:00
John Lancaster
6afd99827c 1password options 2025-06-30 23:21:22 -05:00
John Lancaster
57d59a9dea options 2025-06-30 22:45:04 -05:00
John Lancaster
c954124c13 added shell stuff 2025-06-30 20:21:20 -05:00
John Lancaster
f829f82885 profile option finally working 2025-06-30 19:44:19 -05:00
John Lancaster
8900ac44f0 working without option, but still referenced 2025-06-30 19:34:45 -05:00
John Lancaster
bb145deb8e stripped down 2025-06-30 19:21:35 -05:00
4 changed files with 147 additions and 49 deletions

View File

@@ -2,53 +2,31 @@
description = "Home Manager configuration flake for JSL"; description = "Home Manager configuration flake for JSL";
inputs = { inputs = {
# Specify the source of Home Manager and Nixpkgs.
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
home-manager = { home-manager = {
url = "github:nix-community/home-manager"; url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
_1password-shell-plugins.url = "github:1Password/shell-plugins";
}; };
outputs = { nixpkgs, home-manager, ... }: outputs = { nixpkgs, ... }@inputs:
let let
system = "x86_64-linux"; system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system}; pkgs = nixpkgs.legacyPackages.${system};
lib = pkgs.lib; lib = pkgs.lib;
homeManagerModule = { config, pkgs, ... }: {
options.user = lib.mkOption {
type = lib.types.str;
description = "The username for the Home Manager configuration.";
};
options.profile = lib.mkOption {
type = lib.types.enum [ "personal" "work" ];
default = "personal";
description = "Profile type for the Home Manager configuration.";
};
imports = [ ./home.nix ];
};
# Function to create a home configuration for any user
mkHomeConfiguration = username: home-manager.lib.homeManagerConfiguration {
inherit pkgs;
modules = [ homeManagerModule { user = username; } ];
};
# Default username from the module evaluation
evaluatedOptions = lib.evalModules { modules = [ homeManagerModule ]; };
userName = evaluatedOptions.config.user;
in in
{ {
# Default configuration using the default username homeManagerModules.default = { ... }: {
homeConfigurations.${userName} = mkHomeConfiguration userName; imports = [
./options.nix
# Export the function so other flakes can create configurations for any user ./home.nix
lib.mkHomeConfiguration = mkHomeConfiguration; ./git.nix
inputs._1password-shell-plugins.hmModules.default
# Export modules for reuse in other flakes ];
homeManagerModules.default = homeManagerModule; nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
"1password-cli"
];
};
}; };
} }

21
git.nix Normal file
View File

@@ -0,0 +1,21 @@
{ config, lib, ... }:
{
programs.git = lib.mkMerge [
{
enable = true;
extraConfig = {
credential.helper = "store --file ~/.git-credentials";
init.defaultBranch = "main";
push.autoSetupRemote = true;
};
}
(lib.mkIf (config.profile == "personal") {
userName = "John Lancaster";
userEmail = "32917998+jsl12@users.noreply.github.com";
})
(lib.mkIf (config.profile == "work") {
userName = "John Lancaster";
userEmail = "john.lancaster@crowncastle.com";
})
];
}

View File

@@ -1,6 +1,9 @@
{ config, pkgs, ... }: { config, pkgs, lib, inputs, ... }:
{ {
# imports = [
# inputs._1password-shell-plugins.hmModules.default
# ];
# Home Manager needs a bit of information about you and the paths it should # Home Manager needs a bit of information about you and the paths it should
# manage. # manage.
home.username = config.user; home.username = config.user;
@@ -18,29 +21,30 @@
# The home.packages option allows you to install Nix packages into your # The home.packages option allows you to install Nix packages into your
# environment. # environment.
home.packages = with pkgs; [ home.packages = with pkgs; [
# # Adds the 'hello' command to your environment. It prints a friendly wget
# # "Hello, world!" when run. curl
# pkgs.hello cacert
uv busybox
git gnugrep
dig
eza eza
gdu
lazygit
btop
yazi
(writeShellScriptBin "nhmu" '' (writeShellScriptBin "nhmu" ''
nix flake update --flake ~/.config/home-manager nix flake update --flake ~/.config/home-manager
nix run home-manager -- switch --flake ~/.config/home-manager nix run home-manager -- switch --flake ~/.config/home-manager
'') '')
(writeShellScriptBin "test-hm" ''
echo "${config.profile}"
'')
# # It is sometimes useful to fine-tune packages, for example, by applying # # It is sometimes useful to fine-tune packages, for example, by applying
# # overrides. You can do that directly here, just don't forget the # # overrides. You can do that directly here, just don't forget the
# # parentheses. Maybe you want to install Nerd Fonts with a limited number of # # parentheses. Maybe you want to install Nerd Fonts with a limited number of
# # fonts? # # fonts?
# (pkgs.nerdfonts.override { fonts = [ "FantasqueSansMono" ]; }) # (pkgs.nerdfonts.override { fonts = [ "FantasqueSansMono" ]; })
# # You can also create simple shell scripts directly inside your
# # configuration. For example, this adds a command 'my-hello' to your
# # environment:
# (pkgs.writeShellScriptBin "my-hello" ''
# echo "Hello, ${config.home.username}!"
# '')
]; ];
# Home Manager is pretty good at managing dotfiles. The primary way to manage # Home Manager is pretty good at managing dotfiles. The primary way to manage
@@ -81,5 +85,68 @@
# Let Home Manager install and manage itself. # Let Home Manager install and manage itself.
programs.home-manager.enable = true; programs.home-manager.enable = true;
# programs.ssh.enable = true; programs.zsh = lib.mkIf config.shell {
enable = true;
enableCompletion = true;
autosuggestion.enable = true;
syntaxHighlighting.enable = true;
oh-my-zsh = {
enable = true;
theme = "risto";
plugins = [
"sudo"
"dotenv"
"git"
"ssh"
"ssh-agent"
] ++ lib.optional config._1password "1password";
};
shellAliases.ls = "${pkgs.eza}/bin/eza -lgos type --no-time";
# initContent = lib.mkIf config._1password ''
# source ${config.home.homeDirectory}/.config/op/plugins.sh
# '';
};
programs.ssh = lib.mkIf config.ssh {
enable = true;
extraConfig = ''
SetEnv TERM="xterm-256color"
${lib.optionalString config._1password "IdentityAgent ~/.1password/agent.sock"}
'';
matchBlocks = lib.mkMerge [
(lib.mkIf (config.profile == "personal") {
"panoptes" = {
hostname = "192.168.1.107";
user = "panoptes";
};
"pve5070" = {
hostname = "192.168.1.130";
user = "root";
};
})
(lib.mkIf (config.profile == "work") {
"ubuntu-nvidia" = {
hostname = "10.118.46.120";
user = "john";
};
})
];
};
# https://developer.1password.com/docs/cli/shell-plugins/nix/
programs._1password-shell-plugins = lib.mkIf config._1password {
# enable 1Password shell plugins for bash, zsh, and fish shell
enable = true;
# the specified packages as well as 1Password CLI will be
# automatically installed and configured to use shell plugins
# https://developer.1password.com/docs/cli/shell-plugins
plugins = with pkgs; [ gh ];
};
home.file.".config/1Password/ssh/agent.toml" = lib.mkIf config._1password {
# https://developer.1password.com/docs/ssh/agent/config
text = ''
[[ssh-keys]]
vault = "Private"
'';
};
} }

32
options.nix Normal file
View File

@@ -0,0 +1,32 @@
{ lib, ... }:
{
options.user = lib.mkOption {
type = lib.types.str;
description = "The username for the Home Manager configuration.";
};
options.profile = lib.mkOption {
type = lib.types.enum [ "personal" "work" ];
default = "personal";
description = "Profile type for the Home Manager configuration.";
};
options.shell = lib.mkOption {
type = lib.types.bool;
default = true;
description = "Whether to enable all the zsh stuff";
};
options.ssh = lib.mkOption {
type = lib.types.bool;
default = true;
description = "Whether to enable SSH configuration";
};
options._1password = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Whether to enable 1 password stuff";
};
}