refactor: reduce duplication and improve consistency across hosts
- Centralize home-manager _module.args in profiles/nixos.nix via sharedModules - Add lib/secrets.nix with mkSyncthingSecrets helper for DRY secret definitions - Move syncthing device IDs to lib/constants.nix - Standardize hostname handling (Darwin hosts now use hostname arg) - Add missing networking.hostName to tahani - Fix redundant string interpolations
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
inputs,
|
||||
pkgs,
|
||||
user,
|
||||
constants,
|
||||
hostname,
|
||||
...
|
||||
}: {
|
||||
imports = [
|
||||
@@ -18,8 +18,8 @@
|
||||
inputs.sops-nix.darwinModules.sops
|
||||
];
|
||||
|
||||
networking.hostName = "chidi";
|
||||
networking.computerName = "Chidi";
|
||||
networking.hostName = hostname;
|
||||
networking.computerName = hostname;
|
||||
|
||||
home-manager.users.${user} = {
|
||||
imports = [
|
||||
|
||||
@@ -1,18 +1,14 @@
|
||||
{user, ...}: {
|
||||
{
|
||||
user,
|
||||
hostname,
|
||||
...
|
||||
}: let
|
||||
secrets = import ../../lib/secrets.nix;
|
||||
in {
|
||||
sops.age.keyFile = "/Users/${user}/.config/sops/age/keys.txt";
|
||||
|
||||
sops.secrets = {
|
||||
chidi-syncthing-cert = {
|
||||
sopsFile = ../../secrets/chidi-syncthing-cert;
|
||||
format = "binary";
|
||||
owner = user;
|
||||
path = "/Users/${user}/.config/syncthing/cert.pem";
|
||||
};
|
||||
chidi-syncthing-key = {
|
||||
sopsFile = ../../secrets/chidi-syncthing-key;
|
||||
format = "binary";
|
||||
owner = user;
|
||||
path = "/Users/${user}/.config/syncthing/key.pem";
|
||||
};
|
||||
sops.secrets = secrets.mkSyncthingSecrets {
|
||||
inherit hostname user;
|
||||
isDarwin = true;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
inputs,
|
||||
user,
|
||||
hostname,
|
||||
...
|
||||
}: {
|
||||
imports = [
|
||||
@@ -16,8 +17,8 @@
|
||||
inputs.sops-nix.darwinModules.sops
|
||||
];
|
||||
|
||||
networking.hostName = "jason";
|
||||
networking.computerName = "Jason";
|
||||
networking.hostName = hostname;
|
||||
networking.computerName = hostname;
|
||||
|
||||
home-manager.users.${user} = {
|
||||
imports = [
|
||||
|
||||
@@ -1,20 +1,16 @@
|
||||
{user, ...}: {
|
||||
{
|
||||
user,
|
||||
hostname,
|
||||
...
|
||||
}: let
|
||||
secrets = import ../../lib/secrets.nix;
|
||||
in {
|
||||
sops.age.keyFile = "/Users/${user}/.config/sops/age/keys.txt";
|
||||
sops.age.sshKeyPaths = [];
|
||||
sops.gnupg.sshKeyPaths = [];
|
||||
|
||||
sops.secrets = {
|
||||
jason-syncthing-cert = {
|
||||
sopsFile = ../../secrets/jason-syncthing-cert;
|
||||
format = "binary";
|
||||
owner = user;
|
||||
path = "/Users/${user}/.config/syncthing/cert.pem";
|
||||
};
|
||||
jason-syncthing-key = {
|
||||
sopsFile = ../../secrets/jason-syncthing-key;
|
||||
format = "binary";
|
||||
owner = user;
|
||||
path = "/Users/${user}/.config/syncthing/key.pem";
|
||||
};
|
||||
sops.secrets = secrets.mkSyncthingSecrets {
|
||||
inherit hostname user;
|
||||
isDarwin = true;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
hostname,
|
||||
inputs,
|
||||
user,
|
||||
constants,
|
||||
...
|
||||
}: {
|
||||
imports = [
|
||||
@@ -23,11 +22,6 @@
|
||||
];
|
||||
|
||||
home-manager.users.${user} = {
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: {
|
||||
_module.args = {inherit user constants inputs;};
|
||||
imports = [
|
||||
inputs.nixvim.homeModules.nixvim
|
||||
../../profiles/bash.nix
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
hostname,
|
||||
inputs,
|
||||
user,
|
||||
constants,
|
||||
...
|
||||
}: {
|
||||
imports = [
|
||||
@@ -25,11 +24,6 @@
|
||||
];
|
||||
|
||||
home-manager.users.${user} = {
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: {
|
||||
_module.args = {inherit user constants inputs;};
|
||||
imports = [
|
||||
inputs.nixvim.homeModules.nixvim
|
||||
../../profiles/bash.nix
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
inputs,
|
||||
pkgs,
|
||||
user,
|
||||
constants,
|
||||
hostname,
|
||||
...
|
||||
}: {
|
||||
imports = [
|
||||
@@ -20,11 +20,6 @@
|
||||
];
|
||||
|
||||
home-manager.users.${user} = {
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: {
|
||||
_module.args = {inherit user constants inputs;};
|
||||
imports = [
|
||||
inputs.nixvim.homeModules.nixvim
|
||||
../../profiles/atuin.nix
|
||||
@@ -60,4 +55,6 @@
|
||||
};
|
||||
|
||||
virtualisation.docker.enable = true;
|
||||
|
||||
networking.hostName = hostname;
|
||||
}
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
{user, ...}: {
|
||||
sops.secrets = {
|
||||
tahani-syncthing-cert = {
|
||||
sopsFile = ../../secrets/tahani-syncthing-cert;
|
||||
format = "binary";
|
||||
owner = user;
|
||||
path = "/home/${user}/.config/syncthing/cert.pem";
|
||||
{
|
||||
user,
|
||||
hostname,
|
||||
...
|
||||
}: let
|
||||
secrets = import ../../lib/secrets.nix;
|
||||
in {
|
||||
sops.secrets =
|
||||
secrets.mkSyncthingSecrets {
|
||||
inherit hostname user;
|
||||
isDarwin = false;
|
||||
}
|
||||
// {
|
||||
tahani-paperless-password = {
|
||||
sopsFile = ../../secrets/tahani-paperless-password;
|
||||
format = "binary";
|
||||
};
|
||||
};
|
||||
tahani-syncthing-key = {
|
||||
sopsFile = ../../secrets/tahani-syncthing-key;
|
||||
format = "binary";
|
||||
owner = user;
|
||||
path = "/home/${user}/.config/syncthing/key.pem";
|
||||
};
|
||||
tahani-paperless-password = {
|
||||
sopsFile = ../../secrets/tahani-paperless-password;
|
||||
format = "binary";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -11,4 +11,10 @@
|
||||
nixos = "25.11";
|
||||
homeManager = "25.11";
|
||||
};
|
||||
|
||||
syncthingDeviceIds = {
|
||||
tahani = "6B7OZZF-TEAMUGO-FBOELXP-Z4OY7EU-5ZHLB5T-V6Z3UDB-Q2DYR43-QBYW6QM";
|
||||
jason = "42II2VO-QYPJG26-ZS3MB2I-AOPVZ67-JJNSE76-U54CO5Y-634A5OG-ECU4YQA";
|
||||
chidi = "N7W6SUT-QO6J4BE-T3Y65SM-OFGYGNV-TGYBJPX-JVN4Z72-AENZ247-KWXOQA6";
|
||||
};
|
||||
}
|
||||
|
||||
25
lib/secrets.nix
Normal file
25
lib/secrets.nix
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
mkSyncthingSecrets = {
|
||||
hostname,
|
||||
user,
|
||||
isDarwin,
|
||||
}: let
|
||||
homeDir =
|
||||
if isDarwin
|
||||
then "/Users/${user}"
|
||||
else "/home/${user}";
|
||||
in {
|
||||
"${hostname}-syncthing-cert" = {
|
||||
sopsFile = ../secrets/${hostname}-syncthing-cert;
|
||||
format = "binary";
|
||||
owner = user;
|
||||
path = "${homeDir}/.config/syncthing/cert.pem";
|
||||
};
|
||||
"${hostname}-syncthing-key" = {
|
||||
sopsFile = ../secrets/${hostname}-syncthing-key;
|
||||
format = "binary";
|
||||
owner = user;
|
||||
path = "${homeDir}/.config/syncthing/key.pem";
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -53,7 +53,7 @@
|
||||
};
|
||||
|
||||
users.users.${user} = {
|
||||
name = "${user}";
|
||||
name = user;
|
||||
home = "/Users/${user}";
|
||||
isHidden = false;
|
||||
shell = pkgs.fish;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
pkgs,
|
||||
user,
|
||||
constants,
|
||||
inputs,
|
||||
...
|
||||
}: {
|
||||
security.sudo.enable = true;
|
||||
@@ -9,8 +10,12 @@
|
||||
system.stateVersion = constants.stateVersions.nixos;
|
||||
time.timeZone = "UTC";
|
||||
|
||||
home-manager.sharedModules = [
|
||||
{_module.args = {inherit user constants inputs;};}
|
||||
];
|
||||
|
||||
nix = {
|
||||
settings.trusted-users = ["${user}"];
|
||||
settings.trusted-users = [user];
|
||||
gc.dates = "weekly";
|
||||
nixPath = ["nixos-config=/home/${user}/.local/share/src/nixos-config:/etc/nixos"];
|
||||
};
|
||||
|
||||
@@ -41,7 +41,6 @@
|
||||
'';
|
||||
};
|
||||
};
|
||||
# Antigravity Google models (for opencode-antigravity-auth plugin)
|
||||
provider = {
|
||||
google = {
|
||||
models = {
|
||||
@@ -128,10 +127,6 @@
|
||||
};
|
||||
};
|
||||
|
||||
# oh-my-opencode configuration
|
||||
# - Disables built-in google_auth (using antigravity plugin instead)
|
||||
# - Oracle uses Zen API (opencode/gpt-5.2) instead of ChatGPT subscription
|
||||
# - Frontend/document/multimodal agents use Antigravity Gemini models
|
||||
home.file.".config/opencode/oh-my-opencode.json".text = builtins.toJSON {
|
||||
"$schema" = "https://raw.githubusercontent.com/code-yeongyu/oh-my-opencode/master/assets/oh-my-opencode.schema.json";
|
||||
google_auth = false;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
user,
|
||||
pkgs,
|
||||
constants,
|
||||
...
|
||||
}: let
|
||||
isDarwin = pkgs.stdenv.isDarwin;
|
||||
@@ -12,36 +13,37 @@
|
||||
if isDarwin
|
||||
then "staff"
|
||||
else "users";
|
||||
deviceIds = constants.syncthingDeviceIds;
|
||||
in {
|
||||
services.syncthing = {
|
||||
enable = true;
|
||||
openDefaultPorts = !isDarwin;
|
||||
dataDir = "${homeDir}/.local/share/syncthing";
|
||||
configDir = "${homeDir}/.config/syncthing";
|
||||
user = "${user}";
|
||||
group = group;
|
||||
user = user;
|
||||
inherit group;
|
||||
guiAddress = "0.0.0.0:8384";
|
||||
overrideFolders = true;
|
||||
overrideDevices = true;
|
||||
|
||||
settings = {
|
||||
devices = {
|
||||
"tahani" = {
|
||||
id = "6B7OZZF-TEAMUGO-FBOELXP-Z4OY7EU-5ZHLB5T-V6Z3UDB-Q2DYR43-QBYW6QM";
|
||||
tahani = {
|
||||
id = deviceIds.tahani;
|
||||
addresses = ["tcp://tahani:22000"];
|
||||
};
|
||||
"jason" = {
|
||||
id = "42II2VO-QYPJG26-ZS3MB2I-AOPVZ67-JJNSE76-U54CO5Y-634A5OG-ECU4YQA";
|
||||
jason = {
|
||||
id = deviceIds.jason;
|
||||
addresses = ["tcp://jason:22000"];
|
||||
};
|
||||
"chidi" = {
|
||||
id = "N7W6SUT-QO6J4BE-T3Y65SM-OFGYGNV-TGYBJPX-JVN4Z72-AENZ247-KWXOQA6";
|
||||
chidi = {
|
||||
id = deviceIds.chidi;
|
||||
addresses = ["tcp://chidi:22000"];
|
||||
};
|
||||
};
|
||||
|
||||
folders = {
|
||||
"nixos-config" = {
|
||||
nixos-config = {
|
||||
path = "${homeDir}/nixos-config";
|
||||
devices = ["tahani" "jason" "chidi"];
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user