-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dev: upgrade flake.nix to self-contain without .venv
- Loading branch information
Showing
5 changed files
with
227 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,94 @@ | ||
{ | ||
description = "Python dev shell flake"; | ||
description = "Wrapper to run programs with different env"; | ||
|
||
inputs = { | ||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; | ||
flake-utils.url = "github:numtide/flake-utils"; | ||
pyproject-nix.url = "github:nix-community/pyproject.nix"; | ||
pyproject-nix.inputs.nixpkgs.follows = "nixpkgs"; | ||
}; | ||
|
||
outputs = { nixpkgs, flake-utils, ... }: | ||
outputs = { self, nixpkgs, flake-utils, pyproject-nix, }: | ||
flake-utils.lib.eachDefaultSystem (system: | ||
let pkgs = nixpkgs.legacyPackages.${system}; | ||
in { devShells = { default = import ./shell.nix { inherit pkgs; }; }; }); | ||
let | ||
pkgs = nixpkgs.legacyPackages.${system}; | ||
pypkgs = pkgs.python3Packages; | ||
python = pkgs.python3.override { | ||
packageOverrides = self: super: { | ||
runenv = runenv; | ||
hatch = pkgs.hatch; | ||
ruff = pkgs.ruff; | ||
mypy = pkgs.mypy; | ||
black = pkgs.black; | ||
}; | ||
}; | ||
project = | ||
pyproject-nix.lib.project.loadPyproject { projectRoot = ./.; }; | ||
|
||
runenv = python.pkgs.buildPythonPackage rec { | ||
pname = "runenv"; | ||
version = "1.2.2"; | ||
|
||
src = python.pkgs.fetchPypi { | ||
inherit pname version; | ||
sha256 = ""; | ||
}; | ||
|
||
doCheck = false; | ||
checkInputs = [ ]; | ||
propagatedBuildInputs = [ pypkgs.feedparser ]; | ||
|
||
meta = with pkgs.lib; { | ||
homepage = "https://github.com/onjin/runenv"; | ||
description = "Wrapper to run programs with different env"; | ||
license = licenses.mit; | ||
}; | ||
}; | ||
|
||
in { | ||
packages = { | ||
runenv = let | ||
# Returns an attribute set that can be passed to `buildPythonPackage`. | ||
attrs = project.renderers.buildPythonPackage { | ||
inherit python; | ||
extras = [ ]; | ||
}; | ||
# Pass attributes to buildPythonPackage. | ||
# Here is a good spot to add on any missing or custom attributes. | ||
in python.pkgs.buildPythonPackage (attrs // { | ||
# Because we're following main, use the git rev as version | ||
version = | ||
if (self ? rev) then self.shortRev else self.dirtyShortRev; | ||
}); | ||
default = self.packages.${system}.runenv; | ||
}; | ||
devShells = { | ||
default = let | ||
# Returns a function that can be passed to `python.withPackages` | ||
arg = project.renderers.withPackages { | ||
inherit python; | ||
extras = [ "develop" ]; | ||
}; | ||
|
||
# Returns a wrapped environment (virtualenv like) with all our packages | ||
pythonEnv = python.withPackages arg; | ||
|
||
# Create a devShell like normal. | ||
in pkgs.mkShell { | ||
packages = [ | ||
self.packages.${system}.runenv | ||
pythonEnv | ||
pkgs.gnumake | ||
pkgs.hatch | ||
pkgs.ruff | ||
pkgs.mypy | ||
pkgs.black | ||
pypkgs.keyrings-alt | ||
]; | ||
shellHook = '' | ||
export PYTHONPATH="$(pwd):$PYTHONPATH" | ||
''; | ||
}; | ||
}; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters