1
0
Fork 0
nix-overlay/packages/weewx.nix

148 lines
4.4 KiB
Nix
Raw Normal View History

2024-06-29 21:11:25 +00:00
{ pkgs, lib, poetry2nix }:
let
python = pkgs.python311;
pythonPackages = pkgs.python311Packages;
weewx = pkgs.fetchFromGitHub {
owner = "weewx";
repo = "weewx";
rev = "v5.0.2";
hash = "sha256-UVHoi+hXcpbledeXlZ+7TDwIeLIXYazmpDcwW3QW5BY=";
};
plugin-weewx-mqtt = pkgs.fetchurl {
url = "https://github.com/matthewwall/weewx-mqtt/archive/d1739f3d57f07f402ddd3c20ac10ad5f874be1e9.zip";
hash = "sha256-mNfZlrJPCo/vD5Dgt8PYa6ZHN+rTqqIA6c7MozY9Vss=";
};
plugin-weewx-mqtt-subscribe = pkgs.fetchurl {
url = "https://github.com/bellrichm/weewx-mqttsubscribe/archive/refs/tags/v2.3.1.zip";
hash = "sha256-co9fTm6vBZzg2jSKi7kmi7n//pi/bLE3rJhTT2O1ZtE=";
};
2024-07-16 19:09:04 +00:00
plugin-weewx-xaggs = pkgs.fetchurl {
url = "https://github.com/tkeffer/weewx-xaggs/archive/5d11e149f96a98fe0518b9feb4ddc8a0d461db63.zip";
hash = "sha256-lHg+/3l60wqV0r+9BHMtzuDQsrVJFP/Ql2XAHjp0UM4=";
};
2024-06-29 21:11:25 +00:00
plugin-weewx-gts = pkgs.fetchurl {
url = "https://github.com/roe-dl/weewx-GTS/archive/3d9c04d4fc2541b555c2a3274c4dc093126fab2e.zip";
hash = "sha256-h5tomXhi0Me+tJtfrvgePGLDo4sQm+0SkrndOWjVUzw=";
};
plugin-weewx-purpleair = pkgs.fetchurl {
url = "https://github.com/bakerkj/weewx-purpleair/archive/refs/tags/v0.9.zip";
hash = "sha256-L7mzbsb/Ewzd6kCrceOESMzEJDLjshFohgVK2U5/ZsM=";
};
plugin-weewx-wdc = pkgs.fetchurl {
url = "https://github.com/Daveiano/weewx-wdc/releases/download/v3.5.1/weewx-wdc-v3.5.1.zip";
hash = "sha256-MPjh/a6+f668yfD5AyCWFmyD1Q5p8nxCzESOUKx7wkQ=";
};
2024-06-30 13:30:13 +00:00
custom-extensions = /* python */ ''
#
# Copyright (c) 2009-2015 Tom Keffer <tkeffer@gmail.com>
#
# See the file LICENSE.txt for your full rights.
#
"""User extensions module
This module is imported from the main executable, so anything put here will be
executed before anything else happens. This makes it a good place to put user
extensions.
"""
import locale
# This will use the locale specified by the environment variable 'LANG'
# Other options are possible. See:
# http://docs.python.org/2/library/locale.html#locale.setlocale
locale.setlocale(locale.LC_ALL, ''')
import weewx.units
weewx.units.obs_group_dict['soilMoist1'] = 'group_percent'
weewx.units.obs_group_dict['luminosity'] = 'group_illuminance'
weewx.units.obs_group_dict['soilMoistBatteryVoltage1'] = 'group_volt'
weewx.units.obs_group_dict['soilTempBatteryVoltage1'] = 'group_volt'
2024-07-15 11:16:27 +00:00
weewx.units.obs_group_dict['solarEnergyDay'] = 'group_energy'
weewx.units.obs_group_dict['solarEnergyActive'] = 'group_power'
2024-06-30 13:30:13 +00:00
'';
2024-06-29 21:11:25 +00:00
in
poetry2nix.mkPoetryApplication {
inherit python;
projectDir = weewx;
overrides = poetry2nix.defaultPoetryOverrides.extend (final: prev: {
ct3 = prev.ct3.overridePythonAttrs (old: {
buildInputs = (old.buildInputs or [ ]) ++ [ prev.setuptools ];
});
pyserial = prev.pyserial.overridePythonAttrs (old: {
buildInputs = (old.buildInputs or [ ]) ++ [ prev.setuptools ];
});
});
nativeBuildInputs = with pythonPackages; [
# Poetry (?)
cachecontrol
cleo
crashtest
dulwich
fastjsonschema
keyring
pexpect
pkginfo
platformdirs
poetry-core
requests-toolbelt
shellingham
tomlkit
trove-classifiers
virtualenv
xattr
pkgs.poetry
pkgs.poetryPlugins.poetry-plugin-export
pkgs.unzip
];
2024-06-30 13:30:13 +00:00
propagatedBuildInputs = with pythonPackages; [
2024-06-29 21:11:25 +00:00
paho-mqtt
requests
];
postPatch = ''
2024-07-07 10:56:47 +00:00
substituteInPlace pyproject.toml --replace-fail 'requires = ["poetry>=0.12"]' "requires = []"
2024-06-29 21:11:25 +00:00
substituteInPlace pyproject.toml --replace-fail "poetry.masonry" "poetry.core.masonry"
'';
postInstall = ''
mkdir -p $out/home/weewx-data
cp $out/lib/*/site-packages/weewx_data/weewx.conf $out/home/weewx-data/
mkdir $TMPDIR/weewx-wdc/
unzip ${plugin-weewx-wdc} -d $TMPDIR/weewx-wdc/
HOME=$out/home $out/bin/weectl extension install ${plugin-weewx-mqtt} --yes
HOME=$out/home $out/bin/weectl extension install ${plugin-weewx-mqtt-subscribe} --yes
2024-07-16 19:09:04 +00:00
HOME=$out/home $out/bin/weectl extension install ${plugin-weewx-xaggs} --yes
2024-06-29 21:11:25 +00:00
HOME=$out/home $out/bin/weectl extension install ${plugin-weewx-gts} --yes
HOME=$out/home $out/bin/weectl extension install ${plugin-weewx-purpleair} --yes
HOME=$out/home $out/bin/weectl extension install $TMPDIR/weewx-wdc/ --yes
2024-06-30 13:30:13 +00:00
cat << EOF > $out/home/weewx-data/bin/user/extensions.py
${custom-extensions}
EOF
2024-06-29 21:11:25 +00:00
'';
}
2024-06-30 13:30:13 +00:00