Skip to content

Commit

Permalink
finally nix building works
Browse files Browse the repository at this point in the history
  • Loading branch information
renxida committed Sep 11, 2024
1 parent e47ae9b commit b3f2498
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 29 deletions.
8 changes: 4 additions & 4 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 29 additions & 25 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{
description = "Application packaged using poetry2nix";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable-small";
poetry2nix = {
url = "github:nix-community/poetry2nix";
inputs.nixpkgs.follows = "nixpkgs";
Expand All @@ -13,32 +12,37 @@
outputs = { self, nixpkgs, flake-utils, poetry2nix }:
flake-utils.lib.eachDefaultSystem (system:
let
# see https://github.com/nix-community/poetry2nix/tree/master#api for more functions and examples.
pkgs = nixpkgs.legacyPackages.${system};
inherit (poetry2nix.lib.mkPoetry2Nix { inherit pkgs; }) mkPoetryApplication;
in
{
packages = {
chatsh = mkPoetryApplication { projectDir = self; };
default = self.packages.${system}.chatsh;
};
inherit (poetry2nix.lib.mkPoetry2Nix { inherit pkgs; }) mkPoetryApplication defaultPoetryOverrides;

# Shell for app dependencies.
#
# nix develop
#
# Use this shell for developing your app.
devShells.default = pkgs.mkShell {
inputsFrom = [ self.packages.${system}.chatsh ];
customOverrides = defaultPoetryOverrides.extend (self: super: {
# Add overrides only if the package exists in super
maturin = if super ? maturin then super.maturin.overridePythonAttrs (old: {
buildInputs = (old.buildInputs or []) ++ [ pkgs.rustc pkgs.cargo ];
}) else null;

tiktoken = if super ? tiktoken then super.tiktoken.overridePythonAttrs (old: {
buildInputs = (old.buildInputs or []) ++ [ self.setuptools-rust pkgs.rustc pkgs.cargo ];
}) else null;

pydantic-core = if super ? pydantic-core then super.pydantic-core.overridePythonAttrs (old: {
buildInputs = (old.buildInputs or []) ++ [ pkgs.rustc pkgs.cargo ];
}) else null;
});

chatsh = mkPoetryApplication {
projectDir = ./.;
overrides = [ customOverrides ];
preferWheels = true;
};

# Shell for poetry.
#
# nix develop .#poetry
#
# Use this shell for changes to pyproject.toml and poetry.lock.
devShells.poetry = pkgs.mkShell {
in {
packages.default = chatsh;

devShells.default = pkgs.mkShell {
inputsFrom = [ chatsh ];
packages = [ pkgs.poetry ];
};
});
}
}
);
}

0 comments on commit b3f2498

Please sign in to comment.