greendeck/flake.nix

121 lines
3.5 KiB
Nix
Raw Normal View History

2022-12-13 14:25:50 -06:00
{
description = "My Streamdeck";
inputs = {
nixpkgs = {
2024-11-07 20:50:15 -06:00
url = "nixpkgs/nixos-unstable";
2023-08-30 22:07:52 -05:00
};
poetry2nix = {
url = "github:nix-community/poetry2nix";
inputs.nixpkgs.follows = "nixpkgs";
2022-12-13 14:25:50 -06:00
};
flake-utils = {
url = "github:numtide/flake-utils";
};
2023-08-29 15:42:03 -05:00
make-shell = {
url = "github:ursi/nix-make-shell";
};
2022-12-13 14:25:50 -06:00
};
2024-11-07 20:50:15 -06:00
outputs = {
self,
nixpkgs,
poetry2nix,
flake-utils,
...
} @ inputs:
2022-12-13 14:25:50 -06:00
flake-utils.lib.eachDefaultSystem
2024-11-07 20:50:15 -06:00
(
system: let
pkgs = import nixpkgs {
inherit system;
};
inherit (poetry2nix.lib.mkPoetry2Nix {inherit pkgs;}) mkPoetryApplication overrides;
2024-11-07 21:33:35 -06:00
python = pkgs.python312.withPackages (ps:
2024-11-07 20:50:15 -06:00
with ps; [
2023-08-29 21:25:39 -05:00
poetry-core
]);
2024-11-07 20:50:15 -06:00
in {
devShells.default = let
make-shell = import inputs.make-shell {
inherit system;
pkgs = pkgs;
};
project = "greendeck";
2022-12-13 14:25:50 -06:00
in
2024-11-07 20:50:15 -06:00
make-shell {
packages = [
python
pkgs.poetry
pkgs.hidapi
pkgs.libusb1
];
env = {
HIDAPI_HOME = pkgs.hidapi;
MAGICK_HOME = pkgs.imagemagickBig;
POETRY_VIRTUALENVS_IN_PROJECT = "true";
name = project;
2022-12-13 14:25:50 -06:00
};
2024-11-07 20:50:15 -06:00
setup = ''
export PATH=''$(pwd)/.venv/bin:$PATH
'';
};
packages = {
greendeck = mkPoetryApplication {
2024-11-07 21:33:35 -06:00
python = pkgs.python312;
2024-11-07 20:50:15 -06:00
projectDir = ./.;
2024-11-07 21:33:35 -06:00
# groups = [];
2024-11-07 20:50:15 -06:00
propagatedBuildInputs = [
pkgs.hidapi
];
postPatch = ''
substituteInPlace greendeck/lib/hidapi/library.py \
--replace \
'os.getenv("HIDAPI_LIBRARY")' \
'"${pkgs.hidapi}/lib/libhidapi-libusb.so.0"'
'';
overrides =
overrides.withDefaults
(
self: super: {
wand =
super.wand.overridePythonAttrs
(
2022-12-24 11:10:51 -06:00
old: {
2024-11-07 20:50:15 -06:00
postPatch = ''
substituteInPlace wand/api.py \
--replace \
"os.environ.get('MAGICK_HOME')" \
"'${pkgs.imagemagickBig}'"
'';
propagatedBuildInputs = old.propagatedBuildInputs ++ [pkgs.imagemagickBig];
2022-12-13 14:25:50 -06:00
}
);
2024-11-07 20:50:15 -06:00
# attrs = super.pydantic-yaml.overridePythonAttrs (
# old: {
# buildInputs = old.buildInputs ++ [ self.hatchling ];
# }
# );
# pytest = super.pytest.overridePythonAttrs (
# old: {
# buildInputs = [ self.attrs ];
# }
# );
pydantic-yaml = super.pydantic-yaml.overridePythonAttrs (
old: {
2024-11-07 21:33:35 -06:00
buildInputs = old.buildInputs ++ [self.setuptools-scm];
2024-11-07 20:50:15 -06:00
}
);
asyncdbus = super.asyncdbus.overridePythonAttrs (
old: {
buildInputs = old.buildInputs ++ [self.setuptools-scm];
}
);
}
);
2022-12-13 14:25:50 -06:00
};
2024-11-07 20:50:15 -06:00
};
default = self.packages.${system}.greendeck;
}
);
2022-12-13 14:25:50 -06:00
}