2 Sep 2024 |
Silvio | That'd be greatly appreciated! | 16:33:41 |
nazarewk | * I can try to find my solution if you need it, I think I figured out how to completely skip sphinx and some other packages from building | 16:33:44 |
nazarewk | In reply to @silvio:booq.org Apparrently I'm not the first one having problems with ansible -> pynacl -> sphinx, but I have no clue how to fix it right now. this seems to be it:
overrides = poetry2nix.overrides.withDefaults (final: prev: let
rm.lists = lists: old: builtins.mapAttrs (name: value: lib.subtractLists value old."${name}") lists;
modified = pkg: fns: pkg.overridePythonAttrs (oldAttrs: lib.pipe oldAttrs (builtins.map (fn: entry: entry // (fn entry)) fns));
in
builtins.mapAttrs (name: modified prev."${name}") {
pynacl = [
(rm.lists {nativeBuildInputs = with final; [sphinxHook];})
(rm.lists {outputs = ["doc"];})
];
pyjwt = [
(rm.lists {nativeBuildInputs = with final; [sphinxHook sphinx-rtd-theme];})
(rm.lists {outputs = ["doc"];})
];
});
| 16:34:59 |
nazarewk | In reply to @silvio:booq.org Apparrently I'm not the first one having problems with ansible -> pynacl -> sphinx, but I have no clue how to fix it right now. * this seems to be it:
overrides = poetry2nix.overrides.withDefaults (final: prev: let
rm.lists = lists: old: builtins.mapAttrs (name: value: lib.subtractLists value old."${name}") lists;
modified = pkg: fns: pkg.overridePythonAttrs (oldAttrs: lib.pipe oldAttrs (builtins.map (fn: entry: entry // (fn entry)) fns));
in
builtins.mapAttrs (name: modified prev."${name}") {
pynacl = [
(rm.lists {nativeBuildInputs = with final; [sphinxHook];})
(rm.lists {outputs = ["doc"];})
];
pyjwt = [
(rm.lists {nativeBuildInputs = with final; [sphinxHook sphinx-rtd-theme];})
(rm.lists {outputs = ["doc"];})
];
});
basically I'm dropping doc output and a single nativeBuildInputs entry from both pyjwt and pynacl packages
| 16:38:37 |
Silvio | Omg it worked! Thank you so much 🙏 | 16:39:38 |
3 Sep 2024 |
l0b0 | Is there some way to set python when importing poetry2nix, rather than when running mkPoetryPackages and the like? | 01:35:23 |
adisbladis | Why is that important? It shouldn't matter. | 01:36:17 |
l0b0 | {pkgs}:
let
poetry2nix = import (
builtins.fetchTarball {
name = "poetry2nix-2024.8.2346599";
url = "https://github.com/nix-community/poetry2nix/archive/7619e43c2b48c29e24b88a415256f09df96ec276.tar.gz";
sha256 = "10nf9213h7vkzrqhrgk88r5sd2rq19cvdpnn59f65ifak790sgc0";
}
) {
inherit pkgs;
};
in
poetry2nix.overrideScope (finalPoetry2nix: prevPoetry2nix: {
defaultPoetryOverrides = prevPoetry2nix.defaultPoetryOverrides.extend (final: prev: {
gdal = prev.gdal.overridePythonAttrs (oldAttrs: {
nativeBuildInputs = (oldAttrs.nativeBuildInputs or []) ++ [final.numpy];
});
});
})
results in "error: value is null while a set was expected"
| 01:36:36 |
l0b0 | I thought this might be because the poetry2nix in this file doesn't know which version of Python I want to run with yet. | 01:37:06 |
adisbladis | No. That's dynamically handled in the overlay composition | 01:38:21 |
adisbladis | How can I reproduce your issue? | 01:38:56 |
l0b0 | Gotta go, but I should be able to show you soon. | 01:39:21 |
l0b0 | In reply to @adis:blad.is How can I reproduce your issue? direnv allow in https://github.com/linz/emergency-management-tools/pull/375 should do it. | 03:18:35 |
l0b0 | Yep, it's definitely something to do with the wrong Python version - I see mention of Python 3.12 in pre-commit output, and both mypy and pylint complain about missing libraries which are installed in the poetry2nix package set. | 03:33:17 |
l0b0 | * Yep, it's definitely something to do with the wrong Python version - I see mention of Python 3.12 in pre-commit output, and both mypy and pylint complain about missing libraries which are installed in the poetry2nix package set. Also:
❯ type -a python
python is /nix/store/d6cy7nfpwjppghqg3mav9537ypl6ww82-python3-3.11.9-env/bin/python
python is /nix/store/pgb120fb7srbh418v4i2a70aq1w9dawd-python3-3.12.5/bin/python
| 03:34:05 |
| @gracicot-59e8f173d73408ce4f7ac803:gitter.im left the room. | 16:13:56 |
| rpop0 joined the room. | 22:30:35 |
rpop0 | Hey so I just got into nix flakes and I'm trying to make the following flake:
{
description = "A very basic flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
poetry2nix.url = "github:nix-community/poetry2nix";
};
outputs = { nixpkgs, ... } @ inputs:
let
pkgs = nixpkgs.legacyPackages.aarch64-darwin;
poetry2nix = inputs.poetry2nix.lib.mkPoetry2Nix { inherit pkgs; };
pythonEnv = poetry2nix.mkPoetryEnv {
python = pkgs.python311;
projectDir = ./.;
};
in
{
devShells.aarch64-darwin.default = pkgs.mkShell {
packages = [ pkgs.python311 pkgs.poetry pythonEnv ];
};
};
}
But I am getting this error:
error:
… while calling the 'derivationStrict' builtin
at <nix/derivation-internal.nix>:9:12:
8|
9| strict = derivationStrict drvAttrs;
| ^
10|
… while evaluating derivation 'nix-shell'
whose name attribute is located at /nix/store/bd4fmzws6n5542khxbifbkr6nrygi232-source/pkgs/stdenv/generic/make-derivation.nix:336:7
… while evaluating attribute 'nativeBuildInputs' of derivation 'nix-shell'
at /nix/store/bd4fmzws6n5542khxbifbkr6nrygi232-source/pkgs/stdenv/generic/make-derivation.nix:380:7:
379| depsBuildBuild = elemAt (elemAt dependencies 0) 0;
380| nativeBuildInputs = elemAt (elemAt dependencies 0) 1;
| ^
381| depsBuildTarget = elemAt (elemAt dependencies 0) 2;
(stack trace truncated; use '--show-trace' to show the full, detailed trace)
error: opening file '/nix/store/afbjx0hhv5q3lkv0rmcmagd3wkq1vhrr-source/poetry.lock': No such file or directory
| 22:32:13 |
rpop0 | I tried using different versions of poetry2nix, including latest commit, some random tags from 2024 and 2023 but I still get this issue. | 22:32:51 |
adisbladis | In reply to @rpop0:matrix.org
Hey so I just got into nix flakes and I'm trying to make the following flake:
{
description = "A very basic flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
poetry2nix.url = "github:nix-community/poetry2nix";
};
outputs = { nixpkgs, ... } @ inputs:
let
pkgs = nixpkgs.legacyPackages.aarch64-darwin;
poetry2nix = inputs.poetry2nix.lib.mkPoetry2Nix { inherit pkgs; };
pythonEnv = poetry2nix.mkPoetryEnv {
python = pkgs.python311;
projectDir = ./.;
};
in
{
devShells.aarch64-darwin.default = pkgs.mkShell {
packages = [ pkgs.python311 pkgs.poetry pythonEnv ];
};
};
}
But I am getting this error:
error:
… while calling the 'derivationStrict' builtin
at <nix/derivation-internal.nix>:9:12:
8|
9| strict = derivationStrict drvAttrs;
| ^
10|
… while evaluating derivation 'nix-shell'
whose name attribute is located at /nix/store/bd4fmzws6n5542khxbifbkr6nrygi232-source/pkgs/stdenv/generic/make-derivation.nix:336:7
… while evaluating attribute 'nativeBuildInputs' of derivation 'nix-shell'
at /nix/store/bd4fmzws6n5542khxbifbkr6nrygi232-source/pkgs/stdenv/generic/make-derivation.nix:380:7:
379| depsBuildBuild = elemAt (elemAt dependencies 0) 0;
380| nativeBuildInputs = elemAt (elemAt dependencies 0) 1;
| ^
381| depsBuildTarget = elemAt (elemAt dependencies 0) 2;
(stack trace truncated; use '--show-trace' to show the full, detailed trace)
error: opening file '/nix/store/afbjx0hhv5q3lkv0rmcmagd3wkq1vhrr-source/poetry.lock': No such file or directory
It's probably a flake thing: Add poetry.lock to git. | 22:37:38 |
rpop0 | In reply to @adis:blad.is It's probably a flake thing: Add poetry.lock to git. So poetry.lock is already added to git, only unstaged files are flake.nix and flake.lock. Do these two files also need to be in git? | 22:41:30 |
adisbladis | Yes. If a flake is in a git repo nothing that isn't staged is considered | 22:42:02 |
rpop0 | Yeah I just noticed that if the flake is added in the .gitignore, it also doesn't work. Well that throws a wrench in my plans | 22:43:47 |
rpop0 | I was planning to use this strictly for my dev environment setup | 22:44:07 |
adisbladis | You could also not use flakes? | 22:45:27 |
rpop0 | What would be the alternative? nix-shell? | 22:46:11 |
adisbladis | In reply to @rpop0:matrix.org What would be the alternative? nix-shell? Yes, nix-shell | 22:47:03 |
adisbladis | https://github.com/edolstra/flake-compat might be an option if you still want to express yourself as a flake, but eval using nix-shell. It still does the whole fetchGit thing iirc, so you'll have to provide it with a source that doesn't look like a git repo | 22:47:57 |
rpop0 | So just to understand, for example in a project when using a flake that would be for setting up a more general environment to be used by everyone. On the other hand, if I need something set up just for myself (Or I'm the only one interested in using nix), a nix-shell would be the better solution? | 22:52:07 |
adisbladis | In reply to @rpop0:matrix.org So just to understand, for example in a project when using a flake that would be for setting up a more general environment to be used by everyone. On the other hand, if I need something set up just for myself (Or I'm the only one interested in using nix), a nix-shell would be the better solution? Flakes and nix-shell are morally equivalent (see https://jade.fyi/blog/flakes-arent-real/ ) | 22:59:51 |