huecli/flake.nix

64 lines
2.1 KiB
Nix
Raw Normal View History

2024-06-04 14:08:08 +00:00
{
description = "Application packaged using poetry2nix";
inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
poetry2nix = {
url = "github:nix-community/poetry2nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, flake-utils, poetry2nix }:
2024-06-04 14:43:57 +00:00
{
overlays.default = final: prev: {
huecli = self.packages.${prev.system}.default;
};
}
//
2024-06-04 14:08:08 +00:00
flake-utils.lib.eachDefaultSystem (system:
let
# see https://github.com/nix-community/poetry2nix/tree/master#api for more functions and examples.
pkgs = nixpkgs.legacyPackages.${system};
inherit (poetry2nix.lib.mkPoetry2Nix { inherit pkgs; }) mkPoetryApplication defaultPoetryOverrides;
pypkgs-build-requirements = {
paho-mqtt = [ "hatch-vcs" ];
2024-06-04 14:58:23 +00:00
typer-slim = [ "pdm-backend" ];
2024-06-04 14:08:08 +00:00
};
p2n-overrides = defaultPoetryOverrides.extend (final: prev:
builtins.mapAttrs
(package: build-requirements:
(builtins.getAttr package prev).overridePythonAttrs (old: {
buildInputs = (old.buildInputs or [ ]) ++ (builtins.map (pkg: if builtins.isString pkg then builtins.getAttr pkg prev else pkg) build-requirements);
})
)
pypkgs-build-requirements
);
in
{
packages = {
huecli = mkPoetryApplication {
projectDir = ./.;
overrides = p2n-overrides;
nativeBuildInputs = [ pkgs.installShellFiles ];
postInstall = ''
installShellCompletion --cmd huecli \
2024-06-04 14:46:37 +00:00
--bash <($out/bin/huecli --show-completion bash) \
--zsh <($out/bin/huecli --show-completion zsh) \
--fish <($out/bin/huecli --show-completion fish)
2024-06-04 14:08:08 +00:00
'';
};
default = self.packages.${system}.huecli;
};
devShells.default = pkgs.mkShell {
inputsFrom = [ self.packages.${system}.huecli ];
packages = [
pkgs.ruff
2024-06-04 14:43:57 +00:00
pkgs.poetry
2024-06-04 14:08:08 +00:00
];
};
});
}