control4-knx-presence/flake.nix
2025-11-03 22:13:37 +01:00

85 lines
2.6 KiB
Nix

{
inputs = {
nix.url = "git+ssh://git@git.c3c.cz/C3C/nix";
};
outputs =
{ self, nix }:
{
formatter = nix.formatter;
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
'';
};
};
}
];
};
});
};
}