feat(coloryou): make build pure

This commit is contained in:
matt1432 2023-09-30 02:06:40 -04:00
parent 6806471b24
commit 7634fab64f

View file

@ -1,35 +1,12 @@
# https://blog.hackeriet.no/packaging-python-script-for-nixos/
{ python3Packages }:
# Below, we can supply defaults for the function arguments to make the script
# runnable with `nix-build` without having to supply arguments manually.
# Also, this lets me build with Python 3.11 by default, but makes it easy
# to change the python version for customised builds (e.g. testing).
{ nixpkgs ? import <nixpkgs> {}, pythonPkgs ? nixpkgs.pkgs.python311Packages }:
let
# This takes all Nix packages into this scope
inherit (nixpkgs) pkgs;
# This takes all Python packages from the selected version into this scope.
inherit pythonPkgs;
# Inject dependencies into the build function
f = { buildPythonPackage, utils, material-color-utilities }:
buildPythonPackage rec {
python3Packages.buildPythonPackage rec {
pname = "coloryou";
version = "0.2.0";
version = "0.0.1";
# If you have your sources locally, you can specify a path
src = ./.;
# Pull source from a Git server.
#src = builtins.fetchGit {
#url = "git://github.com/stigok/ruterstop.git";
#ref = "master";
#rev = "a9a4cd60e609ed3471b4b8fac8958d009053260d";
#};
# Specify runtime dependencies for the package
propagatedBuildInputs = [ utils material-color-utilities ];
propagatedBuildInputs = with python3Packages; [ utils material-color-utilities ];
postInstall = ''
mv -v $out/bin/coloryou.py $out/bin/coloryou
@ -40,9 +17,4 @@ let
Get Material You colors from an image.
'';
};
};
drv = pythonPkgs.callPackage f {};
in
if pkgs.lib.inNixShell then drv.env else drv
}