republisher/shell.nix

52 lines
1.6 KiB
Nix
Raw Normal View History

2024-04-18 17:28:09 +02:00
{
system ? "x86_64-linux",
pkgs ? import <nixpkgs> { inherit system; },
dev ? true,
}:
2024-02-03 09:31:33 +01:00
let
2024-04-17 10:43:19 +02:00
pyCurrent = pkgs.python311;
2024-04-18 17:28:09 +02:00
poetryExtras = if dev then [ "dev" ] else [ ];
2024-04-17 10:43:19 +02:00
poetryInstallExtras = (
2024-04-18 17:28:09 +02:00
if poetryExtras == [ ] then
""
else
pkgs.lib.concatStrings [
" --with="
(pkgs.lib.concatStringsSep "," poetryExtras)
]
2024-04-17 10:43:19 +02:00
);
2024-02-03 09:31:33 +01:00
packages = [
2024-04-18 17:28:09 +02:00
pkgs.ffmpeg_5-headless
#(pyCurrent (ps: with ps; [ ffmpeg-python ]))
2024-02-03 09:31:33 +01:00
pkgs.zsh
2024-04-18 17:28:09 +02:00
(pkgs.poetry.withPlugins (ps: with ps; [ poetry-plugin-up ]))
2024-02-03 09:31:33 +01:00
];
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [
pkgs.stdenv.cc.cc
# Add any missing library needed
# You can use the nix-index package to locate them, e.g. nix-locate -w --top-level --at-root /lib/libudev.so.1
];
# Put the venv on the repo, so direnv can access it
POETRY_VIRTUALENVS_IN_PROJECT = "true";
POETRY_VIRTUALENVS_PATH = "{project-dir}/.venv";
# Use python from path, so you can use a different version to the one bundled with poetry
POETRY_VIRTUALENVS_PREFER_ACTIVE_PYTHON = "true";
in
2024-04-18 17:28:09 +02:00
pkgs.mkShell {
buildInputs = packages;
shellHook = ''
export SHELL=${pkgs.zsh}
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}"
export POETRY_VIRTUALENVS_IN_PROJECT="${POETRY_VIRTUALENVS_IN_PROJECT}"
export POETRY_VIRTUALENVS_PATH="${POETRY_VIRTUALENVS_PATH}"
export POETRY_VIRTUALENVS_PREFER_ACTIVE_PYTHON="${POETRY_VIRTUALENVS_PREFER_ACTIVE_PYTHON}"
export PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring
poetry env use "${pyCurrent}/bin/python"
poetry install -vv --sync${poetryInstallExtras}
'';
}