2024-07-15 19:17:57 -04:00
|
|
|
{
|
|
|
|
description = "Application packaged using poetry2nix";
|
|
|
|
|
2024-07-28 15:30:18 -04:00
|
|
|
nixConfig = {
|
|
|
|
substituters = [
|
|
|
|
"https://cache.nixos.org/?priority=1&want-mass-query=true"
|
2025-04-06 22:55:35 -04:00
|
|
|
#"https://attic.nayeonie.com/nix-cache"
|
2024-07-28 15:30:18 -04:00
|
|
|
"https://nix-community.cachix.org/?priority=10&want-mass-query=true"
|
|
|
|
];
|
|
|
|
trusted-substituters = [
|
|
|
|
"https://cache.nixos.org"
|
2025-03-01 23:29:01 -05:00
|
|
|
"https://attic.nayeonie.com/nix-cache"
|
2024-07-28 15:30:18 -04:00
|
|
|
"https://nix-community.cachix.org"
|
|
|
|
];
|
|
|
|
trusted-public-keys = [
|
|
|
|
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
|
2025-03-01 23:29:01 -05:00
|
|
|
"nix-cache:trR+y5nwpQHR4hystoogubFmp97cewkjWeqqbygRQRs="
|
2024-07-28 15:30:18 -04:00
|
|
|
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
|
|
|
|
];
|
2025-04-03 08:20:20 -04:00
|
|
|
fallback = true;
|
2024-07-28 15:30:18 -04:00
|
|
|
};
|
|
|
|
|
2024-07-15 19:17:57 -04:00
|
|
|
inputs = {
|
|
|
|
flake-utils.url = "github:numtide/flake-utils";
|
2025-03-18 15:31:05 -04:00
|
|
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable-small";
|
2024-07-15 19:17:57 -04:00
|
|
|
pre-commit-hooks = {
|
|
|
|
url = "github:cachix/pre-commit-hooks.nix";
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.follows = "nixpkgs";
|
|
|
|
# nixpkgs-stable.follows = "nixpkgs-stable";
|
|
|
|
# flake-compat.follows = "flake-compat";
|
|
|
|
};
|
|
|
|
};
|
2025-03-18 18:11:42 -04:00
|
|
|
pyproject-nix = {
|
|
|
|
url = "github:pyproject-nix/pyproject.nix";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
|
|
|
|
uv2nix = {
|
|
|
|
url = "github:pyproject-nix/uv2nix";
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.follows = "nixpkgs";
|
|
|
|
pyproject-nix.follows = "pyproject-nix";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
pyproject-build-systems = {
|
|
|
|
url = "github:pyproject-nix/build-system-pkgs";
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.follows = "nixpkgs";
|
|
|
|
pyproject-nix.follows = "pyproject-nix";
|
|
|
|
uv2nix.follows = "uv2nix";
|
|
|
|
};
|
|
|
|
};
|
2024-07-15 19:17:57 -04:00
|
|
|
};
|
|
|
|
|
2024-07-15 19:42:22 -04:00
|
|
|
outputs =
|
|
|
|
{
|
|
|
|
self,
|
|
|
|
nixpkgs,
|
|
|
|
flake-utils,
|
2025-03-18 18:11:42 -04:00
|
|
|
uv2nix,
|
|
|
|
pyproject-nix,
|
|
|
|
pyproject-build-systems,
|
2024-07-15 19:42:22 -04:00
|
|
|
...
|
|
|
|
}@inputs:
|
|
|
|
flake-utils.lib.eachDefaultSystem (
|
|
|
|
system:
|
2024-07-15 19:17:57 -04:00
|
|
|
let
|
2025-03-18 18:11:42 -04:00
|
|
|
inherit (nixpkgs) lib;
|
|
|
|
|
|
|
|
# Load a uv workspace from a workspace root.
|
|
|
|
# Uv2nix treats all uv projects as workspace projects.
|
|
|
|
workspace = uv2nix.lib.workspace.loadWorkspace { workspaceRoot = ./.; };
|
2024-07-28 14:15:06 -04:00
|
|
|
|
2025-03-18 18:11:42 -04:00
|
|
|
# Create package overlay from workspace.
|
|
|
|
overlay = workspace.mkPyprojectOverlay {
|
|
|
|
# Prefer prebuilt binary wheels as a package source.
|
|
|
|
# Sdists are less likely to "just work" because of the metadata missing from uv.lock.
|
|
|
|
# Binary wheels are more likely to, but may still require overrides for library dependencies.
|
|
|
|
sourcePreference = "wheel";
|
|
|
|
#sourcePreference = "sdist";
|
|
|
|
# Optionally customise PEP 508 environment
|
|
|
|
# environ = {
|
|
|
|
# platform_release = "5.10.65";
|
|
|
|
# };
|
|
|
|
};
|
2024-07-28 14:15:06 -04:00
|
|
|
|
2025-03-18 18:11:42 -04:00
|
|
|
# Extend generated overlay with build fixups
|
|
|
|
#
|
|
|
|
# Uv2nix can only work with what it has, and uv.lock is missing essential metadata to perform some builds.
|
|
|
|
# This is an additional overlay implementing build fixups.
|
|
|
|
# See:
|
|
|
|
# - https://pyproject-nix.github.io/uv2nix/FAQ.html
|
|
|
|
pyprojectOverrides = _final: _prev: {
|
|
|
|
# Implement build fixups here.
|
|
|
|
# Note that uv2nix is _not_ using Nixpkgs buildPythonPackage.
|
|
|
|
# It's using https://pyproject-nix.github.io/pyproject.nix/build.html
|
|
|
|
};
|
|
|
|
|
|
|
|
# This example is only using x86_64-linux
|
|
|
|
pkgs = nixpkgs.legacyPackages.${system};
|
|
|
|
|
|
|
|
# Use Python 3.12 from nixpkgs
|
|
|
|
python = pkgs.python312;
|
|
|
|
|
|
|
|
# Construct package set
|
|
|
|
pythonSet =
|
|
|
|
# Use base package set from pyproject.nix builders
|
|
|
|
(pkgs.callPackage pyproject-nix.build.packages {
|
|
|
|
inherit python;
|
|
|
|
}).overrideScope
|
|
|
|
(
|
|
|
|
lib.composeManyExtensions [
|
|
|
|
pyproject-build-systems.overlays.default
|
|
|
|
overlay
|
|
|
|
pyprojectOverrides
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
|
|
|
uv-shell = import ./uv-shell.nix {
|
|
|
|
inherit
|
|
|
|
lib
|
|
|
|
pkgs
|
|
|
|
python
|
|
|
|
workspace
|
|
|
|
pythonSet
|
|
|
|
;
|
2024-07-28 14:15:06 -04:00
|
|
|
};
|
2024-07-15 19:17:57 -04:00
|
|
|
in
|
|
|
|
rec {
|
2025-03-18 18:11:42 -04:00
|
|
|
# Package a virtual environment as our main application.
|
|
|
|
#
|
|
|
|
# Enable no optional dependencies for production build.
|
|
|
|
packages = rec {
|
|
|
|
flupdt = pythonSet.mkVirtualEnv "flupdt-env" workspace.deps.default;
|
|
|
|
default = flupdt;
|
|
|
|
};
|
|
|
|
|
|
|
|
# Make hello runnable with `nix run`
|
|
|
|
apps = {
|
|
|
|
default = {
|
|
|
|
type = "app";
|
|
|
|
program = "${packages.default}/bin/flupdt";
|
2024-07-28 14:15:06 -04:00
|
|
|
};
|
2024-07-15 19:17:57 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
formatter = pkgs.nixfmt-rfc-style;
|
|
|
|
|
2024-07-15 19:42:22 -04:00
|
|
|
devShells = import ./shell.nix {
|
|
|
|
inherit
|
|
|
|
self
|
2024-08-03 00:21:44 -04:00
|
|
|
pkgs
|
2024-07-15 19:42:22 -04:00
|
|
|
inputs
|
|
|
|
system
|
|
|
|
checks
|
2025-03-18 18:11:42 -04:00
|
|
|
uv-shell
|
2024-07-15 19:42:22 -04:00
|
|
|
;
|
|
|
|
};
|
|
|
|
checks = import ./checks.nix { inherit inputs system formatter; };
|
|
|
|
}
|
|
|
|
)
|
|
|
|
// {
|
|
|
|
hydraJobs = import ./hydra/jobs.nix { inherit (self) inputs outputs; };
|
|
|
|
};
|
2024-07-15 19:17:57 -04:00
|
|
|
}
|