Get rid of deps

This commit is contained in:
2026-07-06 23:21:42 +02:00
parent a426b62d4a
commit b176c7705d
21 changed files with 262 additions and 528 deletions
+82 -74
View File
@@ -1,84 +1,92 @@
{
description = "c3c-knx-presence development environment";
inputs = {
nix.url = "git+ssh://git@git.c3c.cz/C3C/nix";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs =
{ self, nix }:
{
formatter = nix.formatter;
self,
nixpkgs,
flake-utils,
}:
let
version = "0.0.1";
gitRev = self.shortRev or self.dirtyShortRev;
driverName = "c3c-knx-presence";
in
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
{
formatter = pkgs.nixfmt-rfc-style;
packages = nix.lib.forAllSystems (pkgs: {
devenv-up = self.devShells.${pkgs.system}.default.config.procfileScript;
devenv-test = self.devShells.${pkgs.system}.default.config.test;
});
devShells = nix.lib.forAllSystems (pkgs: {
default = nix.lib.mkDevenvShell {
inherit pkgs;
inputs = {
self = self;
nixpkgs = pkgs;
};
modules = [
{
packages = [
nix.lib.control4-env.${pkgs.system}
];
scripts = {
menu = {
description = "Print this menu";
exec = ''
echo "Commands:"
echo -n '${
builtins.toJSON (
builtins.mapAttrs (s: value: value.description) self.devShells.${pkgs.system}.default.config.scripts
)
}' | \
${pkgs.jq}/bin/jq -r 'to_entries | map(" \(.key)\n" + " - \(if .value == "" then "no description provided" else .value end)") | "" + .[]'
'';
};
generate = {
exec = ''
${nix.lib.cd_root}
rm -rf ./src/control4-utils
cp -rp node_modules/@c3c/control4-utils/src ./src/control4-utils
node_modules/@c3c/control4-utils/bin/driver-manager ./package.json
mdtohtml -page README.md > src/www/documentation.html
'';
};
github-push = {
description = "Push current branch and all tags to github, lazy workaround for automated mirror. TODO: Automate";
exec = ''
b=$(git rev-parse --abbrev-ref HEAD)
git push git@github.com:Sharsie/control4-knx-presence.git "$b":"$b"
git push git@github.com:Sharsie/control4-knx-presence.git --tags
'';
};
lint = {
exec = ''
${nix.lib.cd_root}
'';
};
fix = {
exec = ''
${nix.lib.cd_root}
nix fmt ./*.nix
stylua ./src
'';
};
};
}
devShells.default = pkgs.mkShell {
packages = with pkgs; [
luajit
zip
unzip
libxml2
];
shellHook = ''
echo "${driverName} dev shell"
echo " build build .c4z into working dir"
'';
};
});
};
apps.default = {
type = "app";
program = "${pkgs.writeShellScript "build-c4z" ''
set -euo pipefail
nix build
# Move the file into a predefined directory mounted in the Composer Pro environment
rm -f ../compiled/${driverName}.c4z
cp -L result/${driverName}.c4z ../compiled
echo "Built ${gitRev}: ../compiled/${driverName}.c4z"
''}";
};
packages.default = pkgs.stdenv.mkDerivation {
pname = driverName;
inherit version;
src = ./.;
nativeBuildInputs = [
pkgs.libxml2
pkgs.luajit
pkgs.zip
];
buildPhase = ''
# Prepare build dir
cp -r src build-src
${pkgs.lowdown}/bin/lowdown -s README.md > build-src/www/documentation.html
# Validate Lua syntax (compile-check only; driver.lua calls into the
# real Control4 "C4" global at load time, so it cannot be executed here)
cd build-src
luajit -e "assert(loadfile('driver.lua'))"
cd -
# Validate driver manifest
xmllint --noout build-src/driver.xml
# Stamp git rev into driver.lua
( ${pkgs.gnused}/bin/sed -i 's/DRIVER_VERSION = "uninitialized"/DRIVER_VERSION = "${gitRev}"/' build-src/driver.lua)
'';
installPhase = ''
mkdir -p $out
cd build-src
zip -rq $out/${driverName}.c4z .
'';
};
}
);
}