greendeck/flake.nix
2023-03-28 09:01:43 -05:00

108 lines
3.8 KiB
Nix

{
description = "My Streamdeck";
inputs = {
nixpkgs = {
url = "nixpkgs/nixos-unstable";
};
flake-utils = {
url = "github:numtide/flake-utils";
};
};
outputs = { self, nixpkgs, flake-utils, ... }@inputs:
flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = import nixpkgs {
inherit system;
};
in
{
devShells.default =
# let
# python = pkgs.python310.withPackages (ps: with ps; [
# poetry-core
# ]);
# in
pkgs.mkShell {
buildInputs = [
#python
pkgs.poetry
pkgs.hidapi
pkgs.libusb1
];
shellHook = ''
export HIDAPI_HOME=${pkgs.hidapi}
export MAGICK_HOME=${pkgs.imagemagickBig}
export POETRY_VIRTUALENVS_IN_PROJECT=true
export PS1='\[\033[1;34m\][greendeck:\w]\$\[\033[0m\] '
export PATH=''$(pwd)/.venv/bin:$PATH
'';
};
packages = {
greendeck = pkgs.poetry2nix.mkPoetryApplication {
python = pkgs.python310;
projectDir = ./.;
propagatedBuildInputs = [
pkgs.hidapi
];
postPatch = ''
substituteInPlace greendeck/lib/hidapi/library.py \
--replace \
'os.getenv("HIDAPI_LIBRARY")' \
'"${pkgs.hidapi}/lib/libhidapi-libusb.so.0"'
'';
overrides = pkgs.poetry2nix.overrides.withDefaults
(
self: super: {
wand = super.wand.overridePythonAttrs
(
old: {
postPatch = ''
substituteInPlace wand/api.py \
--replace \
"os.environ.get('MAGICK_HOME')" \
"'${pkgs.imagemagickBig}'"
'';
propagatedBuildInputs = old.propagatedBuildInputs ++ [ pkgs.imagemagickBig ];
}
);
types-deprecated = super.types-deprecated.overridePythonAttrs (
old: {
buildInputs = old.buildInputs ++ [ pkgs.python3Packages.setuptools ];
}
);
pydantic-yaml = super.pydantic-yaml.overridePythonAttrs (
old: {
buildInputs = old.buildInputs ++ [ pkgs.python3Packages.setuptools ];
}
);
pydocstyle = super.pydocstyle.overridePythonAttrs (
old: {
buildInputs = old.buildInputs ++ [
# pkgs.python3Packages.poetry-core
];
}
);
pydocstringformatter = super.pydocstringformatter.overridePythonAttrs (
old: {
buildInputs = old.buildInputs ++ [
pkgs.python3Packages.poetry-core
pkgs.python3Packages.setuptools
];
}
);
asyncdbus = super.asyncdbus.overridePythonAttrs (
old: {
buildInputs = old.buildInputs ++ [ pkgs.python3Packages.setuptools-scm ];
}
);
}
);
};
};
default = self.packages.${system}.greendeck;
}
);
}