ct-Open-Source / ct-Open-Source/tuya-convert
Add nix flake to documentation
- Dominant language
- Python
- Stars
- 5.1k
- Forks
- 523
- PR merge metrics
- No merged PRs in 30d
Description
Hi there,
i think i made it happen to
- Create a nix flake satisfying all dependencies
- Deactivate NetworkManager and firewall (necessary) on entering flake devShell
- Re-Activate NetworkManager and firewall on leaving flake devShell
So using the flake below, you only need to run `nix develop` in the same directory
Then follow the official documentation (clone git, edit config, run `start_flash_sh`) and if you leave the flake, everything gets re-enabled
Maybe thats convenient for others
```
{
description = "Dev shell with Python, MQTT, sslpsk, etc.";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
};
python = pkgs.python3;
pythonEnv = python.withPackages (ps: with ps; [
paho-mqtt
tornado
pycryptodomex
(ps.buildPythonPackage {
pname = "sslpsk";
version = "unstable-2021-05-28";
src = pkgs.fetchFromGitHub {
owner = "drbild";
repo = "sslpsk";
rev = "d88123a75786953f82f5e25d6c43d9d9259acb62";
sha256 = "sha256-RqaZLtRMzYJPKXBBsw1alujGyqWAQRSQLPyAR8Zi6t4=";
};
nativeBuildInputs = [ pkgs.openssl.dev ];
propagatedBuildInputs = [ pkgs.openssl ];
pythonImportsCheck = [ "sslpsk" ];
})
]);
in {
devShells.default = pkgs.mkShell {
name = "prerequisites-shell";
buildInputs = [
pkgs.git
pkgs.iw
pkgs.dnsmasq
pkgs.util-linux
pkgs.hostapd
pkgs.screen
pkgs.curl
pkgs.mosquitto
pkgs.haveged
pkgs.nettools
pkgs.openssl.dev
pkgs.openssl
pkgs.iproute2
pkgs.iputils
pythonEnv
];
shellHook = ''
echo "✅ Development environment ready."
echo "Deactivating firewall and NetworkManager services..."
sudo systemctl stop NetworkManager.service
sudo systemctl stop firewall
cleanup() {
echo "🔄 Re-activating firewall and NetworkManager..."
sudo systemctl start firewall
sudo systemctl start NetworkManager.service
}
trap cleanup EXIT
'';
};
});
}
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reading the official documentation for cloning the repository, editing the config, and running `start_flash_h`, then inspect where a new flake would belong. Review the proposed dependencies and shell behavior in the issue, including service handling. Done means `nix develop` provides the documented prerequisites and leaving the shell restores the services.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, shell
- Domain
- devops, documentation, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100