started flakes
This commit is contained in:
11
appdaemon/devenv.nix
Normal file
11
appdaemon/devenv.nix
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{ pkgs, config, ... }: {
|
||||||
|
# This is your devenv configuration
|
||||||
|
packages = [ pkgs.hello ];
|
||||||
|
|
||||||
|
enterShell = ''
|
||||||
|
export PS1="\[\033[01;34m\](AppDaemon)\[\033[00m\] \[\]\[\]\n\[\033[1;32m\][\[\e]0;\u@\h: \w\a\]\u@\h:\w]\$\[\033[0m\] \[\]\[\]"
|
||||||
|
echo "AppDaemon v$(uv pip show appdaemon | awk '/^Version:/ {print $2}') development shell started"
|
||||||
|
'';
|
||||||
|
|
||||||
|
processes.run.exec = "hello";
|
||||||
|
}
|
||||||
68
appdaemon/flake.nix
Normal file
68
appdaemon/flake.nix
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
{
|
||||||
|
description = "AppDaemon development";
|
||||||
|
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||||
|
devenv.url = "github:cachix/devenv";
|
||||||
|
};
|
||||||
|
|
||||||
|
# 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};
|
||||||
|
python = pkgs.python312;
|
||||||
|
adPath = "/usr/src/app";
|
||||||
|
# uv = "${pkgs.uv}/bin/uv";
|
||||||
|
in
|
||||||
|
{
|
||||||
|
packages.${system}.devenv-up = self.devShells.${system}.default.config.procfileScript;
|
||||||
|
packages.${system}.devenv-test = self.devShells.${system}.default.config.test;
|
||||||
|
|
||||||
|
devShells.${system}.default = devenv.lib.mkShell {
|
||||||
|
inherit inputs pkgs;
|
||||||
|
modules = [
|
||||||
|
./devenv.nix
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
devShells.${system}.native = pkgs.mkShell {
|
||||||
|
nativeBuildInputs = with pkgs; [
|
||||||
|
git
|
||||||
|
uv
|
||||||
|
python
|
||||||
|
];
|
||||||
|
|
||||||
|
packages = with pkgs; [
|
||||||
|
(writeShellScriptBin "cd-ad" "cd ${adPath}")
|
||||||
|
(writeShellScriptBin "full-build" ''
|
||||||
|
rm -rf ${adPath}/build ${adPath}/dist
|
||||||
|
${pkgs.uv}/bin/uv build --wheel ${adPath}
|
||||||
|
docker build -t acockburn/appdaemon:local-dev ${adPath}
|
||||||
|
'')
|
||||||
|
];
|
||||||
|
|
||||||
|
shellHook = ''
|
||||||
|
cd ${adPath}
|
||||||
|
echo "URL: $(${pkgs.git}/bin/git config --get remote.origin.url)"
|
||||||
|
echo "Branch: $(${pkgs.git}/bin/git rev-parse --abbrev-ref HEAD)"
|
||||||
|
echo "Hash: $(${pkgs.git}/bin/git rev-parse --short HEAD)"
|
||||||
|
|
||||||
|
${pkgs.uv}/bin/uv sync -U --all-extras
|
||||||
|
export UV_PYTHON="${adPath}/.venv/bin/python"
|
||||||
|
alias clean="rm -rf ${adPath}/dist ${adPath}/build"
|
||||||
|
alias appdaemon="${pkgs.uv}/bin/uv run --frozen python -m appdaemon"
|
||||||
|
alias ad="appdaemon"
|
||||||
|
|
||||||
|
export PS1="\[\033[01;34m\](AppDaemon)\[\033[00m\] \[\]\[\]\n\[\033[1;32m\][\[\e]0;\u@\h: \w\a\]\u@\h:\w]\$\[\033[0m\] \[\]\[\]"
|
||||||
|
echo "AppDaemon v$(uv pip show appdaemon | awk '/^Version:/ {print $2}') development shell started"
|
||||||
|
'';
|
||||||
|
|
||||||
|
UV_LINK_MODE = "copy";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -18,10 +18,15 @@ in
|
|||||||
./portainer.nix
|
./portainer.nix
|
||||||
./watchtower.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
|
||||||
|
'')
|
||||||
(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}
|
||||||
@@ -30,7 +35,7 @@ in
|
|||||||
echo "${adPath} already exists"
|
echo "${adPath} already exists"
|
||||||
fi
|
fi
|
||||||
'')
|
'')
|
||||||
unstable.uv
|
# unstable.uv
|
||||||
bash
|
bash
|
||||||
git
|
git
|
||||||
eza
|
eza
|
||||||
|
|||||||
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"
|
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user