60 lines
2.1 KiB
Nix
60 lines
2.1 KiB
Nix
{
|
|
inputs = {
|
|
dream2nix.url = "github:nix-community/dream2nix";
|
|
clan-core .url = "git+https://git.clan.lol/clan/clan-core";
|
|
clan-core.inputs.nixpkgs.follows = "nixpkgs";
|
|
nixpkgs.follows = "dream2nix/nixpkgs";
|
|
};
|
|
|
|
outputs =
|
|
{ dream2nix, nixpkgs, clan-core, ... } @ inputs:
|
|
let
|
|
system = "x86_64-linux";
|
|
lib = nixpkgs.lib;
|
|
pkgs = nixpkgs.legacyPackages.${system};
|
|
package = dream2nix.lib.evalModules {
|
|
modules = [ ./nix/package.nix ];
|
|
packageSets.nixpkgs = pkgs;
|
|
specialArgs = { inherit pkgs inputs; };
|
|
};
|
|
pyproject = lib.importTOML ./pyproject.toml;
|
|
scripts = lib.flip lib.mapAttrsToList pyproject.project.scripts (
|
|
execName: funcPath: let
|
|
split = lib.splitString ":" funcPath;
|
|
module = lib.concatStringsSep "." (lib.init split);
|
|
func = lib.last split;
|
|
pythonCmd = ''
|
|
import ${module}
|
|
${module}.${func}()
|
|
'';
|
|
in
|
|
pkgs.writers.writePython3Bin execName {flakeIgnore = ["*"];} pythonCmd
|
|
);
|
|
in
|
|
{
|
|
packages.${system}.default = package;
|
|
devShells.${system}.default = pkgs.mkShell {
|
|
inherit (package.meta) options_clan options_nixos;
|
|
inputsFrom = [ package.devShell ];
|
|
packages = [
|
|
pkgs.pdm
|
|
pkgs.ruff
|
|
] ++ scripts;
|
|
buildInputs = [ pkgs.portaudio ];
|
|
shellHook = ''
|
|
if [ -e .env ]; then
|
|
source .env
|
|
fi
|
|
echo "$(which python)" > .pdm-python
|
|
export PYTHONPATH="$(realpath ./src):$PYTHONPATH"
|
|
export PYTHONPATH="${pkgs.python3.pkgs.tkinter}/${pkgs.python3.sitePackages}:$PYTHONPATH"
|
|
export PYTHONPATH="$PYTHONPATH:$(realpath ${clan-core.packages.${system}.clan-cli}/lib/*/site-packages)"
|
|
export LD_LIBRARY_PATH="${pkgs.portaudio}/lib:${lib.getLib pkgs.libsndfile}/lib"
|
|
export NIX_PATH=nixpkgs=${pkgs.path}
|
|
# print in green
|
|
echo -e "\\033[0;32mPython executables: ${toString (lib.attrNames pyproject.project.scripts)}\\033[0m"
|
|
'';
|
|
};
|
|
};
|
|
}
|