mirror of
https://github.com/Swarsel/.dotfiles.git
synced 2025-12-06 09:07:21 +01:00
feat: expose python flake to all systems
This commit is contained in:
parent
5915a28ba0
commit
fbc134388d
1 changed files with 71 additions and 58 deletions
|
|
@ -32,6 +32,7 @@
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
inherit (nixpkgs) lib;
|
inherit (nixpkgs) lib;
|
||||||
|
forAllSystems = lib.genAttrs lib.systems.flakeExposed;
|
||||||
|
|
||||||
# Load a uv workspace from a workspace root.
|
# Load a uv workspace from a workspace root.
|
||||||
# Uv2nix treats all uv projects as workspace projects.
|
# Uv2nix treats all uv projects as workspace projects.
|
||||||
|
|
@ -55,38 +56,50 @@
|
||||||
# This is an additional overlay implementing build fixups.
|
# This is an additional overlay implementing build fixups.
|
||||||
# See:
|
# See:
|
||||||
# - https://pyproject-nix.github.io/uv2nix/FAQ.html
|
# - https://pyproject-nix.github.io/uv2nix/FAQ.html
|
||||||
|
|
||||||
|
# Construct package set
|
||||||
|
pythonSets = forAllSystems
|
||||||
|
(system:
|
||||||
|
let
|
||||||
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
pyprojectOverrides = _final: _prev: {
|
pyprojectOverrides = _final: _prev: {
|
||||||
# Implement build fixups here.
|
# Implement build fixups here.
|
||||||
};
|
};
|
||||||
|
baseSet = pkgs.callPackage pyproject-nix.build.packages {
|
||||||
pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
|
||||||
python = pkgs.python312;
|
python = pkgs.python312;
|
||||||
|
};
|
||||||
# Construct package set
|
in
|
||||||
pythonSet =
|
|
||||||
# Use base package set from pyproject.nix builders
|
# Use base package set from pyproject.nix builders
|
||||||
(pkgs.callPackage pyproject-nix.build.packages {
|
baseSet.overrideScope
|
||||||
inherit python;
|
|
||||||
}).overrideScope
|
|
||||||
(
|
(
|
||||||
lib.composeManyExtensions [
|
lib.composeManyExtensions [
|
||||||
pyproject-build-systems.overlays.default
|
pyproject-build-systems.overlays.default
|
||||||
overlay
|
overlay
|
||||||
pyprojectOverrides
|
pyprojectOverrides
|
||||||
]
|
]
|
||||||
);
|
));
|
||||||
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
# Package a virtual environment as our main application.
|
# Package a virtual environment as our main application.
|
||||||
#
|
#
|
||||||
# Enable no optional dependencies for production build.
|
# Enable no optional dependencies for production build.
|
||||||
packages.x86_64-linux.default = pythonSet.mkVirtualEnv "name-env" workspace.deps.default;
|
packages = forAllSystems (system:
|
||||||
|
let
|
||||||
|
pythonSet = pythonSets.${system};
|
||||||
|
in
|
||||||
|
{ default = pythonSet.mkVirtualEnv "name-env" workspace.deps.default; });
|
||||||
|
|
||||||
# This example provides two different modes of development:
|
# This example provides two different modes of development:
|
||||||
# - Impurely using uv to manage virtual environments
|
# - Impurely using uv to manage virtual environments
|
||||||
# - Pure development using uv2nix to manage virtual environments
|
# - Pure development using uv2nix to manage virtual environments
|
||||||
devShells.x86_64-linux = {
|
devShells = forAllSystems
|
||||||
|
(system:
|
||||||
|
let
|
||||||
|
pythonSet = pythonSets.${system};
|
||||||
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
|
in
|
||||||
|
{
|
||||||
# This devShell uses uv2nix to construct a virtual environment purely from Nix, using the same dependency specification as the application.
|
# This devShell uses uv2nix to construct a virtual environment purely from Nix, using the same dependency specification as the application.
|
||||||
# The notable difference is that we also apply another overlay here enabling editable mode ( https://setuptools.pypa.io/en/latest/userguide/development_mode.html ).
|
# The notable difference is that we also apply another overlay here enabling editable mode ( https://setuptools.pypa.io/en/latest/userguide/development_mode.html ).
|
||||||
#
|
#
|
||||||
|
|
@ -129,6 +142,6 @@
|
||||||
export REPO_ROOT=$(git rev-parse --show-toplevel)
|
export REPO_ROOT=$(git rev-parse --show-toplevel)
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue