Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(flake): Add setuptools in order to build on a minimal Nix system #741

Merged
merged 1 commit into from
Jan 17, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 50 additions & 38 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,45 +11,57 @@
};
};

outputs = { self, nixpkgs, flake-utils, poetry2nix }:
flake-utils.lib.eachDefaultSystem (system:
outputs =
{
self,
nixpkgs,
flake-utils,
poetry2nix,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs { inherit system; };
p2n = (poetry2nix.lib.mkPoetry2Nix { inherit pkgs; });
in {
devShells.default = (p2n.mkPoetryEnv {
projectDir = self + "/backend";
# pyinstaller fails to compile so precompiled it is
overrides = p2n.overrides.withDefaults (final: prev: {
pyinstaller = prev.pyinstaller.override { preferWheel = true; };
pyright = null;
});
}).env.overrideAttrs (oldAttrs: {
shellHook = ''
PYTHONPATH=`which python`
FILE=.vscode/settings.json
if [ -f "$FILE" ]; then
jq --arg pythonpath "$PYTHONPATH" '.["python.defaultInterpreterPath"] = $pythonpath' $FILE > "$FILE.tmp" && mv "$FILE.tmp" "$FILE"
else
echo "{\"python.defaultInterpreterPath\": \"$PYTHONPATH\"}" > "$FILE"
fi
'';
UV_USE_IO_URING = 0; # work around node#48444
buildInputs = with pkgs; [
nodejs_22
nodePackages.pnpm
poetry
jq
# fixes local pyright not being able to see the pythonpath properly.
(pkgs.writeShellScriptBin "pyright" ''
${pkgs.pyright}/bin/pyright --pythonpath `which python3` "$@" '')
(pkgs.writeShellScriptBin "pyright-langserver" ''
${pkgs.pyright}/bin/pyright-langserver --pythonpath `which python3` "$@" '')
(pkgs.writeShellScriptBin "pyright-python" ''
${pkgs.pyright}/bin/pyright-python --pythonpath `which python3` "$@" '')
(pkgs.writeShellScriptBin "pyright-python-langserver" ''
${pkgs.pyright}/bin/pyright-python-langserver --pythonpath `which python3` "$@" '')
];
});
});
in
{
devShells.default =
(p2n.mkPoetryEnv {
projectDir = self + "/backend";
# pyinstaller fails to compile so precompiled it is
overrides = p2n.overrides.withDefaults (
final: prev: {
pyinstaller = prev.pyinstaller.override { preferWheel = true; };
pyright = null;
}
);
}).env.overrideAttrs
(oldAttrs: {
shellHook = ''
PYTHONPATH=`which python`
FILE=.vscode/settings.json
if [ -f "$FILE" ]; then
jq --arg pythonpath "$PYTHONPATH" '.["python.defaultInterpreterPath"] = $pythonpath' $FILE > "$FILE.tmp" && mv "$FILE.tmp" "$FILE"
else
echo "{\"python.defaultInterpreterPath\": \"$PYTHONPATH\"}" > "$FILE"
fi
'';
UV_USE_IO_URING = 0; # work around node#48444
nativeBuildInputs = with pkgs; [
python311Packages.setuptools
];
buildInputs = with pkgs; [
nodejs_22
nodePackages.pnpm
poetry
jq
# fixes local pyright not being able to see the pythonpath properly.
(pkgs.writeShellScriptBin "pyright" ''${pkgs.pyright}/bin/pyright --pythonpath `which python3` "$@" '')
(pkgs.writeShellScriptBin "pyright-langserver" ''${pkgs.pyright}/bin/pyright-langserver --pythonpath `which python3` "$@" '')
(pkgs.writeShellScriptBin "pyright-python" ''${pkgs.pyright}/bin/pyright-python --pythonpath `which python3` "$@" '')
(pkgs.writeShellScriptBin "pyright-python-langserver" ''${pkgs.pyright}/bin/pyright-python-langserver --pythonpath `which python3` "$@" '')
];
});
}
);
}