Compare commits
8 Commits
91f6a16fb2
...
flakes
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3e7762c10e | ||
|
|
ae1275fc20 | ||
|
|
cc6cb9ffcc | ||
|
|
afbc973248 | ||
|
|
809d4ee6c1 | ||
|
|
5cfe401b8c | ||
|
|
a905bff8b0 | ||
|
|
1702cb3828 |
@@ -1,14 +1,17 @@
|
|||||||
{
|
{
|
||||||
"folders": [
|
"folders": [
|
||||||
{
|
|
||||||
"path": "/srv/appdaemon/ad-nix"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"path": "/usr/src/app"
|
"path": "/usr/src/app"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "/conf"
|
"path": "/conf"
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
"path": "/srv/appdaemon/snippets"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "/srv/appdaemon/ad-nix"
|
||||||
|
},
|
||||||
],
|
],
|
||||||
"settings": {
|
"settings": {
|
||||||
"python.defaultInterpreterPath": "/usr/src/app/.venv/bin/python3"
|
"python.defaultInterpreterPath": "/usr/src/app/.venv/bin/python3"
|
||||||
|
|||||||
301
appdaemon/flake.lock
generated
Normal file
301
appdaemon/flake.lock
generated
Normal file
@@ -0,0 +1,301 @@
|
|||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"cachix": {
|
||||||
|
"inputs": {
|
||||||
|
"devenv": [
|
||||||
|
"devenv"
|
||||||
|
],
|
||||||
|
"flake-compat": [
|
||||||
|
"devenv"
|
||||||
|
],
|
||||||
|
"git-hooks": [
|
||||||
|
"devenv"
|
||||||
|
],
|
||||||
|
"nixpkgs": "nixpkgs"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1728672398,
|
||||||
|
"narHash": "sha256-KxuGSoVUFnQLB2ZcYODW7AVPAh9JqRlD5BrfsC/Q4qs=",
|
||||||
|
"owner": "cachix",
|
||||||
|
"repo": "cachix",
|
||||||
|
"rev": "aac51f698309fd0f381149214b7eee213c66ef0a",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "cachix",
|
||||||
|
"ref": "latest",
|
||||||
|
"repo": "cachix",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"devenv": {
|
||||||
|
"inputs": {
|
||||||
|
"cachix": "cachix",
|
||||||
|
"flake-compat": "flake-compat",
|
||||||
|
"git-hooks": "git-hooks",
|
||||||
|
"nix": "nix",
|
||||||
|
"nixpkgs": "nixpkgs_3"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1733323168,
|
||||||
|
"narHash": "sha256-d5DwB4MZvlaQpN6OQ4SLYxb5jA4UH5EtV5t5WOtjLPU=",
|
||||||
|
"owner": "cachix",
|
||||||
|
"repo": "devenv",
|
||||||
|
"rev": "efa9010b8b1cfd5dd3c7ed1e172a470c3b84a064",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "cachix",
|
||||||
|
"repo": "devenv",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"flake-compat": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1696426674,
|
||||||
|
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
|
||||||
|
"owner": "edolstra",
|
||||||
|
"repo": "flake-compat",
|
||||||
|
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "edolstra",
|
||||||
|
"repo": "flake-compat",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"flake-compat_2": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1696426674,
|
||||||
|
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
|
||||||
|
"owner": "edolstra",
|
||||||
|
"repo": "flake-compat",
|
||||||
|
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "edolstra",
|
||||||
|
"repo": "flake-compat",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"flake-parts": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs-lib": [
|
||||||
|
"devenv",
|
||||||
|
"nix",
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1712014858,
|
||||||
|
"narHash": "sha256-sB4SWl2lX95bExY2gMFG5HIzvva5AVMJd4Igm+GpZNw=",
|
||||||
|
"owner": "hercules-ci",
|
||||||
|
"repo": "flake-parts",
|
||||||
|
"rev": "9126214d0a59633752a136528f5f3b9aa8565b7d",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "hercules-ci",
|
||||||
|
"repo": "flake-parts",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"git-hooks": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-compat": [
|
||||||
|
"devenv"
|
||||||
|
],
|
||||||
|
"gitignore": "gitignore",
|
||||||
|
"nixpkgs": [
|
||||||
|
"devenv",
|
||||||
|
"nixpkgs"
|
||||||
|
],
|
||||||
|
"nixpkgs-stable": [
|
||||||
|
"devenv"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1730302582,
|
||||||
|
"narHash": "sha256-W1MIJpADXQCgosJZT8qBYLRuZls2KSiKdpnTVdKBuvU=",
|
||||||
|
"owner": "cachix",
|
||||||
|
"repo": "git-hooks.nix",
|
||||||
|
"rev": "af8a16fe5c264f5e9e18bcee2859b40a656876cf",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "cachix",
|
||||||
|
"repo": "git-hooks.nix",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"gitignore": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"devenv",
|
||||||
|
"git-hooks",
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1709087332,
|
||||||
|
"narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=",
|
||||||
|
"owner": "hercules-ci",
|
||||||
|
"repo": "gitignore.nix",
|
||||||
|
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "hercules-ci",
|
||||||
|
"repo": "gitignore.nix",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"libgit2": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1697646580,
|
||||||
|
"narHash": "sha256-oX4Z3S9WtJlwvj0uH9HlYcWv+x1hqp8mhXl7HsLu2f0=",
|
||||||
|
"owner": "libgit2",
|
||||||
|
"repo": "libgit2",
|
||||||
|
"rev": "45fd9ed7ae1a9b74b957ef4f337bc3c8b3df01b5",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "libgit2",
|
||||||
|
"repo": "libgit2",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nix": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-compat": [
|
||||||
|
"devenv"
|
||||||
|
],
|
||||||
|
"flake-parts": "flake-parts",
|
||||||
|
"libgit2": "libgit2",
|
||||||
|
"nixpkgs": "nixpkgs_2",
|
||||||
|
"nixpkgs-23-11": [
|
||||||
|
"devenv"
|
||||||
|
],
|
||||||
|
"nixpkgs-regression": [
|
||||||
|
"devenv"
|
||||||
|
],
|
||||||
|
"pre-commit-hooks": [
|
||||||
|
"devenv"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1727438425,
|
||||||
|
"narHash": "sha256-X8ES7I1cfNhR9oKp06F6ir4Np70WGZU5sfCOuNBEwMg=",
|
||||||
|
"owner": "domenkozar",
|
||||||
|
"repo": "nix",
|
||||||
|
"rev": "f6c5ae4c1b2e411e6b1e6a8181cc84363d6a7546",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "domenkozar",
|
||||||
|
"ref": "devenv-2.24",
|
||||||
|
"repo": "nix",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1730531603,
|
||||||
|
"narHash": "sha256-Dqg6si5CqIzm87sp57j5nTaeBbWhHFaVyG7V6L8k3lY=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "7ffd9ae656aec493492b44d0ddfb28e79a1ea25d",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixos-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs-python": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-compat": "flake-compat_2",
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1733319315,
|
||||||
|
"narHash": "sha256-cFQBdRmtIZFVjr2P6NkaCOp7dddF93BC0CXBwFZFaN0=",
|
||||||
|
"owner": "cachix",
|
||||||
|
"repo": "nixpkgs-python",
|
||||||
|
"rev": "01263eeb28c09f143d59cd6b0b7c4cc8478efd48",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "cachix",
|
||||||
|
"repo": "nixpkgs-python",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs_2": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1717432640,
|
||||||
|
"narHash": "sha256-+f9c4/ZX5MWDOuB1rKoWj+lBNm0z0rs4CK47HBLxy1o=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "88269ab3044128b7c2f4c7d68448b2fb50456870",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "release-24.05",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs_3": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1716977621,
|
||||||
|
"narHash": "sha256-Q1UQzYcMJH4RscmpTkjlgqQDX5yi1tZL0O345Ri6vXQ=",
|
||||||
|
"owner": "cachix",
|
||||||
|
"repo": "devenv-nixpkgs",
|
||||||
|
"rev": "4267e705586473d3e5c8d50299e71503f16a6fb6",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "cachix",
|
||||||
|
"ref": "rolling",
|
||||||
|
"repo": "devenv-nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs_4": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1733212471,
|
||||||
|
"narHash": "sha256-M1+uCoV5igihRfcUKrr1riygbe73/dzNnzPsmaLCmpo=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "55d15ad12a74eb7d4646254e13638ad0c4128776",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixos-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"devenv": "devenv",
|
||||||
|
"nixpkgs": "nixpkgs_4",
|
||||||
|
"nixpkgs-python": "nixpkgs-python"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
||||||
78
appdaemon/flake.nix
Normal file
78
appdaemon/flake.nix
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
{
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
|
devenv.url = "github:cachix/devenv";
|
||||||
|
nixpkgs-python = {
|
||||||
|
url = "github:cachix/nixpkgs-python";
|
||||||
|
inputs = { nixpkgs.follows = "nixpkgs"; };
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
nixConfig = {
|
||||||
|
extra-trusted-public-keys = "devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw=";
|
||||||
|
extra-substituters = "https://devenv.cachix.org";
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = { self, nixpkgs, devenv, ... } @ inputs:
|
||||||
|
let
|
||||||
|
system = "x86_64-linux";
|
||||||
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
|
adPath = "/usr/src/app";
|
||||||
|
in
|
||||||
|
{
|
||||||
|
packages.${system} = {
|
||||||
|
devenv-up = self.devShells.${system}.default.config.procfileScript;
|
||||||
|
devenv-test = self.devShells.${system}.default.config.test;
|
||||||
|
};
|
||||||
|
|
||||||
|
devShells.${system}.default = devenv.lib.mkShell {
|
||||||
|
inherit inputs pkgs;
|
||||||
|
modules = [
|
||||||
|
({ pkgs, config, ... }: {
|
||||||
|
# This is your devenv configuration
|
||||||
|
|
||||||
|
pre-commit.hooks = {
|
||||||
|
end-of-file-fixer.enable = true;
|
||||||
|
trim-trailing-whitespace.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
languages.python = {
|
||||||
|
enable = true;
|
||||||
|
version = "3.12.7";
|
||||||
|
uv = {
|
||||||
|
enable = true;
|
||||||
|
sync = {
|
||||||
|
enable = true;
|
||||||
|
allExtras = true;
|
||||||
|
arguments = [ "-U" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
packages = with pkgs; [
|
||||||
|
git
|
||||||
|
(writeShellScriptBin "full-build" ''
|
||||||
|
cd ${adPath}
|
||||||
|
${pkgs.uv}/bin/uv build --wheel
|
||||||
|
docker build -t acockburn/appdaemon:local-dev ${adPath}
|
||||||
|
'')
|
||||||
|
];
|
||||||
|
|
||||||
|
enterShell = ''
|
||||||
|
alias appdaemon="${pkgs.uv}/bin/uv run --frozen python -m appdaemon"
|
||||||
|
alias ad="appdaemon"
|
||||||
|
|
||||||
|
export PS1="\[\e[0;34m\](AppDaemon)\[\e[0m\] ''${PS1-}"
|
||||||
|
|
||||||
|
export VIRTUAL_ENV=$UV_PROJECT_ENVIRONMENT
|
||||||
|
|
||||||
|
echo -e "URL: \e[34m$(${pkgs.git}/bin/git config --get remote.origin.url)\e[0m"
|
||||||
|
echo -e "Branch: \e[32m$(${pkgs.git}/bin/git rev-parse --abbrev-ref HEAD)\e[0m"
|
||||||
|
echo -e "Hash: \e[33m$(${pkgs.git}/bin/git rev-parse --short HEAD)\e[0m"
|
||||||
|
echo "AppDaemon v$(${pkgs.uv}/bin/uv pip show appdaemon | awk '/^Version:/ {print $2}') development shell started"
|
||||||
|
'';
|
||||||
|
})
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -14,11 +14,19 @@ in
|
|||||||
(import "${builtins.fetchTarball https://github.com/nix-community/home-manager/archive/release-24.05.tar.gz}/nixos")
|
(import "${builtins.fetchTarball https://github.com/nix-community/home-manager/archive/release-24.05.tar.gz}/nixos")
|
||||||
(fetchTarball "https://github.com/nix-community/nixos-vscode-server/tarball/master")
|
(fetchTarball "https://github.com/nix-community/nixos-vscode-server/tarball/master")
|
||||||
./telegraf.nix
|
./telegraf.nix
|
||||||
|
./promtail.nix
|
||||||
|
./portainer.nix
|
||||||
|
./watchtower.nix
|
||||||
];
|
];
|
||||||
|
nix.settings.experimental-features = [ "nix-command" "flakes" ];
|
||||||
|
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
(pkgs.writeShellScriptBin "nrbs" "sudo nixos-rebuild switch")
|
(pkgs.writeShellScriptBin "nrbs" "sudo nixos-rebuild switch")
|
||||||
(pkgs.writeShellScriptBin "nrbsu" "sudo nix-channel --update && sudo nixos-rebuild switch")
|
(pkgs.writeShellScriptBin "nrbsu" "sudo nix-channel --update && sudo nixos-rebuild switch")
|
||||||
|
(pkgs.writeShellScriptBin "ads" ''
|
||||||
|
cd ${adPath}
|
||||||
|
nix develop --no-pure-eval ${adNixPath}/appdaemon
|
||||||
|
'')
|
||||||
(pkgs.writeShellScriptBin "ad-clone" ''
|
(pkgs.writeShellScriptBin "ad-clone" ''
|
||||||
if [ ! -d ${adPath} ]; then
|
if [ ! -d ${adPath} ]; then
|
||||||
sudo git clone -b ${adBranch} ${adRepo} ${adPath}
|
sudo git clone -b ${adBranch} ${adRepo} ${adPath}
|
||||||
@@ -27,6 +35,7 @@ in
|
|||||||
echo "${adPath} already exists"
|
echo "${adPath} already exists"
|
||||||
fi
|
fi
|
||||||
'')
|
'')
|
||||||
|
# unstable.uv
|
||||||
bash
|
bash
|
||||||
git
|
git
|
||||||
eza
|
eza
|
||||||
@@ -34,7 +43,11 @@ in
|
|||||||
# appdaemon
|
# appdaemon
|
||||||
];
|
];
|
||||||
|
|
||||||
|
time.timeZone = "America/Chicago";
|
||||||
|
|
||||||
virtualisation.docker.enable = true;
|
virtualisation.docker.enable = true;
|
||||||
|
virtualisation.oci-containers.backend = "docker";
|
||||||
|
|
||||||
services.vscode-server.enable = true;
|
services.vscode-server.enable = true;
|
||||||
services.openssh.enable = true;
|
services.openssh.enable = true;
|
||||||
services.tailscale.enable = true;
|
services.tailscale.enable = true;
|
||||||
@@ -60,6 +73,8 @@ in
|
|||||||
openssh.authorizedKeys.keyFiles = [ "/root/.ssh/authorized_keys" ];
|
openssh.authorizedKeys.keyFiles = [ "/root/.ssh/authorized_keys" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
nix.settings.trusted-users = [ "root" "@wheel" ];
|
||||||
|
|
||||||
home-manager = {
|
home-manager = {
|
||||||
useGlobalPkgs = true;
|
useGlobalPkgs = true;
|
||||||
users.appdaemon = { pkgs, ... }: {
|
users.appdaemon = { pkgs, ... }: {
|
||||||
|
|||||||
13
portainer.nix
Normal file
13
portainer.nix
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
{ config, ... }:
|
||||||
|
{
|
||||||
|
virtualisation.oci-containers.containers.portainer-agent = {
|
||||||
|
image = "portainer/agent:latest"; # Use the latest Portainer agent image
|
||||||
|
ports = [
|
||||||
|
"9001:9001" # Expose the Portainer agent API port
|
||||||
|
];
|
||||||
|
volumes = [
|
||||||
|
"/etc/zoneinfo/${config.time.timeZone}:/etc/localtime:ro"
|
||||||
|
"/var/run/docker.sock:/var/run/docker.sock"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
||||||
81
promtail.nix
Normal file
81
promtail.nix
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
{ config, ... }:
|
||||||
|
let
|
||||||
|
lokiHost = "192.168.1.174:3100";
|
||||||
|
in
|
||||||
|
{
|
||||||
|
systemd.services.promtail.serviceConfig = {
|
||||||
|
SupplementaryGroups = [ "docker" ];
|
||||||
|
};
|
||||||
|
|
||||||
|
services.promtail = {
|
||||||
|
enable = true;
|
||||||
|
configuration = {
|
||||||
|
server = {
|
||||||
|
http_listen_port = 3031;
|
||||||
|
grpc_listen_port = 0;
|
||||||
|
};
|
||||||
|
positions = {
|
||||||
|
filename = "/tmp/positions.yaml";
|
||||||
|
};
|
||||||
|
clients = [{url = "http://${lokiHost}/loki/api/v1/push";}];
|
||||||
|
scrape_configs = [
|
||||||
|
{
|
||||||
|
job_name = "journal";
|
||||||
|
journal = {
|
||||||
|
max_age = "24h";
|
||||||
|
path = "/var/log/journal";
|
||||||
|
json = true;
|
||||||
|
# matches: _TRANSPORT=kernel;
|
||||||
|
labels = {
|
||||||
|
job = "systemd-journal";
|
||||||
|
host = config.networking.hostName; # Dynamically fetch the hostname
|
||||||
|
};
|
||||||
|
};
|
||||||
|
relabel_configs = [
|
||||||
|
{
|
||||||
|
source_labels = [ "__journal__systemd_unit" ];
|
||||||
|
target_label = "unit";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
{
|
||||||
|
job_name = "flog_scrape";
|
||||||
|
docker_sd_configs = [
|
||||||
|
{
|
||||||
|
host = "unix:///var/run/docker.sock";
|
||||||
|
refresh_interval = "5s";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
relabel_configs = [
|
||||||
|
{
|
||||||
|
source_labels = [ "__meta_docker_container_name" ];
|
||||||
|
regex = "/(.*)";
|
||||||
|
target_label = "container";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
source_labels = [ "__meta_docker_container_label_com_docker_compose_oneoff" ];
|
||||||
|
target_label = "oneoff";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
source_labels = [ "__meta_docker_container_label_com_docker_compose_project_config_files" ];
|
||||||
|
target_label = "compose_file";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
source_labels = [ "__meta_docker_container_label_com_docker_compose_project" ];
|
||||||
|
target_label = "project_name";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
source_labels = [ "__meta_docker_container_label_com_docker_compose_service" ];
|
||||||
|
target_label = "service";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
target_label = "host";
|
||||||
|
replacement = "${config.networking.hostName}";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
# extraFlags
|
||||||
|
};
|
||||||
|
}
|
||||||
31
shell.nix
31
shell.nix
@@ -1,13 +1,26 @@
|
|||||||
{ pkgs ? import <nixpkgs> {}, unstable ? import <nixpkgs-unstable> {} }:
|
{ pkgs ? import <nixpkgs> {}, unstable ? import <nixpkgs-unstable> {} }:
|
||||||
|
|
||||||
pkgs.mkShell {
|
pkgs.mkShell {
|
||||||
buildInputs = [
|
packages = [
|
||||||
pkgs.python312
|
pkgs.git
|
||||||
unstable.uv
|
(pkgs.python312.withPackages (python-pkgs: with python-pkgs; [
|
||||||
unstable.python312Packages.ipykernel
|
pip
|
||||||
unstable.python312Packages.rich
|
setuptools
|
||||||
];
|
wheel
|
||||||
|
|
||||||
|
# pyproject deps
|
||||||
|
aiohttp
|
||||||
|
astral
|
||||||
|
bcrypt
|
||||||
|
deepdiff
|
||||||
|
feedparser
|
||||||
|
iso8601
|
||||||
|
paho-mqtt
|
||||||
|
requests
|
||||||
|
uvloop
|
||||||
|
pydantic
|
||||||
|
click
|
||||||
|
]))
|
||||||
|
];
|
||||||
shellHook = ''
|
shellHook = ''
|
||||||
echo "Welcome to the Nix shell for AppDaemon development"
|
echo "Welcome to the Nix shell for AppDaemon development"
|
||||||
cd /usr/src/app
|
cd /usr/src/app
|
||||||
@@ -20,9 +33,5 @@ pkgs.mkShell {
|
|||||||
alias fbuild="build && dbuild"
|
alias fbuild="build && dbuild"
|
||||||
alias clean="cd /usr/src/app && rm -rf ./build ./dist"
|
alias clean="cd /usr/src/app && rm -rf ./build ./dist"
|
||||||
alias ad="python -m appdaemon"
|
alias ad="python -m appdaemon"
|
||||||
|
|
||||||
uv sync --all-extras --upgrade --inexact
|
|
||||||
source .venv/bin/activate
|
|
||||||
echo -e "Built and activated virtual environment\n"
|
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|||||||
18
telegraf.nix
18
telegraf.nix
@@ -1,8 +1,18 @@
|
|||||||
{ ... }:
|
{ ... }:
|
||||||
|
let
|
||||||
|
influxURL = "http://panoptes.john-stream.com:8086";
|
||||||
|
organization = "homelab";
|
||||||
|
bucket = "docker";
|
||||||
|
envFile = ./telegraf.env;
|
||||||
|
in
|
||||||
{
|
{
|
||||||
|
systemd.services.telegraf.serviceConfig = {
|
||||||
|
SupplementaryGroups = [ "docker" ];
|
||||||
|
};
|
||||||
|
|
||||||
services.telegraf = {
|
services.telegraf = {
|
||||||
enable = true;
|
enable = true;
|
||||||
environmentFiles = [ ./telegraf.env ];
|
environmentFiles = [ "${envFile}" ];
|
||||||
extraConfig = {
|
extraConfig = {
|
||||||
agent = {
|
agent = {
|
||||||
interval = "10s";
|
interval = "10s";
|
||||||
@@ -30,10 +40,10 @@
|
|||||||
};
|
};
|
||||||
outputs = {
|
outputs = {
|
||||||
influxdb_v2 = {
|
influxdb_v2 = {
|
||||||
urls = ["http://panoptes.john-stream.com:8086"];
|
urls = ["${influxURL}"];
|
||||||
token = "$INFLUX_WRITE_TOKEN";
|
token = "$INFLUX_WRITE_TOKEN";
|
||||||
organization = "homelab";
|
organization = "${organization}";
|
||||||
bucket = "docker";
|
bucket = "${bucket}";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
11
watchtower.nix
Normal file
11
watchtower.nix
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{ config, ... }:
|
||||||
|
{
|
||||||
|
virtualisation.oci-containers.containers.watchtower = {
|
||||||
|
image = "containrrr/watchtower:latest";
|
||||||
|
volumes = [
|
||||||
|
"/etc/zoneinfo/${config.time.timeZone}:/etc/localtime:ro"
|
||||||
|
"/var/run/docker.sock:/var/run/docker.sock"
|
||||||
|
];
|
||||||
|
environment = {WATCHTOWER_SCHEDULE = "0 0 3 * * *";};
|
||||||
|
};
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user