| 6 Nov 2023 |
adisbladis | cc K900 ⚡️ | 01:05:19 |
adisbladis | * cc K900 ⚡️ cpcloud etc | 01:21:10 |
adisbladis | Not exactly sure which project would implement what | 01:21:14 |
adisbladis | * Thinking a bit out loud here about a possible interface for lock files (cross post from #pyproject.nix:blad.is ):
{ lib, pkgs, poetry2nix, pyproject }:
let
# Stub attrs, not yet implemented
pdm = { };
overlays = { };
# Use project abstraction from pyproject.nix
project = pyproject.project.loadPyproject {
pyproject = lib.importTOML ./pyproject.toml;
};
# Python packages overlay
overlay = let
# Create an overlay from pdm.lock
pdmPackages = pdm.mkOverlay {
pyproject = lib.importTOML ./pyproject.toml;
pdmLock = lib.importTOML ./pdm.lock;
};
# Pdm.lock does not have PEP-517 build systems locked, use overrides from poetry2nix
pdmWithBuild = overlays.intersect pdmPackages poetry2nix.overlays.build-systems;
# Only apply build system overrides to packages that actually need them (packages created by the overlay generator)
in overlays.intersect pdmPackages poetry2nix.build-systems;
# Create an overriden interpreter
python = pkgs.python3.override {
# Note the self argument.
# It's important so the interpreter/set is internally consistent.
self = python;
packageOverrides = overlay;
};
# Render buildPythonPackage with our overriden interpreter
attrs = pyproject.lib.renderers.buildPythonPackage { inherit python project; };
in python.pkgs.buildPythonPackage attrs
| 03:52:30 |
adisbladis | The same idea, but a bit more formed:
{ lib, pkgs, poetry2nix, pyproject }:
let
# Stub attrs, not yet implemented
pdm = {
mkOverlay = { ... }: throw "Not implemented";
};
overlays = {
# Return overlay `a` with `b` applied, but only with intersecting keys.
# This is useful when filtering
intersect = a: b: throw "Not implemented";
# Return overlay filtered by predicate
filter = pred: overlay: throw "Not implemented";
};
# Use project abstraction from pyproject.nix
project = pyproject.project.loadPyproject {
pyproject = lib.importTOML ./pyproject.toml;
};
# Python packages overlay
overlay = let
# Create an overlay from pdm.lock
pdmPackages = pdm.mkOverlay {
pyproject = lib.importTOML ./pyproject.toml;
pdmLock = lib.importTOML ./pdm.lock;
};
# Use nixpkgs definitions whenever possible, only overlay missing packages
onlyPdm = overlays.filter (pname: overriden: ! lib.hasAttr pname pkgs.python3.pkgs) pdmPackages;
# Pdm.lock does not have PEP-517 build systems locked, use overrides from poetry2nix
pdmWithBuild = overlays.intersect onlyPdm poetry2nix.overlays.build-systems;
in pdmWithBuild;
# Create an overriden interpreter
python = pkgs.python3.override {
# Note the self argument.
# It's important so the interpreter/set is internally consistent.
self = python;
packageOverrides = overlay;
};
# Render buildPythonPackage with our overriden interpreter
attrs = pyproject.lib.renderers.buildPythonPackage { inherit python project; };
in python.pkgs.buildPythonPackage attrs
| 04:03:58 |
adisbladis | * The same idea, but a bit more formed:
{ lib, pkgs, poetry2nix, pyproject }:
let
# Stub attrs, not yet implemented
pdm = {
mkOverlay = { ... }: throw "Not implemented";
};
overlays = {
# Return overlay `a` with `b` applied, but only with intersecting keys.
intersect = a: b: throw "Not implemented";
# Return overlay filtered by predicate
filter = pred: overlay: throw "Not implemented";
};
# Use project abstraction from pyproject.nix
project = pyproject.project.loadPyproject {
pyproject = lib.importTOML ./pyproject.toml;
};
# Python packages overlay
overlay = let
# Create an overlay from pdm.lock
pdmPackages = pdm.mkOverlay {
pyproject = lib.importTOML ./pyproject.toml;
pdmLock = lib.importTOML ./pdm.lock;
};
# Use nixpkgs definitions whenever possible, only overlay missing packages
onlyPdm = overlays.filter (pname: overriden: ! lib.hasAttr pname pkgs.python3.pkgs) pdmPackages;
# Pdm.lock does not have PEP-517 build systems locked, use overrides from poetry2nix
pdmWithBuild = overlays.intersect onlyPdm poetry2nix.overlays.build-systems;
in pdmWithBuild;
# Create an overriden interpreter
python = pkgs.python3.override {
# Note the self argument.
# It's important so the interpreter/set is internally consistent.
self = python;
packageOverrides = overlay;
};
# Render buildPythonPackage with our overriden interpreter
attrs = pyproject.lib.renderers.buildPythonPackage { inherit python project; };
in python.pkgs.buildPythonPackage attrs
| 04:25:06 |
adisbladis | No takers? :P | 08:16:43 |
adisbladis | I really want some input on this before I go nuts and implement something like it | 08:58:52 |
K900 | Looks pretty good to me but I can't brain right now | 08:59:28 |
zeratax (any/all) | {
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
inputs.poetry2nix = {
url = "github:sciyoshi/poetry2nix/master";
inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, nixpkgs, flake-utils, poetry2nix }:
flake-utils.lib.eachDefaultSystem (system:
let
inherit (poetry2nix.legacyPackages.${system}) mkPoetryEnv;
projectPath = builtins.path { path = ./.; name = "shark3d-deployment"; };
pkgs = nixpkgs.legacyPackages.${system};
deployment = mkPoetryEnv {
python = pkgs.python311;
projectDir = projectPath;
editablePackageSources = {
deployment = projectPath;
};
};
in
{
devShells.default = deployment.env.overrideAttrs (oldAttrs: {
buildInputs = [ pkgs.kubectl pkgs.pulumi-bin ];
});
});
}
| 12:53:31 |
zeratax (any/all) | * {
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
inputs.poetry2nix = {
url = "github:sciyoshi/poetry2nix/master";
inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, nixpkgs, flake-utils, poetry2nix }:
flake-utils.lib.eachDefaultSystem (system:
let
inherit (poetry2nix.legacyPackages.${system}) mkPoetryEnv;
projectPath = builtins.path { path = ./.; name = "shark3d-deployment"; };
pkgs = nixpkgs.legacyPackages.${system};
deployment = mkPoetryEnv {
python = pkgs.python311;
projectDir = projectPath;
editablePackageSources = {
deployment = projectPath;
};
};
in
{
devShells.default = deployment.env.overrideAttrs (oldAttrs: {
buildInputs = [ pkgs.kubectl pkgs.pulumi-bin ];
});
});
}
nix develop
warning: Git tree '/home/jonaa/git/deployment' is dirty
error: list index 2 is out of bounds
at /nix/store/dqxnzhmh5xq79508f9h6rg11jqy9nnmv-source/shell-scripts.nix:10:12:
9| module = elem 0;
10| fn = elem 2;
| ^
11| in
(use '--show-trace' to show detailed location information)
not sure what this means
| 12:54:54 |
zeratax (any/all) | * {
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
inputs.poetry2nix = {
url = "github:sciyoshi/poetry2nix/master";
inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, nixpkgs, flake-utils, poetry2nix }:
flake-utils.lib.eachDefaultSystem (system:
let
inherit (poetry2nix.legacyPackages.${system}) mkPoetryEnv;
projectPath = builtins.path { path = ./.; name = "shark3d-deployment"; };
pkgs = nixpkgs.legacyPackages.${system};
deployment = mkPoetryEnv {
python = pkgs.python311;
projectDir = projectPath;
editablePackageSources = {
deployment = projectPath;
};
};
in
{
devShells.default = deployment.env.overrideAttrs (oldAttrs: {
buildInputs = [ pkgs.kubectl pkgs.pulumi-bin ];
});
});
}
nix develop
warning: Git tree '/home/jonaa/git/deployment' is dirty
error: list index 2 is out of bounds
at /nix/store/dqxnzhmh5xq79508f9h6rg11jqy9nnmv-source/shell-scripts.nix:10:12:
9| module = elem 0;
10| fn = elem 2;
| ^
11| in
(use '--show-trace' to show detailed location information)
not sure what this means
| 12:57:20 |
K900 | Please use poetry2nix upstream now | 12:58:24 |
K900 | Actually why are you even using a poetry2nix fork with 23.05 | 12:58:53 |
zeratax (any/all) | oh wow idk why i used a fork | 13:00:32 |
zeratax (any/all) | yeah sorry about that. idk where i copied that from >.> | 13:11:18 |
zeratax (any/all) | * yeah sorry about that. idk where i copied that from >.> but thank you! | 13:11:26 |
zeratax (any/all) | this works:
#pyproject.toml
[tool.poetry.scripts]
deploy_cluster_aws = "deploy_cluster_aws:main"
while this doesn't
#pyproject.toml
[tool.poetry.scripts]
deploy_cluster_aws = { reference = "deploy_cluster_aws", extras = ["aws"], type="console" }
but should be valid, no? https://python-poetry.org/docs/pyproject/#scripts
$ nix develop
warning: Git tree '/home/jonaa/git/deployment' is dirty
error: value is a set while a string was expected
at /nix/store/knlmp0ljafmp1k4fkf61jdhia6l9kw1q-source/shell-scripts.nix:8:31:
7| let
8| elem = builtins.elemAt (builtins.split ":" entrypoint);
| ^
9| module = elem 0;
(use '--show-trace' to show detailed location information)
| 16:34:15 |
K900 | Probably an issue with our pyproject.toml parsing | 16:35:21 |
K900 | CC adisbladis | 16:35:25 |
| pareto-optimal-dev joined the room. | 17:10:47 |
pareto-optimal-dev | I'm trying to package https://github.com/cpacker/MemGPT and running into an issue with "dist: no such file or directory" in pypaInstallPhase, specifically in the `nix/-support/setup-hook`. I think maybe I need to "passthrough" dist or modify some place to copy it? Can anyone help? | 17:12:59 |
K900 | Post the full expression and log, please | 17:13:34 |
pareto-optimal-dev | expression: https://github.com/ParetoOptimalDev/MemGPT/blob/poetry2nix/flake.nix
error: https://github.com/ParetoOptimalDev/MemGPT/blob/poetry2nix/error.log | 17:22:01 |
K900 | Your build does nothing | 17:22:40 |
K900 | If it's a Rust/maturin project, you need to add the maturinBuildHook | 17:22:55 |
matthewcroughan - nix.how | Hahaha, I'm struggling with the same right now | 17:23:22 |
pareto-optimal-dev | Even funnier is I was about to contact you about it ;) | 17:24:39 |
pareto-optimal-dev | In reply to @k900:0upti.me Your build does nothing Well.. it fails :) But seriously I'm not sure what you mean by does nothing since I get an error. I did find the preferWheels setting though after you said that and will try that route for now before investigating rust/maturin. | 17:28:12 |
K900 | It does nothing as in it doesn't actually build the thing | 17:29:47 |