Skip to content

Commit 773580c

Browse files
authored
Merge pull request #281 from DavHau/dev
version 3.3.0
2 parents 97d7448 + 40e1302 commit 773580c

13 files changed

+87
-56
lines changed

Changelog.md

+31
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,34 @@
1+
# 3.3.0 (22 May 2021)
2+
bugfixes, flakes improvements
3+
4+
### Changes
5+
- The flakes cmdline api has been changed. New usage:
6+
```
7+
nix (build|shell) mach-nix#gen.(python|docker).package1.package2...
8+
```
9+
(Despite this changes being backward incompatible, I did not bump the major version since everything flakes related should be considered experimental anyways)
10+
11+
### Improvements
12+
- Mach-nix (used via flakes) will now throw an error if the selected nixpkgs version is newer than the dependency DB since this can cause conflicts in the resulting environment.
13+
- When used via flakes, it was impossible to select the python version because the import function is not used anymore. Now `python` can be passed to `mkPython` alternatively.
14+
- For the flakes cmdline api, collisions are now ignored by default
15+
- The simplified override interface did not deal well with non-existent values.
16+
- Now the `.add` directive automatically assumes an empty list/set/string when the attribute to be extended doesn't exist.
17+
- Now the `.mod` directive will pass `null` to the given function if the attribute to modify doesn't exist instead.
18+
19+
### Fixes
20+
- Generating an environment with a package named `overrides` failed due to a variable name collision in the resulting nix expression.
21+
- When used via flakes, the pypiData was downloaded twice, because the legacy code path for fetching was still used instead of the flakes input.
22+
- `nix flake show mach-nix` failed because it required IFD for foreign platforms.
23+
- For environments generated via `mach-nix env ...` the `python` command referred to the wrong interpreter.
24+
- When checking wheels for compatibility, the minor version for python was not respected which could lead to invalid environments.
25+
- Some python modules in nixpkgs propagate unnecessary dependencies which could lead to collisions in the final environment. Now mach-nix recursively removes all python dependencies which are not strictly required.
26+
27+
### Package Fixes
28+
- cryptography: remove rust related hook when version < 3.4
29+
30+
31+
132
# 3.2.0 (11 Mar 2021)
233
bugfixes, ignoreCollisions
334

Readme.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ Table of Contents
6363
You can either install mach-nix via pip or by using nix in case you already have the nix package manager installed.
6464
#### Installing via pip
6565
```shell
66-
pip install git+git://github.com/DavHau/mach-nix@3.2.0
66+
pip install git+git://github.com/DavHau/mach-nix@3.3.0
6767
```
6868
#### Installing via nix
6969
```shell
70-
nix-env -if https://github.com/DavHau/mach-nix/tarball/3.2.0 -A mach-nix
70+
nix-env -if https://github.com/DavHau/mach-nix/tarball/3.3.0 -A mach-nix
7171
```
7272
or, if you prefer `nix-shell`:
7373

@@ -80,7 +80,7 @@ or, if you prefer `nix-shell`:
8080
+ otherwise:
8181

8282
```shell
83-
nix-shell -p '(callPackage (fetchTarball https://github.com/DavHau/mach-nix/tarball/3.2.0) {}).mach-nix'
83+
nix-shell -p '(callPackage (fetchTarball https://github.com/DavHau/mach-nix/tarball/3.3.0) {}).mach-nix'
8484
```
8585

8686
---
@@ -112,7 +112,7 @@ You can call mach-nix directly from a nix expression
112112
let
113113
mach-nix = import (builtins.fetchGit {
114114
url = "https://github.com/DavHau/mach-nix/";
115-
ref = "refs/tags/3.2.0";
115+
ref = "refs/tags/3.3.0";
116116
}) {};
117117
in
118118
mach-nix.mkPython {

examples.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ every mach-nix expression should begin like this:
4545
let
4646
mach-nix = import (builtins.fetchGit {
4747
url = "https://github.com/DavHau/mach-nix/";
48-
ref = "refs/tags/3.2.0";
48+
ref = "refs/tags/3.3.0";
4949
}) {
5050
# optionally bring your own nixpkgs
5151
# pkgs = import <nixpkgs> {};
@@ -281,7 +281,7 @@ In this example, mach-nix is used to resolve our python dependencies and provide
281281
let
282282
mach-nix = import (builtins.fetchGit {
283283
url = "https://github.com/DavHau/mach-nix/";
284-
ref = "refs/tags/3.2.0"; # update this version
284+
ref = "refs/tags/3.3.0"; # update this version
285285
}) {
286286
python = "python37";
287287
};

interpreter.nix

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# python interpreter for dev environment
22
let
33
pkgs = import (import ./mach_nix/nix/nixpkgs-src.nix) { config = {}; };
4-
python = pkgs.python37;
4+
python = pkgs.python38;
55
deps = (pkgs.lib.attrValues (import ./mach_nix/nix/python-deps.nix { inherit python; fetchurl = pkgs.fetchurl; }));
66
in
77
python.withPackages (ps: deps ++ [

mach_nix/VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
master
1+
3.3.0

mach_nix/fixes.nix

+28-20
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,36 @@ let
2020
result = parse('${ver1}') ${op} parse('${ver2}')
2121
print(json.dumps(result))
2222
'';
23+
24+
# prevent the normal fitler from being used
25+
filter = raise "Error: only use filterSafe (doesn't crash on null input)";
26+
27+
# filter function that doesn't crash on 'objects = null'
28+
# This is important because null will be returned whenever the attribute to modify doesn't exist
29+
filterSafe = func: objects: if isNull objects then [] else builtins.filter func objects;
30+
2331
in
2432

2533

2634
### Put Fixes here
2735
rec {
2836

29-
### FORMAT ############################################################################
30-
# #
31-
# package-to-fix = { #
32-
# name-of-the-fix = { #
33-
# # optionally limit the fix to a condtion #
34-
# _cond = {prov, ver, ... }: some boolean expression; #
35-
# #
36-
# # define overrides #
37-
# key-to-override = ...; # replace #
38-
# key-to-override.add = ...; # append #
39-
# key-to-override.mod = oldVal: ...; # modify #
40-
# key-to-override.mod = pySelf: oldAttrs: oldVal: ...; # modify (more args) #
41-
# }; #
42-
# }; #
43-
# #
44-
#########################################################################################
37+
### FORMAT ##################################################################################
38+
# #
39+
# package-to-fix = { #
40+
# name-of-the-fix = { #
41+
# # optionally limit the fix to a condtion #
42+
# _cond = {prov, ver, ... }: some boolean expression; #
43+
# #
44+
# # define overrides #
45+
# key-to-override = ...; # replace #
46+
# key-to-override.add = ...; # append (list/attrs/string) #
47+
# key-to-override.mod = oldVal: ...; # modify #
48+
# key-to-override.mod = pySelf: oldAttrs: oldVal: ...; # modify (accessing all pkgs) #
49+
# }; #
50+
# }; #
51+
# #
52+
###############################################################################################
4553

4654
### _cond ####################################
4755
# possible arguments: #
@@ -57,7 +65,7 @@ rec {
5765

5866
cryptography.no-rust-build = {
5967
_cond = { prov, ver, ... }: prov == "sdist" && comp_ver ver "<" "3.4";
60-
nativeBuildInputs.mod = old: filter (inp: (inp.name or "") != "cargo-setup-hook.sh") old;
68+
nativeBuildInputs.mod = old: filterSafe (inp: (inp.name or "") != "cargo-setup-hook.sh") old;
6169
};
6270

6371
# remove if merged: https://github.com/NixOS/nixpkgs/pull/114384
@@ -83,15 +91,15 @@ rec {
8391

8492
pip.remove-reproducible-patch = {
8593
_cond = { prov, ver, ... }: prov == "sdist" && comp_ver ver "<" "20.0";
86-
patches.mod = oldPatches: filter (patch: ! hasSuffix "reproducible.patch" patch) oldPatches;
94+
patches.mod = oldPatches: filterSafe (patch: ! hasSuffix "reproducible.patch" patch) oldPatches;
8795
};
8896

8997
pyqt5 = {
9098
fix-build-inputs = {
9199
# fix mach-nix induced problem: mach-nix removes all previous python inputs from propagatedBuildInputs
92100
_cond = {prov, ... }: prov == "nixpkgs";
93101
propagatedBuildInputs.mod = pySelf: oldAttrs: oldVal:
94-
(filter (p: p.pname != "pyqt5-sip") oldVal) ++ [ pySelf.sip pySelf.dbus-python ];
102+
(filterSafe (p: p.pname != "pyqt5-sip") oldVal) ++ [ pySelf.sip pySelf.dbus-python ];
95103
};
96104
fix-wheel-inputs = {
97105
_cond = {prov, ... }: prov == "wheel";
@@ -106,7 +114,7 @@ rec {
106114
# https://github.com/rpy2/rpy2/commit/39e1cb6fca0d4107f1078727d8670c422e3c6f7f
107115
prov == "sdist"
108116
&& comp_ver ver ">=" "3.2.6";
109-
patches.mod = oldPatches: filter (p: ! hasSuffix "pandas-1.x.patch" p) oldPatches;
117+
patches.mod = oldPatches: filterSafe (p: ! hasSuffix "pandas-1.x.patch" p) oldPatches;
110118
};
111119

112120
tensorflow.rm-tensorboard = {

mach_nix/flake.lock

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mach_nix/nix/compileOverrides.nix

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ let
1212
nixpkgs_json = import ./nixpkgs-json.nix {
1313
inherit overrides pkgs python;
1414
};
15-
builder_python = pkgs.pkgsBuildHost.python37.withPackages(ps:
16-
(pkgs.lib.attrValues (import ./python-deps.nix {python = pkgs.python37; fetchurl = pkgs.fetchurl; }))
15+
builder_python = pkgs.pkgsBuildHost.python38.withPackages(ps:
16+
(pkgs.lib.attrValues (import ./python-deps.nix {python = pkgs.python38; fetchurl = pkgs.fetchurl; }))
1717
);
1818
src = ./../../.;
1919
db_and_fetcher = import ./deps-db-and-fetcher.nix {

mach_nix/nix/deps-db-and-fetcher.nix

+3-10
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,11 @@ let
2121
inherit pkgs;
2222
};
2323
in
24-
let
25-
pypi_deps_db_src = pkgs.buildEnv {
26-
name = "pypi-deps-db-src";
27-
paths = [ deps_db_src ];
28-
};
29-
in
30-
{ inherit
31-
pypi_deps_db_src
24+
{
25+
pypi_deps_db_src = deps_db_src;
26+
inherit
3227
pypi_fetcher_src
33-
3428
pypi_fetcher_commit
3529
pypi_fetcher_sha256
36-
3730
pypi_fetcher;
3831
}

mach_nix/nix/lib.nix

+6-6
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ rec {
9191
};
9292

9393
combine = pname: key: val1: val2:
94-
if isList val2 then val1 ++ val2
95-
else if isAttrs val2 then val1 // val2
96-
else if isString val2 then val1 + val2
94+
if isList val2 then (if ! isNull val1 then val1 else []) ++ val2
95+
else if isAttrs val2 then (if ! isNull val1 then val1 else {}) // val2
96+
else if isString val2 then (if ! isNull val1 then val1 else "") + val2
9797
else throw "_.${pname}.${key}.add only accepts list or attrs or string.";
9898

9999
fixes_to_overrides = fixes:
@@ -107,14 +107,14 @@ rec {
107107
mapAttrs (key: val:
108108
trace "\napplying fix '${fix}' (${key}) for ${pkg}:${oa.version}\n" (
109109
if isAttrs val && hasAttr "add" val then
110-
combine pkg key oa."${key}" val.add
110+
combine pkg key (oa."${key}" or null) val.add
111111
else if isAttrs val && hasAttr "mod" val && isFunction val.mod then
112-
let result = val.mod oa."${key}"; in
112+
let result = val.mod (oa."${key}" or null); in
113113
# if the mod function wants more argument, call with more arguments (alternative style)
114114
if ! isFunction result then
115115
result
116116
else
117-
val.mod pySelf oa oa."${key}"
117+
val.mod pySelf oa (oa."${key}" or null)
118118
else
119119
val
120120
)

mach_nix/nix/python.nix

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
}:
55
with pkgs;
66
let
7-
python = python37;
7+
python = python38;
88
python_deps = (lib.attrValues (import ./python-deps.nix { inherit python; fetchurl = fetchurl; }));
99
in
1010
python.withPackages ( ps: python_deps )

shell.nix

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
}:
55
with pkgs;
66
let
7-
python = python37;
7+
python = python38;
88
machnixDeps = (lib.attrValues (import ./mach_nix/nix/python-deps.nix { inherit python; fetchurl = fetchurl; }));
99
in
1010
mkShell {

tests/test_flakes.nix

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
with builtins;
66
let
77
pyEnv = (builtins.getFlake (toString ../.)).packages.x86_64-linux.gen.python.requests;
8-
pyEnvShell = (builtins.getFlake (toString ../.)).packages.x86_64-linux.gen.shell.requests;
98
pyEnvDockerImage = (builtins.getFlake (toString ../.)).packages.x86_64-linux.gen.docker.requests;
109
in
1110
(map (p:
@@ -15,7 +14,7 @@ in
1514
throw "Error"
1615
) [pyEnv pyEnvDockerImage])
1716
++ [
18-
(if ! pyEnvShell ? _passthru.python.pkgs.requests then
17+
(if ! pyEnv ? _passthru.python.pkgs.requests then
1918
throw "Error with shell"
2019
else
2120
mach-nix.nixpkgs.hello)

0 commit comments

Comments
 (0)