Compare commits
39 Commits
v1
...
16bdff2d69
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
16bdff2d69 | ||
|
|
6094dd062d | ||
|
|
0d0a4b2429 | ||
|
|
de44f365fb | ||
|
|
7220d8eed2 | ||
|
|
322d4ee482 | ||
|
|
74a399b8da | ||
|
|
d0040bf42e | ||
|
|
4f7d24e8a7 | ||
|
|
6fec75538f | ||
|
|
8736ef6520 | ||
|
|
b3b27c5b56 | ||
|
|
1d0c88a021 | ||
|
|
0db404fd58 | ||
|
|
c1a9e401cb | ||
| 97b2e05f80 | |||
| 7ddbba1b85 | |||
| a8655471ee | |||
| b7aa2be8e7 | |||
|
|
e2fa10ae0d | ||
|
|
aa6e9a515f | ||
|
|
8b48ed06e2 | ||
|
|
9b4f75126e | ||
|
|
8ff937f722 | ||
|
|
d56d7ac9cd | ||
|
|
ee597577d4 | ||
|
|
6b78ef3a71 | ||
|
|
6fd8ceead7 | ||
|
|
537cda3889 | ||
|
|
0c7d55488b | ||
|
|
4c3f14b4ab | ||
|
|
1ae16e2971 | ||
|
|
ee1f038f55 | ||
|
|
6afd99827c | ||
|
|
57d59a9dea | ||
|
|
c954124c13 | ||
|
|
f829f82885 | ||
|
|
8900ac44f0 | ||
|
|
bb145deb8e |
97
flake.nix
97
flake.nix
@@ -2,53 +2,92 @@
|
||||
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 = { self, 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 ];
|
||||
userOptions = config: {
|
||||
openssh.authorizedKeys.keyFiles = lib.optionals config.ssh [ ./personal_keys ];
|
||||
extraGroups = lib.optionals config.root [ "wheel" ];
|
||||
shell = lib.mkIf config.shell pkgs.zsh;
|
||||
};
|
||||
|
||||
# Function to create a home configuration for any user
|
||||
mkHomeConfiguration = username: home-manager.lib.homeManagerConfiguration {
|
||||
inherit pkgs;
|
||||
modules = [ homeManagerModule { user = username; } ];
|
||||
};
|
||||
homeManagerModules = config: [
|
||||
self.homeManagerModules.default {
|
||||
user = config.user;
|
||||
stateVersion = config.stateVersion;
|
||||
profile = config.profile;
|
||||
shell = config.shell;
|
||||
ssh = config.ssh;
|
||||
_1password = config._1password;
|
||||
}
|
||||
] ++ config.extraImports;
|
||||
|
||||
# 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;
|
||||
homeManagerModules.default = { ... }: {
|
||||
imports = [
|
||||
./nixosModules/options.nix
|
||||
./home.nix
|
||||
inputs._1password-shell-plugins.hmModules.default
|
||||
];
|
||||
nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
|
||||
"1password-cli"
|
||||
];
|
||||
|
||||
# Export the function so other flakes can create configurations for any user
|
||||
lib.mkHomeConfiguration = mkHomeConfiguration;
|
||||
home.packages = with pkgs; [
|
||||
(writeShellScriptBin "nhmu" ''
|
||||
nix flake update --flake ~/.config/home-manager
|
||||
nix run home-manager -- switch --flake ~/.config/home-manager
|
||||
'')
|
||||
];
|
||||
};
|
||||
|
||||
# Export modules for reuse in other flakes
|
||||
homeManagerModules.default = homeManagerModule;
|
||||
nixosModules.default = { config, ... }: {
|
||||
imports = [
|
||||
./nixosModules/options.nix
|
||||
./nixosModules/scripts.nix
|
||||
inputs.home-manager.nixosModules.default
|
||||
];
|
||||
nix.settings.trusted-users = [ "root" "@wheel" ];
|
||||
users.users.${config.user} = {
|
||||
isNormalUser = true;
|
||||
} // userOptions config;
|
||||
|
||||
users.users.root = lib.mkIf config.root (userOptions config);
|
||||
security.sudo-rs = lib.mkIf config.root {
|
||||
enable = true;
|
||||
execWheelOnly = false;
|
||||
wheelNeedsPassword = false;
|
||||
extraConfig = "Defaults timestamp_timeout=1440";
|
||||
};
|
||||
|
||||
programs.zsh.enable = lib.mkIf config.shell true;
|
||||
|
||||
home-manager = {
|
||||
useUserPackages = true;
|
||||
extraSpecialArgs = { inherit inputs; };
|
||||
users = {
|
||||
${config.user} = {
|
||||
imports = homeManagerModules config;
|
||||
};
|
||||
} // lib.optionalAttrs config.root {
|
||||
root = {
|
||||
# home.stateVersion = config.stateVersion;
|
||||
imports = homeManagerModules (config // { user = "root"; });
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
80
home.nix
80
home.nix
@@ -1,63 +1,38 @@
|
||||
{ config, pkgs, ... }:
|
||||
{ config, pkgs, lib, inputs, ... }:
|
||||
|
||||
{
|
||||
imports = [
|
||||
./homeManagerModules/git.nix
|
||||
./homeManagerModules/shell.nix
|
||||
./homeManagerModules/ssh.nix
|
||||
# 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;
|
||||
home.homeDirectory = "/home/${config.user}";
|
||||
|
||||
# This value determines the Home Manager release that your configuration is
|
||||
# compatible with. This helps avoid breakage when a new Home Manager release
|
||||
# introduces backwards incompatible changes.
|
||||
#
|
||||
# You should not change this value, even if you update Home Manager. If you do
|
||||
# want to update the value, then make sure to first check the Home Manager
|
||||
# release notes.
|
||||
home.stateVersion = "25.05"; # Please read the comment before changing.
|
||||
home.homeDirectory = lib.mkIf (config.user != "root") "/home/${config.user}";
|
||||
home.stateVersion = config.stateVersion;
|
||||
|
||||
# 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
|
||||
eza
|
||||
(writeShellScriptBin "nhmu" ''
|
||||
nix flake update --flake ~/.config/home-manager
|
||||
nix run home-manager -- switch --flake ~/.config/home-manager
|
||||
'')
|
||||
|
||||
wget
|
||||
curl
|
||||
cacert
|
||||
busybox
|
||||
gnugrep
|
||||
dig
|
||||
gdu
|
||||
lazygit
|
||||
btop
|
||||
yazi
|
||||
# # 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
|
||||
# plain files is through 'home.file'.
|
||||
home.file = {
|
||||
# # Building this configuration will create a copy of 'dotfiles/screenrc' in
|
||||
# # the Nix store. Activating the configuration will then make '~/.screenrc' a
|
||||
# # symlink to the Nix store copy.
|
||||
# ".screenrc".source = dotfiles/screenrc;
|
||||
|
||||
# # You can also set the file content immediately.
|
||||
# ".gradle/gradle.properties".text = ''
|
||||
# org.gradle.console=verbose
|
||||
# org.gradle.daemon.idletimeout=3600000
|
||||
# '';
|
||||
};
|
||||
|
||||
# Home Manager can also manage your environment variables through
|
||||
# 'home.sessionVariables'. These will be explicitly sourced when using a
|
||||
# shell provided by Home Manager. If you don't want to manage your shell
|
||||
@@ -81,5 +56,20 @@
|
||||
# Let Home Manager install and manage itself.
|
||||
programs.home-manager.enable = true;
|
||||
|
||||
# programs.ssh.enable = true;
|
||||
# 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"
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
||||
21
homeManagerModules/git.nix
Normal file
21
homeManagerModules/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";
|
||||
})
|
||||
];
|
||||
}
|
||||
44
homeManagerModules/shell.nix
Normal file
44
homeManagerModules/shell.nix
Normal file
@@ -0,0 +1,44 @@
|
||||
{ config, pkgs, lib, inputs, ... }:
|
||||
{
|
||||
home.packages = with pkgs; [
|
||||
eza
|
||||
(writeShellScriptBin "test-pkgs" ''
|
||||
echo "Hello from ~/.config/home-manager/home.nix!"
|
||||
'')
|
||||
];
|
||||
programs.zsh = lib.mkIf config.shell {
|
||||
enable = true;
|
||||
enableCompletion = true;
|
||||
autosuggestion.enable = true;
|
||||
# syntaxHighlighting.enable = true;
|
||||
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"
|
||||
] ++ 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
|
||||
'';
|
||||
};
|
||||
}
|
||||
32
homeManagerModules/ssh.nix
Normal file
32
homeManagerModules/ssh.nix
Normal file
@@ -0,0 +1,32 @@
|
||||
{ config, lib, ... }:
|
||||
{
|
||||
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";
|
||||
};
|
||||
"nix-test" = {
|
||||
hostname = "192.168.1.36";
|
||||
user = "john";
|
||||
};
|
||||
})
|
||||
(lib.mkIf (config.profile == "work") {
|
||||
"ubuntu-nvidia" = {
|
||||
hostname = "10.118.46.120";
|
||||
user = "john";
|
||||
};
|
||||
})
|
||||
];
|
||||
};
|
||||
}
|
||||
56
nixosModules/options.nix
Normal file
56
nixosModules/options.nix
Normal file
@@ -0,0 +1,56 @@
|
||||
{ lib, ... }:
|
||||
|
||||
{
|
||||
options.user = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "The username for the Home Manager configuration.";
|
||||
};
|
||||
|
||||
# This value determines the Home Manager release that your configuration is
|
||||
# compatible with. This helps avoid breakage when a new Home Manager release
|
||||
# introduces backwards incompatible changes.
|
||||
#
|
||||
# You should not change this value, even if you update Home Manager. If you do
|
||||
# want to update the value, then make sure to first check the Home Manager
|
||||
# release notes.
|
||||
options.stateVersion = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "The state version when the configuration was initially created";
|
||||
};
|
||||
|
||||
options.profile = lib.mkOption {
|
||||
type = lib.types.enum [ "personal" "work" ];
|
||||
default = "personal";
|
||||
description = "Profile type for the Home Manager configuration.";
|
||||
};
|
||||
|
||||
options.root = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
description = "Whether enable all the root user stuff";
|
||||
};
|
||||
|
||||
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";
|
||||
};
|
||||
|
||||
options.extraImports = lib.mkOption {
|
||||
type = lib.types.listOf lib.types.anything;
|
||||
default = [];
|
||||
description = "Additional Home Manager modules to import";
|
||||
};
|
||||
}
|
||||
16
nixosModules/scripts.nix
Normal file
16
nixosModules/scripts.nix
Normal file
@@ -0,0 +1,16 @@
|
||||
{ config, pkgs, ... }:
|
||||
let
|
||||
hostName = config.networking.hostName;
|
||||
in
|
||||
{
|
||||
environment.systemPackages = with pkgs; [
|
||||
(pkgs.writeShellScriptBin "nfs" ''
|
||||
sudo nixos-rebuild switch --flake $(readlink -f /etc/nixos)#${hostName} --impure
|
||||
'')
|
||||
(pkgs.writeShellScriptBin "nfsu" ''
|
||||
FLAKE=$(readlink -f /etc/nixos)
|
||||
nix flake update --flake $FLAKE --impure
|
||||
sudo nixos-rebuild switch --flake $FLAKE#${hostName} --impure
|
||||
'')
|
||||
];
|
||||
}
|
||||
3
personal_keys
Normal file
3
personal_keys
Normal file
@@ -0,0 +1,3 @@
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDIaHS9CLiDc6T1tja0fBwwv5qc6iwuckWN6w8MNo5yiR8LPWyrfueowNJkL4HMqu6OEuggtdybGw1Do4sW5o+toHCyWfZf3khI1l15opPXuVpD4CWED+SpJiZ0wBgRaCaWhfxLI+s4JOhjOO2OjiClPX3HfxIHyTpRiR78lOMcIieHSnzrAV2MatYKf6lL2ckOsIPwxo/OVM+1ljjX+HLq9IxGUCpWOnF4nF1rq3gKL2JUh2KsrgrzE3NB7EFuqKm8F0tF2rG3JjSvlwox0h06drKD02lpZWXPOBRlcyFDpNXymmc2bpG0S2Bbj5g+pqNBB0jO0h3kzWvYYqrtU/ElObg1cXhyi0PFOhhptlbhbK0Ao8B+pAbSZ661nMT3jpRWLVbnJrRFnXXdjX08r5eseQ3k4CFpv+g64n7yg3IMo9f8gA9P/hOexR+qu5AQ1Ad/tvkp6pPXnR/zsUnbe4p2A9MaNJm4E1zxbs5VGlXynNikXwDL+spkrnjwdfUULTk= john@JOHN-PC
|
||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFn5ilhqaeDsOWSk7y29se2NvxGm8djlfL3RGLokj0q6 john@john-p14s
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDHh9SBuxU2dOJHnpGZAE4cwe0fXcTBBAx+JmRsmIX+Tk8zooeM32vbNxxSXiZNpBGH5wzHNb534dWexGGG3sOaONmcL7SCoPIvaAdnIn5VsiznerLrzppSbx3Qn8eyF97WAGCcOcIUNmTIDDx1m6zG762WQnoaUEy0Ul5IR7ET5GQxP3p5Qwx8yqfixKDwarvV421sUIxYt9gee31jS9jcI3MFd6EL57hWle95Z8BGpR/Q7sXDBTZQWMZauh5NPwLMZS7k3bHgxXZ7WNOw/J/yts1ckBbvIFJSRNnMuWD0oGnDTL6aivGi+Eiswp0fpKzYGzquB3/wr3VU4G1JcMM5 JuiceSSH
|
||||
Reference in New Issue
Block a user