Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 7 additions & 1 deletion dev-flake/flake-compat.nix
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,13 @@

rootOverrides =
mapAttrs'
(input: lockKey: nameValuePair lockKey (impureOverrides.${input} or null))
(input: lockKey': let
lockKey =
if builtins.isList lockKey'
then builtins.concatStringsSep "/" lockKey'
else lockKey';
in
nameValuePair lockKey (impureOverrides.${input} or null))
lockFile.nodes.${lockFile.root}.inputs;

allNodes =
Expand Down
70 changes: 45 additions & 25 deletions dev-flake/flake.lock

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

4 changes: 2 additions & 2 deletions dev-flake/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
};

inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable";
nixpkgs.url = "nixpkgs/nixpkgs-unstable";

flake-parts.url = "github:hercules-ci/flake-parts";
flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs";
Expand All @@ -19,7 +19,7 @@
pre-commit-hooks.inputs.nixpkgs.follows = "nixpkgs";

nix-unit.url = "github:nix-community/nix-unit";
# nix-unit.inputs.nixpkgs.follows = "nixpkgs";
nix-unit.inputs.nixpkgs.follows = "nixpkgs";
nix-unit.inputs.flake-parts.follows = "flake-parts";

devshell = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ in {
dream2nix.modules.dream2nix.nixpkgs-overrides
];
nixpkgs-overrides = {
exclude = ["propagatedBuildInputs"];
exclude = ["propagatedBuildInputs" "dependencies"];
};
};
lazy-object-proxy = {
Expand Down
6 changes: 3 additions & 3 deletions flake.lock

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

2 changes: 1 addition & 1 deletion modules/dream2nix/core/eval-cache/interface.nix
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ in {

refresh = l.mkOption {
type = t.path;
description = "Script to refresh the cache file of this package";
description = "Script to refresh the eval cache file";
readOnly = true;
};
};
Expand Down
6 changes: 3 additions & 3 deletions modules/dream2nix/core/lock/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
refresh_scripts = json.loads('${l.toJSON cfg.fields}') # noqa: E501
repo_path = Path(subprocess.run(
['${config.paths.findRoot}'], # noqa: E501
check=True, text=True, capture_output=True)
check=True, text=True, stdout=subprocess.PIPE)
.stdout.strip())
lock_path_rel = Path('${config.paths.package}/${config.paths.lockFile}') # noqa: E501
lock_path = repo_path / lock_path_rel.relative_to(lock_path_rel.anchor)
Expand Down Expand Up @@ -200,7 +200,7 @@ in {

config = {
lock.refresh = config.deps.writeScriptBin "refresh" ''
#!/usr/bin/env bash
#!${config.deps.bash}/bin/bash
set -Eeuo pipefail

### Executing auto generated refresh script
Expand All @@ -221,7 +221,7 @@ in {

deps = {nixpkgs, ...}:
l.mapAttrs (_: l.mkDefault) {
inherit (nixpkgs) nix writeScriptBin;
inherit (nixpkgs) bash nix writeScriptBin;
inherit (nixpkgs.writers) writePython3 writePython3Bin;
};
};
Expand Down
2 changes: 1 addition & 1 deletion modules/dream2nix/core/lock/interface.nix
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ in {

refresh = l.mkOption {
type = t.package;
description = "Script to refresh the cache file of this package";
description = "Script to refresh the lock file";
readOnly = true;
};

Expand Down
2 changes: 1 addition & 1 deletion modules/dream2nix/pip/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ in {
inherit (cfg) env pypiSnapshotDate pipFlags pipVersion requirementsList requirementsFiles nativeBuildInputs;
inherit (config.deps) writePureShellScript nix;
inherit (config.paths) findRoot;
inherit (nixpkgs) gitMinimal nix-prefetch-scripts python3 writeText openssh;
inherit (nixpkgs) fetchFromGitHub fetchurl gitMinimal nix-prefetch-scripts openssh python3 rustPlatform writeText;
pythonInterpreter = "${python}/bin/python";
};
setuptools = config.deps.python.pkgs.setuptools;
Expand Down
56 changes: 56 additions & 0 deletions modules/dream2nix/pip/tests/packages/lock-script-works/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# An example package with dependencies defined via pyproject.toml
{
config,
lib,
dream2nix,
packageSets,
...
}: let
pyproject = lib.importTOML (config.mkDerivation.src + /pyproject.toml);
pkgs = packageSets.nixpkgs;
in {
imports = [
dream2nix.modules.dream2nix.pip
];

deps = {nixpkgs, ...}: {
python = nixpkgs.python310;
};

inherit (pyproject.project) name version;

mkDerivation = {
src = ./.;
};

pip = {
pypiSnapshotDate = "2023-08-27";
requirementsList =
pyproject.build-system.requires
or []
++ pyproject.project.dependencies;
flattenDependencies = true;
};

paths.projectRootFile = "pyproject.toml";

public = lib.mkForce (pkgs.runCommand "pip-lock-script-works" {
outputHashMode = "flat";
outputHashAlgo = "sha256";
outputHash = "sha256-47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=";
# invalidate by including into the name a hash over:
# - the path to the nixpkgs
# - TODO: the implementation of the fetch script
name = let
hash = builtins.hashString "sha256" (builtins.unsafeDiscardStringContext ''
${pkgs.path}
'');
in "pip-lock-script-works-${lib.substring 0 16 hash}";
} ''
cp -r ${config.mkDerivation.src}/* .
chmod +w -R .
ls -lah
${config.lock.refresh}/bin/refresh
touch $out
'');
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from setuptools import setup


def main():
print("Hello World!")


if __name__ == "__main__":
main()
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[build-system]
requires = [ "setuptools" ]
build-backend = "setuptools.build_meta"

[project]
name = "my-tool"
description = "my tool"
version = "1.0.0"
dependencies = [
"setuptools"
]

[project.scripts]
my-tool = "my_tool:main"
59 changes: 58 additions & 1 deletion pkgs/fetchPipMetadata/script.nix
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
writePureShellScript,
nix-prefetch-scripts,
openssh,
fetchFromGitHub,
fetchurl,
rustPlatform,
}: let
package = import ./package.nix {
inherit
Expand All @@ -53,9 +56,63 @@
;
};

pythonFixed = python3.override {
packageOverrides = curr: prev: {
/*
downgrading to version 10.1.*, as 10.2.0 introduces a breakage triggering:
[17:42:11.824][[::1]:56958] client connect
[17:42:11.909][[::1]:56958] server connect pypi.org:443 (151.101.64.223:443)
[17:42:11.958] Deferring layer decision, not enough data: [...]
*/
mitmproxy = prev.mitmproxy.overridePythonAttrs (old: rec {
version = "10.1.6";
src = fetchFromGitHub {
owner = "mitmproxy";
repo = "mitmproxy";
rev = "refs/tags/${version}";
hash = "sha256-W+gxK5bNCit1jK9ojwE/HVjUz6OJcNw6Ac1lN5FxGgw=";
};
doCheck = false;
pyproject = true;
# format = "pyproject";
});
mitmproxy-rs = prev.mitmproxy-rs.overrideAttrs (old: rec {
version = "0.4.1";
src = fetchFromGitHub {
owner = "mitmproxy";
repo = "mitmproxy_rs";
rev = version;
hash = "sha256-Vc7ez/W40CefO2ZLAHot14p478pDPtQor865675vCtI=";
};
cargoDeps = rustPlatform.importCargoLock {
lockFile = "${src}/Cargo.lock";
outputHashes = {
"internet-packet-0.1.0" = "sha256-VtEuCE1sulBIFVymh7YW7VHCuIBjtb6tHoPz2tjxX+Q=";
};
};
});

mitmproxy-macos = prev.buildPythonPackage rec {
pname = "mitmproxy-macos";
version = "0.4.1";
format = "wheel";

src = fetchurl {
url = "https://files.pythonhosted.org/packages/85/79/f11ba4cf6e89408ed52d9317c00d3ae4ad18c51cf710821c9342fc95cd0f/mitmproxy_macos-0.5.1-py3-none-any.whl";
hash = "sha256-P7T8mTCzMQEphnWuumZF3ucb4XYgyMsHyBC6i+1sKkI=";
};

pythonImportsCheck = ["mitmproxy_macos"];
nativeBuildInputs = [
prev.hatchling
];
};
};
};

# We use nixpkgs python3 to run mitmproxy, see function parameters
pythonWithMitmproxy =
python3.withPackages
pythonFixed.withPackages
(ps: [ps.mitmproxy ps.python-dateutil]);

path = [nix gitMinimal openssh] ++ nativeBuildInputs;
Expand Down
2 changes: 1 addition & 1 deletion tests/nix-unit/test_python-pdm-lib/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
}: let
libpdm = (import ../../../modules/dream2nix/WIP-python-pdm/lib.nix) {
inherit lib libpyproject;
python3 = pkgs.python3;
python3 = pkgs.python310;
targetPlatform = lib.systems.elaborate "x86_64-linux";
};
pyproject-nix = inputs.pyproject-nix;
Expand Down