Skip to content

Commit e77bd91

Browse files
committed
update nixpkgs:
- downgrade mitmproxy to avoid breakage - add test for pip lock script - fix bug in flake compat implementation (nix-community/flake-compat#4 (comment)) - small fix in docs for lock and eval-cache - fix lock refresh script: don't swallow errors
1 parent 3308e05 commit e77bd91

File tree

14 files changed

+202
-40
lines changed

14 files changed

+202
-40
lines changed

dev-flake/flake-compat.nix

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,13 @@
200200

201201
rootOverrides =
202202
mapAttrs'
203-
(input: lockKey: nameValuePair lockKey (impureOverrides.${input} or null))
203+
(input: lockKey': let
204+
lockKey =
205+
if builtins.isList lockKey'
206+
then builtins.concatStringsSep "/" lockKey'
207+
else lockKey';
208+
in
209+
nameValuePair lockKey (impureOverrides.${input} or null))
204210
lockFile.nodes.${lockFile.root}.inputs;
205211

206212
allNodes =

dev-flake/flake.lock

Lines changed: 45 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dev-flake/flake.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
};
88

99
inputs = {
10-
nixpkgs.url = "nixpkgs/nixos-unstable";
10+
nixpkgs.url = "nixpkgs/nixpkgs-unstable";
1111

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

2121
nix-unit.url = "github:nix-community/nix-unit";
22-
# nix-unit.inputs.nixpkgs.follows = "nixpkgs";
22+
nix-unit.inputs.nixpkgs.follows = "nixpkgs";
2323
nix-unit.inputs.flake-parts.follows = "flake-parts";
2424

2525
devshell = {

examples/packages/single-language/python-package-apache-airflow/default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ in {
6161
dream2nix.modules.dream2nix.nixpkgs-overrides
6262
];
6363
nixpkgs-overrides = {
64-
exclude = ["propagatedBuildInputs"];
64+
exclude = ["propagatedBuildInputs" "dependencies"];
6565
};
6666
};
6767
lazy-object-proxy = {

flake.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

modules/dream2nix/core/eval-cache/interface.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ in {
4949

5050
refresh = l.mkOption {
5151
type = t.path;
52-
description = "Script to refresh the cache file of this package";
52+
description = "Script to refresh the eval cache file";
5353
readOnly = true;
5454
};
5555
};

modules/dream2nix/core/lock/default.nix

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
refresh_scripts = json.loads('${l.toJSON cfg.fields}') # noqa: E501
4848
repo_path = Path(subprocess.run(
4949
['${config.paths.findRoot}'], # noqa: E501
50-
check=True, text=True, capture_output=True)
50+
check=True, text=True, stdout=subprocess.PIPE)
5151
.stdout.strip())
5252
lock_path_rel = Path('${config.paths.package}/${config.paths.lockFile}') # noqa: E501
5353
lock_path = repo_path / lock_path_rel.relative_to(lock_path_rel.anchor)
@@ -200,7 +200,7 @@ in {
200200

201201
config = {
202202
lock.refresh = config.deps.writeScriptBin "refresh" ''
203-
#!/usr/bin/env bash
203+
#!${config.deps.bash}/bin/bash
204204
set -Eeuo pipefail
205205
206206
### Executing auto generated refresh script
@@ -221,7 +221,7 @@ in {
221221

222222
deps = {nixpkgs, ...}:
223223
l.mapAttrs (_: l.mkDefault) {
224-
inherit (nixpkgs) nix writeScriptBin;
224+
inherit (nixpkgs) bash nix writeScriptBin;
225225
inherit (nixpkgs.writers) writePython3 writePython3Bin;
226226
};
227227
};

modules/dream2nix/core/lock/interface.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ in {
7979

8080
refresh = l.mkOption {
8181
type = t.package;
82-
description = "Script to refresh the cache file of this package";
82+
description = "Script to refresh the lock file";
8383
readOnly = true;
8484
};
8585

modules/dream2nix/pip/default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ in {
135135
inherit (cfg) env pypiSnapshotDate pipFlags pipVersion requirementsList requirementsFiles nativeBuildInputs;
136136
inherit (config.deps) writePureShellScript nix;
137137
inherit (config.paths) findRoot;
138-
inherit (nixpkgs) gitMinimal nix-prefetch-scripts python3 writeText openssh;
138+
inherit (nixpkgs) fetchFromGitHub fetchurl gitMinimal nix-prefetch-scripts openssh python3 rustPlatform writeText;
139139
pythonInterpreter = "${python}/bin/python";
140140
};
141141
setuptools = config.deps.python.pkgs.setuptools;
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# An example package with dependencies defined via pyproject.toml
2+
{
3+
config,
4+
lib,
5+
dream2nix,
6+
packageSets,
7+
...
8+
}: let
9+
pyproject = lib.importTOML (config.mkDerivation.src + /pyproject.toml);
10+
pkgs = packageSets.nixpkgs;
11+
in {
12+
imports = [
13+
dream2nix.modules.dream2nix.pip
14+
];
15+
16+
deps = {nixpkgs, ...}: {
17+
python = nixpkgs.python310;
18+
};
19+
20+
inherit (pyproject.project) name version;
21+
22+
mkDerivation = {
23+
src = ./.;
24+
};
25+
26+
pip = {
27+
pypiSnapshotDate = "2023-08-27";
28+
requirementsList =
29+
pyproject.build-system.requires
30+
or []
31+
++ pyproject.project.dependencies;
32+
flattenDependencies = true;
33+
};
34+
35+
paths.projectRootFile = "pyproject.toml";
36+
37+
public = lib.mkForce (pkgs.runCommand "pip-lock-script-works" {
38+
outputHashMode = "flat";
39+
outputHashAlgo = "sha256";
40+
outputHash = "sha256-47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=";
41+
# invalidate by including into the name a hash over:
42+
# - the path to the nixpkgs
43+
# - TODO: the implementation of the fetch script
44+
name = let
45+
hash = builtins.hashString "sha256" (builtins.unsafeDiscardStringContext ''
46+
${pkgs.path}
47+
'');
48+
in "pip-lock-script-works-${lib.substring 0 16 hash}";
49+
} ''
50+
cp -r ${config.mkDerivation.src}/* .
51+
chmod +w -R .
52+
ls -lah
53+
${config.lock.refresh}/bin/refresh
54+
touch $out
55+
'');
56+
}

0 commit comments

Comments
 (0)