big refactor

This commit is contained in:
John Lancaster
2024-12-18 00:52:36 -06:00
parent f36c1b1188
commit e80a85c490
17 changed files with 422 additions and 483 deletions

View File

@@ -1,39 +1,32 @@
{ pkgs, lib, userSettings, systemSettings, ... }:
{ inputs, pkgs, lib, userSettings, systemSettings, ... }:
let
stateVersion = "24.05";
adHome = "/srv/appdaemon";
adNixPath = "${adHome}/ad-nix";
adPath = "/usr/src/app";
adRepo = "https://github.com/jsl12/appdaemon";
adBranch = "hass";
stateVersion = systemSettings.stateVersion;
# adHome = "/srv/appdaemon";
# adNixPath = "${adHome}/ad-nix";
# adPath = "/usr/src/app";
in
{
imports = [
./telegraf.nix
./promtail.nix
./portainer.nix
./watchtower.nix
(import ./home-manager/home.nix {inherit systemSettings userSettings;})
./nixos
];
system.stateVersion = stateVersion;
time.timeZone = "${systemSettings.timeZone}";
nix.settings.trusted-users = [ "root" "@wheel" ];
nix.settings.experimental-features = [ "nix-command" "flakes" ];
sops.defaultSopsFile = ./secrets/secrets.yaml;
sops.defaultSopsFormat = "yaml";
sops.age.keyFile = "${adHome}/.config/sops/age/keys.txt";
sops.age.keyFile = "${userSettings.adHome}/.config/sops/age/keys.txt";
environment.systemPackages = with pkgs; [
(pkgs.writeShellScriptBin "nrbs" "sudo nixos-rebuild switch")
(pkgs.writeShellScriptBin "nrbsu" "sudo nix-channel --update && sudo nixos-rebuild switch")
(pkgs.writeShellScriptBin "nfs" "sudo nixos-rebuild switch --flake ${adNixPath} --impure")
(pkgs.writeShellScriptBin "ads" "cd ${adPath} && nix develop --no-pure-eval ${adNixPath}/appdaemon")
(pkgs.writeShellScriptBin "ad-clone" ''
if [ ! -d ${adPath} ]; then
sudo git clone -b ${adBranch} ${adRepo} ${adPath}
sudo chown -R appdaemon:users $(dirname ${adPath})
else
echo "${adPath} already exists"
fi
(pkgs.writeShellScriptBin "nfs" ''
sudo nixos-rebuild switch --flake $(readlink -f /etc/nixos)#${systemSettings.hostName}
'')
(pkgs.writeShellScriptBin "ads" "nix develop --no-pure-eval $(readlink -f /etc/nixos)")
bash
git
eza
@@ -41,8 +34,6 @@ in
sops
];
time.timeZone = "${systemSettings.timeZone}";
virtualisation.docker.enable = true;
virtualisation.oci-containers.backend = "docker";
@@ -57,35 +48,4 @@ in
chown 1000:100 /conf
fi
'';
security.sudo-rs = {
enable = true;
execWheelOnly = false;
wheelNeedsPassword = false;
};
users.users.appdaemon = {
isNormalUser = true;
home = "${adHome}";
extraGroups = [ "wheel" "docker" ];
openssh.authorizedKeys.keyFiles = [ "/root/.ssh/authorized_keys" ];
};
home-manager = {
useGlobalPkgs = true;
users.appdaemon = { pkgs, ... }: {
home.stateVersion = stateVersion;
systemd.user.startServices = "sd-switch";
imports = [ (import ./git.nix {inherit userSettings;}) ];
programs = {
ssh.enable = true;
git.extraConfig.safe.directory = "${adNixPath}";
bash = {
enable = true;
profileExtra = "cd ${adNixPath}";
};
};
};
};
system.stateVersion = stateVersion;
}