Compare commits

...

8 commits

Author SHA1 Message Date
a58684c0a3 Add .chat to .gitignore to exclude chat files from version control 2025-04-24 01:05:19 -04:00
91ecc62472 Update readme.md 2025-04-24 01:05:19 -04:00
4c9b07a8f0 Setup git-crypt for secrets.nix, enables gnupg in nix as well. 2025-04-24 01:05:19 -04:00
3682ace397 Add 1 git-crypt collaborator
New collaborators:

	9449ECE5 Toph (decrypt git) <toph@ryot.foo>
2025-04-24 01:05:18 -04:00
b65fdb30ba Refactor user authentication to use hashed passwords across all configurations 2025-04-24 01:05:18 -04:00
167fcde3cb Add known_hosts support in SSH secrets
• Append known_hosts file generation using defined SSH entries
• Change knownHosts type from attribute set to list for simplicity
2025-04-24 01:05:18 -04:00
38087f582e Refactor git configuration to use userFullName instead of handle 2025-04-24 01:05:18 -04:00
2e4db2b86c Refactor user configuration to utilize secret-based management and remove deprecated environment files 2025-04-24 01:05:18 -04:00
27 changed files with 123 additions and 130 deletions

4
.git-crypt/.gitattributes vendored Normal file
View file

@ -0,0 +1,4 @@
# Do not edit this file. To specify the files to encrypt, create your own
# .gitattributes file in the directory where your files are.
* !filter !diff
*.gpg binary

3
.gitattributes vendored
View file

@ -1,2 +1,5 @@
# Auto detect text files and perform LF normalization # Auto detect text files and perform LF normalization
* text=auto * text=auto
# git-crypt
secrets.nix filter=git-crypt diff=git-crypt

1
.gitignore vendored
View file

@ -1,4 +1,5 @@
nixos/modules/nextcloud/nextcloud-admin-pass nixos/modules/nextcloud/nextcloud-admin-pass
.BAK/ .BAK/
.chat
*.bak *.bak

25
.vscode/settings.json vendored
View file

@ -1,16 +1,25 @@
{ {
"explorer.fileNesting.patterns": {
".gitignore": ".gitattributes, .envrc, readme",
"flake.nix": "flake.lock, shell.nix, checks.nix"
},
"editor.formatOnSave": true, "editor.formatOnSave": true,
"editor.formatOnSaveMode": "file", "editor.formatOnSaveMode": "file",
"explorer.fileNesting.patterns": {
".gitignore": ".gitattributes, .envrc, readme",
"flake.nix": "flake.lock, shell.nix, secrets.nix"
},
"files.exclude": {
".git-crypt": true
},
"terminal.integrated.defaultProfile.linux": "fish-fhs", "terminal.integrated.defaultProfile.linux": "fish-fhs",
"terminal.integrated.profiles.linux": { "terminal.integrated.profiles.linux": {
// ...
"fish-fhs": { "fish-fhs": {
"path": "systemd-run", "args": [
"args": ["--user", "--pty", "--quiet", "--same-dir", "--service-type=exec", "fish"] "--user",
"--pty",
"--quiet",
"--same-dir",
"--service-type=exec",
"fish"
],
"path": "systemd-run"
} }
} }
} }

View file

@ -6,13 +6,18 @@
inputs, inputs,
... ...
}: }:
let
# handle = config.hostSpec.handle;
fullName = config.hostSpec.userFullName;
email = config.hostSpec.email;
in
{ {
programs.git = { programs.git = {
enable = true; enable = true;
package = pkgs.gitAndTools.gitFull; package = pkgs.gitAndTools.gitFull;
userName = "[REDACTED]"; userName = fullName;
userEmail = "[REDACTED]"; userEmail = email;
ignores = [ ignores = [
".csvignore" ".csvignore"

View file

@ -42,6 +42,8 @@ in
chmod 400 $HOME/.ssh/config chmod 400 $HOME/.ssh/config
''; '';
}; };
".ssh/known_hosts".text = lib.concatStringsSep "\n" secretsSpec.ssh.knownHosts;
} }
# Dynamically add all SSH private keys using the existing store paths # Dynamically add all SSH private keys using the existing store paths
# Ensures the keys have correct permissions and are not symlinks # Ensures the keys have correct permissions and are not symlinks

View file

@ -21,6 +21,9 @@
# System-wide packages, in case we log in as root # System-wide packages, in case we log in as root
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
curl curl
git
git-crypt
gpg-tui
micro micro
openssh openssh
ranger ranger

View file

@ -0,0 +1,9 @@
{ pkgs, ... }:
{
# GnuPG
programs.gnupg.agent = {
enable = true;
pinentryPackage = pkgs.pinentry-gnome3;
};
services.pcscd.enable = true;
}

View file

@ -18,5 +18,5 @@
}; };
}; };
networking.[REDACTED] 22 ]; networking.firewall.allowedTCPPorts = [ 22 ];
} }

View file

@ -11,15 +11,15 @@
}: }:
let let
hostSpec = config.hostSpec.username; user = config.hostSpec.username;
default = { default = {
command = "${pkgs.greetd.tuigreet}/bin/tuigreet --asterisks --time --time-format '%I:%M %p | %a %h | %F' --cmd uwsm start default"; command = "${pkgs.greetd.tuigreet}/bin/tuigreet --asterisks --time --time-format '%I:%M %p | %a %h | %F' --cmd uwsm start default";
user = "toph"; user = user;
}; };
initial = { initial = {
# command = "${pkgs.hyprland}/bin/Hyprland"; # command = "${pkgs.hyprland}/bin/Hyprland";
command = "uwsm start default"; command = "uwsm start default";
user = "toph"; user = user;
}; };
in in
{ {

View file

@ -14,6 +14,8 @@
}: }:
let let
username = "toph"; username = "toph";
user = config.secretsSpec.users.${username};
firewall = config.secretsSpec.firewall.cloud;
in in
{ {
imports = lib.flatten [ imports = lib.flatten [
@ -39,22 +41,16 @@ in
hostSpec = { hostSpec = {
hostName = "cloud"; hostName = "cloud";
username = username; username = username;
handle = "tophC7"; hashedPassword = user.hashedPassword;
password = "[REDACTED]"; email = user.email;
[REDACTED]; handle = user.handle;
email = "[REDACTED]"; userFullName = user.fullName;
userFullName = "[REDACTED]"; isServer = true;
isARM = false;
}; };
networking = { networking = {
enableIPv6 = false; enableIPv6 = false;
# Container Ports firewall.allowedTCPPorts = firewall.allowedTCPPorts;
[REDACTED]
80 # Caddy
443 # Caddy
[REDACTED]
];
}; };
## System-wide packages ## ## System-wide packages ##

View file

@ -14,6 +14,8 @@
}: }:
let let
username = "toph"; username = "toph";
user = config.secretsSpec.users.${username};
firewall = config.secretsSpec.firewall.komodo;
in in
{ {
imports = lib.flatten [ imports = lib.flatten [
@ -40,47 +42,19 @@ in
hostSpec = { hostSpec = {
hostName = "komodo"; hostName = "komodo";
username = username; username = username;
handle = "tophC7"; hashedPassword = user.hashedPassword;
password = "[REDACTED]"; email = user.email;
[REDACTED]; handle = user.handle;
email = "[REDACTED]"; userFullName = user.fullName;
userFullName = "[REDACTED]"; isServer = true;
isARM = false;
}; };
networking = { networking = {
enableIPv6 = false; enableIPv6 = false;
# Container Ports
firewall = { firewall = {
allowedTCPPorts = [ allowedTCPPorts = firewall.allowedTCPPorts;
[REDACTED] allowedTCPPortRanges = firewall.allowedTCPPortRanges;
[REDACTED] allowedUDPPorts = firewall.allowedUDPPorts;
[REDACTED]
222 # Forgejo SSH
[REDACTED]
[REDACTED]
[REDACTED]
[REDACTED]
[REDACTED]
8080 # File Browser
[REDACTED]
[REDACTED]
[REDACTED]
[REDACTED]
[REDACTED]
];
# Game Server Ports
allowedTCPPortRanges = [
{
[REDACTED]
[REDACTED]
}
];
allowedUDPPorts = [
8089 # Grafana
];
}; };
}; };
@ -91,12 +65,6 @@ in
compose2nix compose2nix
]; ];
# environment.etc = {
# "cloudflared/.keep" = {
# text = "This directory is used to store cloudflared configuration files.";
# };
# };
# https://wiki.nixos.org/wiki/FAQ/When_do_I_update_stateVersion # https://wiki.nixos.org/wiki/FAQ/When_do_I_update_stateVersion
system.stateVersion = "24.11"; system.stateVersion = "24.11";
} }

View file

@ -16,6 +16,7 @@
}: }:
let let
username = "toph"; username = "toph";
user = config.secretsSpec.users.${username};
in in
{ {
imports = lib.flatten [ imports = lib.flatten [
@ -35,12 +36,11 @@ in
hostSpec = { hostSpec = {
hostName = "lxc"; hostName = "lxc";
username = username; username = username;
handle = "tophC7"; hashedPassword = user.hashedPassword;
password = "[REDACTED]"; email = user.email;
[REDACTED]; handle = user.handle;
email = "[REDACTED]"; userFullName = user.fullName;
userFullName = "[REDACTED]"; isServer = true;
isARM = false;
}; };
networking = { networking = {

View file

@ -16,6 +16,7 @@
}: }:
let let
username = "toph"; username = "toph";
user = config.secretsSpec.users.${username};
in in
{ {
imports = lib.flatten [ imports = lib.flatten [
@ -37,12 +38,11 @@ in
hostSpec = { hostSpec = {
hostName = "nix"; hostName = "nix";
username = username; username = username;
handle = "tophC7"; hashedPassword = user.hashedPassword;
password = "[REDACTED]"; email = user.email;
[REDACTED]; handle = user.handle;
email = "[REDACTED]"; userFullName = user.fullName;
userFullName = "[REDACTED]"; isServer = true;
isARM = false;
}; };
networking = { networking = {
@ -54,12 +54,6 @@ in
# environment.systemPackages = with pkgs; [ # environment.systemPackages = with pkgs; [
# ]; # ];
# environment.etc = {
# "cloudflared/.keep" = {
# text = "This directory is used to store cloudflared configuration files.";
# };
# };
# https://wiki.nixos.org/wiki/FAQ/When_do_I_update_stateVersion # https://wiki.nixos.org/wiki/FAQ/When_do_I_update_stateVersion
system.stateVersion = "24.11"; system.stateVersion = "24.11";
} }

View file

@ -14,6 +14,8 @@
}: }:
let let
username = "toph"; username = "toph";
user = config.secretsSpec.users.${username};
firewall = config.secretsSpec.firewall.proxy;
in in
{ {
imports = lib.flatten [ imports = lib.flatten [
@ -39,22 +41,16 @@ in
hostSpec = { hostSpec = {
hostName = "proxy"; hostName = "proxy";
username = username; username = username;
handle = "tophC7"; hashedPassword = user.hashedPassword;
password = "[REDACTED]"; email = user.email;
[REDACTED]; handle = user.handle;
email = "[REDACTED]"; userFullName = user.fullName;
userFullName = "[REDACTED]"; isServer = true;
isARM = false;
}; };
networking = { networking = {
enableIPv6 = false; enableIPv6 = false;
# Container Ports firewall.allowedTCPPorts = firewall.allowedTCPPorts;
[REDACTED]
80 # Caddy
443 # Caddy
[REDACTED]
];
}; };
## System-wide packages ## ## System-wide packages ##

View file

@ -14,6 +14,7 @@
}: }:
let let
username = "toph"; username = "toph";
user = config.secretsSpec.users.${username};
in in
{ {
imports = lib.flatten [ imports = lib.flatten [
@ -53,12 +54,11 @@ in
hostSpec = { hostSpec = {
hostName = "rune"; hostName = "rune";
username = username; username = username;
handle = "tophC7"; hashedPassword = user.hashedPassword;
password = "[REDACTED]"; email = user.email;
[REDACTED]; handle = user.handle;
email = "[REDACTED]"; userFullName = user.fullName;
userFullName = "[REDACTED]"; isServer = true;
isARM = false;
}; };
networking = { networking = {

View file

@ -14,6 +14,7 @@
}: }:
let let
username = "toph"; username = "toph";
user = config.secretsSpec.users.${username};
in in
{ {
imports = lib.flatten [ imports = lib.flatten [
@ -45,12 +46,11 @@ in
hostSpec = { hostSpec = {
hostName = "vm"; hostName = "vm";
username = username; username = username;
handle = "tophC7"; hashedPassword = user.hashedPassword;
password = "[REDACTED]"; email = user.email;
[REDACTED]; handle = user.handle;
email = "[REDACTED]"; userFullName = user.fullName;
userFullName = "[REDACTED]"; isServer = true;
isARM = false;
}; };
networking = { networking = {

View file

@ -25,7 +25,7 @@ in
createHome = true; createHome = true;
description = "Admin"; description = "Admin";
homeMode = "750"; homeMode = "750";
password = hostSpec.password; hashedPassword = hostSpec.hashedPassword;
uid = 1000; uid = 1000;
group = "ryot"; group = "ryot";
extraGroups = lib.flatten [ extraGroups = lib.flatten [
@ -51,7 +51,7 @@ in
# root's ssh key are mainly used for remote deployment, borg, and some other specific ops # root's ssh key are mainly used for remote deployment, borg, and some other specific ops
users.users.root = { users.users.root = {
shell = pkgs.bash; shell = pkgs.bash;
password = lib.mkForce hostSpec.password; hashedPassword = lib.mkForce hostSpec.hashedPassword;
openssh.authorizedKeys.keys = config.users.users.${hostSpec.username}.openssh.authorizedKeys.keys; # root's ssh keys are mainly used for remote deployment. openssh.authorizedKeys.keys = config.users.users.${hostSpec.username}.openssh.authorizedKeys.keys; # root's ssh keys are mainly used for remote deployment.
}; };
} }

View file

@ -14,7 +14,7 @@ in
# Set a temp password for use by minimal builds like installer and iso # Set a temp password for use by minimal builds like installer and iso
users.users.${hostSpec.username} = { users.users.${hostSpec.username} = {
isNormalUser = true; isNormalUser = true;
password = hostSpec.password; hashedPassword = hostSpec.hashedPassword;
group = "ryot"; group = "ryot";
extraGroups = [ extraGroups = [
"wheel" "wheel"

View file

@ -17,7 +17,7 @@
description = "The username for the host's user"; description = "The username for the host's user";
}; };
password = lib.mkOption { hashedPassword = lib.mkOption {
type = lib.types.str; type = lib.types.str;
description = "Hashed password for the host's user"; description = "Hashed password for the host's user";
}; };

View file

@ -42,9 +42,9 @@ in
default = { }; default = { };
}; };
knownHosts = lib.mkOption { knownHosts = lib.mkOption {
type = lib.types.attrsOf lib.types.str; type = lib.types.listOf lib.types.str;
description = "SSH known hosts entries keyed by hostname"; description = "SSH known hosts entries";
default = { }; default = [ ];
}; };
}; };
}; };
@ -68,7 +68,7 @@ in
type = lib.types.attrsOf ( type = lib.types.attrsOf (
lib.types.submodule { lib.types.submodule {
options = { options = {
password = lib.mkOption { hashedPassword = lib.mkOption {
type = lib.types.str; type = lib.types.str;
description = "Hashed password for the user"; # nix-shell -p whois --run 'mkpasswd --method=sha-512 --rounds=656000' description = "Hashed password for the user"; # nix-shell -p whois --run 'mkpasswd --method=sha-512 --rounds=656000'
}; };
@ -129,8 +129,8 @@ in
default = [ ]; default = [ ];
# example = [ # example = [
# { # {
# [REDACTED] # from = 25565;
# [REDACTED] # to = 25570;
# } # }
# ]; # ];
}; };
@ -162,8 +162,8 @@ in
default = [ ]; default = [ ];
# example = [ # example = [
# { # {
# [REDACTED] # from = 25565;
# [REDACTED] # to = 25570;
# } # }
# ]; # ];
}; };

View file

@ -20,20 +20,20 @@ sendon = success,error
; set to false to get full programm output via email ; set to false to get full programm output via email
short = true short = true
subject = [SnapRAID] Status Report: subject = [SnapRAID] Status Report:
from = [REDACTED] from =
to = [REDACTED] to =
; maximum email size in KiB ; maximum email size in KiB
maxsize = 500 maxsize = 500
[smtp] [smtp]
host = smtp.protonmail.ch host =
; leave empty for default port ; leave empty for default port
port = 587 port = 587
; set to "true" to activate ; set to "true" to activate
ssl = true ssl = true
tls = true tls = true
user = [REDACTED] user =
password = [REDACTED] password =
[scrub] [scrub]
; set to true to run scrub after sync ; set to true to run scrub after sync

3
readme
View file

@ -1,3 +0,0 @@
# My .dotfiles
Separated by branch

3
readme.md Normal file
View file

@ -0,0 +1,3 @@
# dot.nix
My overly complex dot.files for my Homelab and PCs :D

BIN
secrets.nix Normal file

Binary file not shown.

View file

@ -34,6 +34,9 @@ in
# Git for repo management # Git for repo management
git git
git-crypt
gnupg
gpg-tui
# Shells # Shells
fish fish