ReproduciblePython/flake.nix

61 lines
1.5 KiB
Nix
Raw Normal View History

2024-03-17 16:05:06 -07:00
{
description = "Reproducible";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
poetry2nix = {
url = "github:nix-community/poetry2nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = inputs @ {
self,
nixpkgs,
flake-parts,
poetry2nix,
...
} : flake-parts.lib.mkFlake { inherit inputs; } {
flake = {
};
systems = [
"x86_64-linux"
"x86_64-darwin"
];
2024-08-27 22:31:47 -07:00
perSystem = { system, ... }: let
pkgs = import nixpkgs {
inherit system;
config = {
allowUnfree = true;
cudaSupport = true;
};
};
poetryLib = poetry2nix.lib.mkPoetry2Nix { inherit pkgs; };
common = {
2024-03-17 16:05:06 -07:00
python = pkgs.python311;
2024-08-27 22:31:47 -07:00
projectDir = ./.;
2024-03-17 16:05:06 -07:00
preferWheels = true;
2024-08-27 22:31:47 -07:00
overrides = poetryLib.defaultPoetryOverrides;
2024-03-17 16:05:06 -07:00
};
2024-08-27 22:31:47 -07:00
application = poetryLib.mkPoetryApplication common;
env = poetryLib.mkPoetryEnv (common // {
2024-03-17 16:05:06 -07:00
editablePackageSources = let project_dir = builtins.getEnv "PROJECT_DIR"; in
{
reproducible = if project_dir == "" then ./. else "${project_dir}";
};
});
in rec {
packages = {
default = application;
};
devShells.default = pkgs.mkShell {
2024-08-27 22:31:47 -07:00
packages = [ env ];
2024-03-17 16:05:06 -07:00
};
2024-08-27 22:31:47 -07:00
#devShells.default = env.overrideAttrs (oldAttrs: {
# buildInputs = [ args.python ];
#});
2024-03-17 16:05:06 -07:00
};
};
}