Compare commits
8 Commits
flakes
...
30fcca3624
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
30fcca3624 | ||
|
|
8321b440ed | ||
|
|
1a3dcb516a | ||
|
|
77098ae071 | ||
|
|
e80a85c490 | ||
|
|
f36c1b1188 | ||
|
|
7216a90f90 | ||
|
|
d0544a89ff |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,2 +1,3 @@
|
|||||||
git.nix
|
# git.nix
|
||||||
*.env
|
*.env
|
||||||
|
.devenv
|
||||||
|
|||||||
7
.sops.yaml
Normal file
7
.sops.yaml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
keys:
|
||||||
|
- &primary age197d424aa7jpj2s735fl2h2s4c687y8vm44usx8wag0r2kh2v7ces4efdyn
|
||||||
|
creation_rules:
|
||||||
|
- path_regex: secrets/secrets.yaml$
|
||||||
|
key_groups:
|
||||||
|
- age:
|
||||||
|
- *primary
|
||||||
46
README.md
46
README.md
@@ -1,15 +1,35 @@
|
|||||||
NixOS Configuration for AppDaemon Development
|
# NixOS Configuration for AppDaemon Development
|
||||||
|
|
||||||
Needs a `git.nix` file. Example below:
|
## Objectives
|
||||||
|
|
||||||
```shell
|
- Use flakes
|
||||||
{ ... }:
|
- `devenv`-based workflow
|
||||||
{
|
- Shell
|
||||||
programs.git = {
|
- Build
|
||||||
enable = true;
|
- SSH remote with VSCode
|
||||||
extraConfig.credential.helper = "store --file ~/.git-credentials";
|
- Jupyter through VSCode
|
||||||
userName = "John Lancaster";
|
- `autoreload` must work with editable install of the dev version
|
||||||
userEmail = "32917998+jsl12@users.noreply.github.com";
|
- Multiple dev versions
|
||||||
};
|
- Multiple config directories
|
||||||
}
|
- Debugger must work
|
||||||
```
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
### `nfs`
|
||||||
|
|
||||||
|
Used to rebuild the ad-nix system.
|
||||||
|
|
||||||
|
### `ads`
|
||||||
|
|
||||||
|
Used to enter the development shell. Be careful, as this will create a `.devenv` directory and venv wherever it's entered.
|
||||||
|
|
||||||
|
### venv
|
||||||
|
|
||||||
|
Activated with `.devenv/state/venv/bin/activate`. Used in VSCode for type hints, running, and debugging
|
||||||
|
|
||||||
|
### Jupyter
|
||||||
|
|
||||||
|
- Install devenv kernel - might not be useful
|
||||||
|
- `python -m ipykernel install --user --name devenv --display-name "Python (devenv)"`
|
||||||
|
- Run jupyter notebook on the side with a `uv run jupyter notebook` command
|
||||||
|
- Use the link with the token to connect the jupyter notebook kernel to it
|
||||||
|
|||||||
@@ -1,78 +0,0 @@
|
|||||||
{
|
|
||||||
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"
|
|
||||||
'';
|
|
||||||
})
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,50 +1,41 @@
|
|||||||
{ pkgs, lib, modulesPath, ... }:
|
{ inputs, pkgs, lib, userSettings, systemSettings, ... }:
|
||||||
let
|
let
|
||||||
stateVersion = "24.05";
|
stateVersion = systemSettings.stateVersion;
|
||||||
unstable = import <nixos-unstable> {};
|
# adHome = "/srv/appdaemon";
|
||||||
adHome = "/srv/appdaemon";
|
# adNixPath = "${adHome}/ad-nix";
|
||||||
adNixPath = "${adHome}/ad-nix";
|
# adPath = "/usr/src/app";
|
||||||
adPath = "/usr/src/app";
|
|
||||||
adRepo = "https://github.com/jsl12/appdaemon";
|
|
||||||
adBranch = "hass";
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
(modulesPath + "/virtualisation/proxmox-lxc.nix")
|
(import ./home-manager/home.nix {inherit systemSettings userSettings;})
|
||||||
(import "${builtins.fetchTarball https://github.com/nix-community/home-manager/archive/release-24.05.tar.gz}/nixos")
|
./nixos
|
||||||
(fetchTarball "https://github.com/nix-community/nixos-vscode-server/tarball/master")
|
|
||||||
./telegraf.nix
|
|
||||||
./promtail.nix
|
|
||||||
./portainer.nix
|
|
||||||
./watchtower.nix
|
|
||||||
];
|
];
|
||||||
|
system.stateVersion = stateVersion;
|
||||||
|
time.timeZone = "${systemSettings.timeZone}";
|
||||||
|
|
||||||
|
nix.settings.trusted-users = [ "root" "@wheel" ];
|
||||||
nix.settings.experimental-features = [ "nix-command" "flakes" ];
|
nix.settings.experimental-features = [ "nix-command" "flakes" ];
|
||||||
|
|
||||||
|
programs.nix-ld.enable = true;
|
||||||
|
|
||||||
|
sops.defaultSopsFile = ./secrets/secrets.yaml;
|
||||||
|
sops.defaultSopsFormat = "yaml";
|
||||||
|
sops.age.keyFile = "${userSettings.adHome}/.config/sops/age/keys.txt";
|
||||||
|
|
||||||
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" ''
|
(pkgs.writeShellScriptBin "nfs" ''
|
||||||
cd ${adPath}
|
sudo nixos-rebuild switch --flake $(readlink -f /etc/nixos)#${systemSettings.hostName}
|
||||||
nix develop --no-pure-eval ${adNixPath}/appdaemon
|
|
||||||
'')
|
'')
|
||||||
(pkgs.writeShellScriptBin "ad-clone" ''
|
(pkgs.writeShellScriptBin "ads" "nix develop --no-pure-eval $(readlink -f /etc/nixos)")
|
||||||
if [ ! -d ${adPath} ]; then
|
|
||||||
sudo git clone -b ${adBranch} ${adRepo} ${adPath}
|
|
||||||
sudo chown -R appdaemon:users $(dirname ${adPath})
|
|
||||||
else
|
|
||||||
echo "${adPath} already exists"
|
|
||||||
fi
|
|
||||||
'')
|
|
||||||
# unstable.uv
|
|
||||||
bash
|
bash
|
||||||
git
|
git
|
||||||
eza
|
eza
|
||||||
gh
|
gh
|
||||||
# appdaemon
|
sops
|
||||||
];
|
];
|
||||||
|
|
||||||
time.timeZone = "America/Chicago";
|
|
||||||
|
|
||||||
virtualisation.docker.enable = true;
|
virtualisation.docker.enable = true;
|
||||||
virtualisation.oci-containers.backend = "docker";
|
virtualisation.oci-containers.backend = "docker";
|
||||||
|
|
||||||
@@ -59,36 +50,4 @@ in
|
|||||||
chown 1000:100 /conf
|
chown 1000:100 /conf
|
||||||
fi
|
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" ];
|
|
||||||
};
|
|
||||||
|
|
||||||
nix.settings.trusted-users = [ "root" "@wheel" ];
|
|
||||||
|
|
||||||
home-manager = {
|
|
||||||
useGlobalPkgs = true;
|
|
||||||
users.appdaemon = { pkgs, ... }: {
|
|
||||||
home.stateVersion = stateVersion;
|
|
||||||
imports = [ ./git.nix ];
|
|
||||||
programs = {
|
|
||||||
ssh.enable = true;
|
|
||||||
git.extraConfig.safe.directory = "${adNixPath}";
|
|
||||||
bash = {
|
|
||||||
enable = true;
|
|
||||||
profileExtra = "cd ${adNixPath}";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
system.stateVersion = stateVersion;
|
|
||||||
}
|
}
|
||||||
|
|||||||
145
appdaemon/flake.lock → flake.lock
generated
145
appdaemon/flake.lock → flake.lock
generated
@@ -34,14 +34,16 @@
|
|||||||
"flake-compat": "flake-compat",
|
"flake-compat": "flake-compat",
|
||||||
"git-hooks": "git-hooks",
|
"git-hooks": "git-hooks",
|
||||||
"nix": "nix",
|
"nix": "nix",
|
||||||
"nixpkgs": "nixpkgs_3"
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1733323168,
|
"lastModified": 1734441494,
|
||||||
"narHash": "sha256-d5DwB4MZvlaQpN6OQ4SLYxb5jA4UH5EtV5t5WOtjLPU=",
|
"narHash": "sha256-/SZXjdKlo6NgVR+/RT0eYCUUJLcQndy7lIl2Bc0qjlY=",
|
||||||
"owner": "cachix",
|
"owner": "cachix",
|
||||||
"repo": "devenv",
|
"repo": "devenv",
|
||||||
"rev": "efa9010b8b1cfd5dd3c7ed1e172a470c3b84a064",
|
"rev": "bdc1a2cefdda8f89e31b1a0f3771786ba9e5d052",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -104,6 +106,24 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"flake-utils": {
|
||||||
|
"inputs": {
|
||||||
|
"systems": "systems"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1681202837,
|
||||||
|
"narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"rev": "cfacdce06f30d2b68473a46042957675eebb3401",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"git-hooks": {
|
"git-hooks": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-compat": [
|
"flake-compat": [
|
||||||
@@ -154,6 +174,26 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"home-manager": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1734344598,
|
||||||
|
"narHash": "sha256-wNX3hsScqDdqKWOO87wETUEi7a/QlPVgpC/Lh5rFOuA=",
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "home-manager",
|
||||||
|
"rev": "83ecd50915a09dca928971139d3a102377a8d242",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "home-manager",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"libgit2": {
|
"libgit2": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
@@ -258,27 +298,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs_3": {
|
"nixpkgs_3": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1716977621,
|
"lastModified": 1734119587,
|
||||||
"narHash": "sha256-Q1UQzYcMJH4RscmpTkjlgqQDX5yi1tZL0O345Ri6vXQ=",
|
"narHash": "sha256-AKU6qqskl0yf2+JdRdD0cfxX4b9x3KKV5RqA6wijmPM=",
|
||||||
"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",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "55d15ad12a74eb7d4646254e13638ad0c4128776",
|
"rev": "3566ab7246670a43abd2ffa913cc62dad9cdf7d5",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -288,11 +312,82 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"nixpkgs_4": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1682134069,
|
||||||
|
"narHash": "sha256-TnI/ZXSmRxQDt2sjRYK/8j8iha4B4zP2cnQCZZ3vp7k=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "fd901ef4bf93499374c5af385b2943f5801c0833",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"id": "nixpkgs",
|
||||||
|
"type": "indirect"
|
||||||
|
}
|
||||||
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"devenv": "devenv",
|
"devenv": "devenv",
|
||||||
"nixpkgs": "nixpkgs_4",
|
"home-manager": "home-manager",
|
||||||
"nixpkgs-python": "nixpkgs-python"
|
"nixpkgs": "nixpkgs_3",
|
||||||
|
"nixpkgs-python": "nixpkgs-python",
|
||||||
|
"sops-nix": "sops-nix",
|
||||||
|
"vscode-server": "vscode-server"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sops-nix": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1733965552,
|
||||||
|
"narHash": "sha256-GZ4YtqkfyTjJFVCub5yAFWsHknG1nS/zfk7MuHht4Fs=",
|
||||||
|
"owner": "Mic92",
|
||||||
|
"repo": "sops-nix",
|
||||||
|
"rev": "2d73fc6ac4eba4b9a83d3cb8275096fbb7ab4004",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "Mic92",
|
||||||
|
"repo": "sops-nix",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"systems": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1681028828,
|
||||||
|
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"vscode-server": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-utils": "flake-utils",
|
||||||
|
"nixpkgs": "nixpkgs_4"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1729422940,
|
||||||
|
"narHash": "sha256-DlvJv33ml5UTKgu4b0HauOfFIoDx6QXtbqUF3vWeRCY=",
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "nixos-vscode-server",
|
||||||
|
"rev": "8b6db451de46ecf9b4ab3d01ef76e59957ff549f",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "nixos-vscode-server",
|
||||||
|
"type": "github"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
144
flake.nix
Normal file
144
flake.nix
Normal file
@@ -0,0 +1,144 @@
|
|||||||
|
{
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
|
home-manager = {
|
||||||
|
url = "github:nix-community/home-manager";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
|
vscode-server.url = "github:nix-community/nixos-vscode-server";
|
||||||
|
sops-nix = {
|
||||||
|
url = "github:Mic92/sops-nix";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
|
nixpkgs-python = {
|
||||||
|
url = "github:cachix/nixpkgs-python";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
|
devenv = {
|
||||||
|
url = "github:cachix/devenv";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
nixConfig = {
|
||||||
|
extra-trusted-public-keys = "devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw=";
|
||||||
|
extra-substituters = "https://devenv.cachix.org";
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = { self, ... }@args:
|
||||||
|
let
|
||||||
|
inherit (self) outputs;
|
||||||
|
nixosSystem = args.nixpkgs.lib.nixosSystem;
|
||||||
|
|
||||||
|
userSettings = {
|
||||||
|
userName = "appdaemon";
|
||||||
|
gitUserName = "John Lancaster";
|
||||||
|
gitUserEmail = "32917998+jsl12@users.noreply.github.com";
|
||||||
|
adRepo = "https://github.com/jsl12/appdaemon";
|
||||||
|
adBranch = "hass";
|
||||||
|
adHome = "/srv/appdaemon";
|
||||||
|
};
|
||||||
|
|
||||||
|
systemSettings = {
|
||||||
|
hostName = "ad-nix";
|
||||||
|
stateVersion = "24.05";
|
||||||
|
system = "x86_64-linux";
|
||||||
|
timeZone = "America/Chicago";
|
||||||
|
locale = "en_US.UTF-8";
|
||||||
|
pythonVersion = "3.12.7";
|
||||||
|
};
|
||||||
|
|
||||||
|
pkgs = args.nixpkgs.legacyPackages.${systemSettings.system};
|
||||||
|
|
||||||
|
in
|
||||||
|
{
|
||||||
|
nixosConfigurations.${systemSettings.hostName} = nixosSystem {
|
||||||
|
system = systemSettings.system;
|
||||||
|
specialArgs =
|
||||||
|
let
|
||||||
|
inputs = args;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
inherit inputs;
|
||||||
|
inherit systemSettings;
|
||||||
|
inherit userSettings;
|
||||||
|
};
|
||||||
|
modules = [
|
||||||
|
(args.nixpkgs + "/nixos/modules/virtualisation/proxmox-lxc.nix")
|
||||||
|
args.home-manager.nixosModules.default
|
||||||
|
args.vscode-server.nixosModules.default
|
||||||
|
args.sops-nix.nixosModules.sops
|
||||||
|
./configuration.nix
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
# https://devenv.sh/guides/using-with-flakes/#the-flakenix-file
|
||||||
|
packages.${systemSettings.system} = {
|
||||||
|
devenv-up = self.devShells.${systemSettings.system}.default.config.procfileScript;
|
||||||
|
devenv-test = self.devShells.${systemSettings.system}.default.config.test;
|
||||||
|
};
|
||||||
|
|
||||||
|
devShells.${systemSettings.system}.default =
|
||||||
|
let
|
||||||
|
inputs = args;
|
||||||
|
in
|
||||||
|
args.devenv.lib.mkShell {
|
||||||
|
inherit inputs pkgs;
|
||||||
|
modules = [
|
||||||
|
({ pkgs, config, ... }: {
|
||||||
|
# This is your devenv configuration
|
||||||
|
|
||||||
|
# https://devenv.sh/reference/options/#pre-commithooks
|
||||||
|
pre-commit.hooks = {
|
||||||
|
end-of-file-fixer.enable = true;
|
||||||
|
trim-trailing-whitespace.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
# https://devenv.sh/supported-languages/python/
|
||||||
|
languages.python = {
|
||||||
|
enable = true;
|
||||||
|
version = systemSettings.pythonVersion;
|
||||||
|
uv = {
|
||||||
|
enable = true;
|
||||||
|
package = pkgs.uv;
|
||||||
|
sync = {
|
||||||
|
enable = true;
|
||||||
|
allExtras = true;
|
||||||
|
arguments = [ "-U" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
packages = with pkgs; [
|
||||||
|
git
|
||||||
|
(pkgs.python312.withPackages (python-pkgs: with python-pkgs; [
|
||||||
|
pip
|
||||||
|
setuptools
|
||||||
|
wheel
|
||||||
|
notebook
|
||||||
|
rich
|
||||||
|
]))
|
||||||
|
];
|
||||||
|
|
||||||
|
processes = {
|
||||||
|
my-jup.exec = "uv run jupyter notebook";
|
||||||
|
};
|
||||||
|
|
||||||
|
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"
|
||||||
|
'';
|
||||||
|
})
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
9
home-manager/git.nix
Normal file
9
home-manager/git.nix
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{ userSettings, ... }:
|
||||||
|
{
|
||||||
|
programs.git = {
|
||||||
|
enable = true;
|
||||||
|
extraConfig.credential.helper = "store --file ~/.git-credentials";
|
||||||
|
userName = "${userSettings.gitUserName}";
|
||||||
|
userEmail = "${userSettings.gitUserEmail}";
|
||||||
|
};
|
||||||
|
}
|
||||||
27
home-manager/home.nix
Normal file
27
home-manager/home.nix
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
{ systemSettings, userSettings, ... }:
|
||||||
|
{
|
||||||
|
security.sudo-rs = {
|
||||||
|
enable = true;
|
||||||
|
execWheelOnly = false;
|
||||||
|
wheelNeedsPassword = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
users.users.${userSettings.userName} = {
|
||||||
|
isNormalUser = true;
|
||||||
|
extraGroups = [ "wheel" "docker" ];
|
||||||
|
openssh.authorizedKeys.keyFiles = [ ../secrets/authorized_keys ];
|
||||||
|
};
|
||||||
|
|
||||||
|
home-manager = {
|
||||||
|
useGlobalPkgs = true;
|
||||||
|
users.${userSettings.userName} = { ... }: {
|
||||||
|
home.stateVersion = systemSettings.stateVersion;
|
||||||
|
systemd.user.startServices = "sd-switch"; # helps with handling systemd services when switching
|
||||||
|
imports = [ (import ./git.nix {inherit userSettings;}) ];
|
||||||
|
programs = {
|
||||||
|
ssh.enable = true;
|
||||||
|
bash.enable = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
6
nixos/default.nix
Normal file
6
nixos/default.nix
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{ ... }:
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
./docker
|
||||||
|
];
|
||||||
|
}
|
||||||
7
nixos/docker/default.nix
Normal file
7
nixos/docker/default.nix
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
{ ... }:
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
./portainer.nix
|
||||||
|
./watchtower.nix
|
||||||
|
];
|
||||||
|
}
|
||||||
7
nixos/services/default.nix
Normal file
7
nixos/services/default.nix
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
{ ... }:
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
./promtail.nix
|
||||||
|
./telegraf.nix
|
||||||
|
];
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
{ config, ... }:
|
{ config, pkgs, ... }:
|
||||||
let
|
let
|
||||||
lokiHost = "192.168.1.174:3100";
|
lokiHost = "192.168.1.174:3100";
|
||||||
in
|
in
|
||||||
@@ -7,6 +7,11 @@ in
|
|||||||
SupplementaryGroups = [ "docker" ];
|
SupplementaryGroups = [ "docker" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
environment.systemPackages = with pkgs; [
|
||||||
|
(pkgs.writeShellScriptBin "pc" "systemctl status promtail.service")
|
||||||
|
(pkgs.writeShellScriptBin "pw" "journalctl -u promtail.service -b -n 25 -f")
|
||||||
|
];
|
||||||
|
|
||||||
services.promtail = {
|
services.promtail = {
|
||||||
enable = true;
|
enable = true;
|
||||||
configuration = {
|
configuration = {
|
||||||
@@ -1,18 +1,27 @@
|
|||||||
{ ... }:
|
{ config, pkgs, ... }:
|
||||||
let
|
let
|
||||||
influxURL = "http://panoptes.john-stream.com:8086";
|
influxURL = "http://panoptes.john-stream.com:8086";
|
||||||
organization = "homelab";
|
organization = "homelab";
|
||||||
bucket = "docker";
|
bucket = "docker";
|
||||||
envFile = ./telegraf.env;
|
token = "${builtins.readFile config.sops.secrets."telegraf_influx_token".path}";
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
systemd.services.telegraf.serviceConfig = {
|
sops.secrets."telegraf_influx_token" = { };
|
||||||
SupplementaryGroups = [ "docker" ];
|
|
||||||
|
environment.systemPackages = with pkgs; [
|
||||||
|
(pkgs.writeShellScriptBin "tc" "systemctl status telegraf.service")
|
||||||
|
(pkgs.writeShellScriptBin "tw" "journalctl -u telegraf.service -b -n 25 -f")
|
||||||
|
];
|
||||||
|
|
||||||
|
systemd.services.telegraf = {
|
||||||
|
environment = {
|
||||||
|
INFLUX_WRITE_TOKEN = token;
|
||||||
|
};
|
||||||
|
serviceConfig.SupplementaryGroups = [ "docker" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
services.telegraf = {
|
services.telegraf = {
|
||||||
enable = true;
|
enable = true;
|
||||||
environmentFiles = [ "${envFile}" ];
|
|
||||||
extraConfig = {
|
extraConfig = {
|
||||||
agent = {
|
agent = {
|
||||||
interval = "10s";
|
interval = "10s";
|
||||||
3
secrets/authorized_keys
Normal file
3
secrets/authorized_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
|
||||||
21
secrets/secrets.yaml
Normal file
21
secrets/secrets.yaml
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
telegraf_influx_token: ENC[AES256_GCM,data:XHT7lvRrw9MeC0Jxe2EYTTa/iB5QLVTzp9TDJaljssRR+kGdK3va1u14NX5b6jFrHnAXLiMdMQ5UTdbsnYH43TnRkY29mcVHxwaQv+rbCgEIKOAYFeIw0g==,iv:uzBYXWYRDH6bHZ3pubWh5Qn/2dN2Rz+sjEmrqpKhA4o=,tag:wemgU05aTl9S1rwt+fVQug==,type:str]
|
||||||
|
sops:
|
||||||
|
kms: []
|
||||||
|
gcp_kms: []
|
||||||
|
azure_kv: []
|
||||||
|
hc_vault: []
|
||||||
|
age:
|
||||||
|
- recipient: age197d424aa7jpj2s735fl2h2s4c687y8vm44usx8wag0r2kh2v7ces4efdyn
|
||||||
|
enc: |
|
||||||
|
-----BEGIN AGE ENCRYPTED FILE-----
|
||||||
|
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSA2Tkc4Yml1R28zdlppY1dN
|
||||||
|
dnJMS0tLZTZQSWtNVGZDbHBKaUJ5RjJhdkZRClQ4K08rbUVoRm5jTGV0M3RzdUZv
|
||||||
|
T0tWbnFrYnNOQ1dXV21ka0dZZ0QyNk0KLS0tIC9FLzBHSVhXT0FYalc4L3VSVXNa
|
||||||
|
dmR2a2QvZVRPc3ZFc1EvVWZqMTdQcncKTc4D3riTbEcv3eeREFMIZYQk7aDvDZEt
|
||||||
|
xBCoMNVjYaLIy9ljNfLGKh0J/wed0MC6wBIfABuH6eanEvV4ob+xnw==
|
||||||
|
-----END AGE ENCRYPTED FILE-----
|
||||||
|
lastmodified: "2024-12-18T02:36:09Z"
|
||||||
|
mac: ENC[AES256_GCM,data:lXFJxFQJy9qNu2dVo+UBIfDNAeZ4U2n5c085qYmAShJrY2OiX0+Dv6n4kLg1ohgPni0VG6tAayPghHkStQPT7chFZwlAlvRol1kELWDukygWgPfZqvooDlPlH3ews16TtEM/B/cTOYFZA3X82nJgjcoEFjUHasWg2Ryic5mWe0I=,iv:ys1nRfNV6gawPjPfjfJfLGSSSsiauNEJVMMTAzcoGf4=,tag:UowQI9F59EzDEyTROACI0A==,type:str]
|
||||||
|
pgp: []
|
||||||
|
unencrypted_suffix: _unencrypted
|
||||||
|
version: 3.9.2
|
||||||
Reference in New Issue
Block a user