I’ve got a simple case, I’ve created a derivation for flask-digest-static
with Nix. Here is my attempt to provide it as a plugin to the flask
cli. I can only get flask
to see the plugin by using nix-shell
first, and I do not understand why.
- Put this into
test.nix
and runnix-shell test.nix
{ pkgs ? import (fetchTarball https://github.com/nixos/nixpkgs/archive/release-21.11.tar.gz) {} }:
let
flask-static-digest = pkgs.python39Packages.buildPythonPackage rec {
pname = "Flask-Static-Digest";
version = "0.2.1";
buildInputs = [ pkgs.python39Packages.flask ];
src = pkgs.python39Packages.fetchPypi {
inherit pname version;
sha256 = "sha256-dSiwiiwS3DqCgJa2buJhLzI9UL420B8oF7dn+7HOym4=";
};
};
in
{
y = pkgs.python39Packages.flask.overrideAttrs (old: {
propagatedBuildInputs = old.propagatedBuildInputs ++ [ flask-static-digest ];
});
}
nix-shell -p python39Packages.flask
- run
flask --help
- Observe that
digest
is available in the help.
Full example
user: matthew swordfish in ~/tmp
❯ cat test.nix
{ pkgs ? import (fetchTarball https://github.com/nixos/nixpkgs/archive/release-21.11.tar.gz) {} }:
let
flask-static-digest = pkgs.python39Packages.buildPythonPackage rec {
pname = "Flask-Static-Digest";
version = "0.2.1";
buildInputs = [ pkgs.python39Packages.flask ];
src = pkgs.python39Packages.fetchPypi {
inherit pname version;
sha256 = "sha256-dSiwiiwS3DqCgJa2buJhLzI9UL420B8oF7dn+7HOym4=";
};
};
in
{
y = pkgs.python39Packages.flask.overrideAttrs (old: {
propagatedBuildInputs = old.propagatedBuildInputs ++ [ flask-static-digest ];
});
}
user: matthew swordfish in ~/tmp
❯ nix build -f test.nix
user: matthew swordfish in ~/tmp took 6s
❯ ./result/bin/flask --help | grep digest
Error: Could not locate a Flask application. You did not provide the "FLASK_APP" environment variable, and a "wsgi.py" or "app.py" module was not found in the current directory.
user: matthew swordfish in ~/tmp
❯ nix-shell test.nix
Sourcing python-remove-tests-dir-hook
Sourcing python-catch-conflicts-hook.sh
Sourcing python-remove-bin-bytecode-hook.sh
Sourcing setuptools-build-hook
Using setuptoolsBuildPhase
Using setuptoolsShellHook
Sourcing pip-install-hook
Using pipInstallPhase
Sourcing python-imports-check-hook.sh
Using pythonImportsCheckPhase
Sourcing python-namespaces-hook
Sourcing setuptools-check-hook
Using setuptoolsCheckPhase
Sourcing pytest-check-hook
Using pytestCheckPhase
Removing setuptoolsCheckPhase
Executing setuptoolsShellHook
Finished executing setuptoolsShellHook
user: matthew swordfish in ~/tmp via ❄️ impure (python3.9-Flask-2.0.2)
❯ ./result/bin/flask --help | grep digest
Error: Could not locate a Flask application. You did not provide the "FLASK_APP" environment variable, and a "wsgi.py" or "app.py" module was not found in the current directory.
digest md5 tag and gzip static files.