Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1ae16e2971 | ||
|
|
ee1f038f55 | ||
|
|
6afd99827c | ||
|
|
57d59a9dea | ||
|
|
c954124c13 | ||
|
|
f829f82885 | ||
|
|
8900ac44f0 | ||
|
|
bb145deb8e |
48
flake.nix
48
flake.nix
@@ -2,53 +2,31 @@
|
||||
description = "Home Manager configuration flake for JSL";
|
||||
|
||||
inputs = {
|
||||
# Specify the source of Home Manager and Nixpkgs.
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
home-manager = {
|
||||
url = "github:nix-community/home-manager";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
_1password-shell-plugins.url = "github:1Password/shell-plugins";
|
||||
};
|
||||
|
||||
outputs = { nixpkgs, home-manager, ... }:
|
||||
outputs = { nixpkgs, ... }@inputs:
|
||||
let
|
||||
system = "x86_64-linux";
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
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
|
||||
{
|
||||
# Default configuration using the default username
|
||||
homeConfigurations.${userName} = mkHomeConfiguration userName;
|
||||
|
||||
# Export the function so other flakes can create configurations for any user
|
||||
lib.mkHomeConfiguration = mkHomeConfiguration;
|
||||
|
||||
# Export modules for reuse in other flakes
|
||||
homeManagerModules.default = homeManagerModule;
|
||||
homeManagerModules.default = { ... }: {
|
||||
imports = [
|
||||
./options.nix
|
||||
./home.nix
|
||||
./git.nix
|
||||
inputs._1password-shell-plugins.hmModules.default
|
||||
];
|
||||
nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
|
||||
"1password-cli"
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
21
git.nix
Normal file
21
git.nix
Normal 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";
|
||||
})
|
||||
];
|
||||
}
|
||||
95
home.nix
95
home.nix
@@ -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
|
||||
# manage.
|
||||
home.username = config.user;
|
||||
@@ -18,29 +21,30 @@
|
||||
# The home.packages option allows you to install Nix packages into your
|
||||
# environment.
|
||||
home.packages = with pkgs; [
|
||||
# # Adds the 'hello' command to your environment. It prints a friendly
|
||||
# # "Hello, world!" when run.
|
||||
# pkgs.hello
|
||||
uv
|
||||
git
|
||||
wget
|
||||
curl
|
||||
cacert
|
||||
busybox
|
||||
gnugrep
|
||||
dig
|
||||
eza
|
||||
gdu
|
||||
lazygit
|
||||
btop
|
||||
yazi
|
||||
(writeShellScriptBin "nhmu" ''
|
||||
nix flake update --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
|
||||
# # 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
|
||||
# # fonts?
|
||||
# (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
|
||||
@@ -81,5 +85,68 @@
|
||||
# Let Home Manager install and manage itself.
|
||||
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
32
options.nix
Normal 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";
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user