Skip to content

Commit

Permalink
Merge f2ac781 into bc5a8d1
Browse files Browse the repository at this point in the history
  • Loading branch information
exarkun committed May 13, 2021
2 parents bc5a8d1 + f2ac781 commit 3b32ee3
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 5 deletions.
4 changes: 4 additions & 0 deletions docs/release-checklist.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ Create Branch and Apply Updates
- summarize major changes
- commit it

- update "nix/tahoe-lafs.nix"

- change the value given for `version` from `OLD.post1` to `NEW.post1`

- update "CREDITS"

- are there any new contributors in this release?
Expand Down
1 change: 1 addition & 0 deletions newsfragments/3712.installation
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The Nix package now includes correct version information.
48 changes: 43 additions & 5 deletions nix/tahoe-lafs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,20 @@
, html5lib, pyutil, distro, configparser
}:
python.pkgs.buildPythonPackage rec {
version = "1.14.0.dev";
# Most of the time this is not exactly the release version (eg 1.15.1).
# Give it a `post` component to make it look newer than the release version
# and we'll bump this up at the time of each release.
#
# It's difficult to read the version from Git the way the Python code does
# for two reasons. First, doing so involves populating the Nix expression
# with values from the source. Nix calls this "import from derivation" or
# "IFD" (<https://nixos.wiki/wiki/Import_From_Derivation>). This is
# discouraged in most cases - including this one, I think. Second, the
# Python code reads the contents of `.git` to determine its version. `.git`
# is not a reproducable artifact (in the sense of "reproducable builds") so
# it is excluded from the source tree by default. When it is included, the
# package tends to be frequently spuriously rebuilt.
version = "1.15.1.post1";
name = "tahoe-lafs-${version}";
src = lib.cleanSourceWith {
src = ../.;
Expand All @@ -22,20 +35,22 @@ python.pkgs.buildPythonPackage rec {
# Build up a bunch of knowledge about what kind of file this is.
isTox = type == "directory" && basename == ".tox";
isTrialTemp = type == "directory" && basename == "_trial_temp";
isVersion = basename == "version.py";
isVersion = basename == "_version.py";
isBytecode = ext == "pyc" || ext == "pyo";
isBackup = lib.hasSuffix "~" basename;
isTemporary = lib.hasPrefix "#" basename && lib.hasSuffix "#" basename;
isSymlink = type == "symlink";
isGit = type == "directory" && basename == ".git";
in
# Exclude all these things
! (isTrialTemp
|| isTox
! (isTox
|| isTrialTemp
|| isVersion
|| isBytecode
|| isBackup
|| isTemporary
|| isSymlink
|| isGit
);
};

Expand All @@ -60,7 +75,21 @@ python.pkgs.buildPythonPackage rec {
# Since we're deleting files, this complains they're missing. For now Nix
# is Python 2-only, anyway, so these tests don't add anything yet.
rm src/allmydata/test/test_python3.py
'';
# Generate _version.py ourselves since we can't rely on the Python code
# extracting the information from the .git directory we excluded.
cat > src/allmydata/_version.py <<EOF
# This _version.py is generated from metadata by nix/tahoe-lafs.nix.
__pkgname__ = "tahoe-lafs"
real_version = "${version}"
full_version = "${version}"
branch = "master"
verstr = "${version}"
__version__ = verstr
EOF
'';


nativeBuildInputs = [
Expand All @@ -85,6 +114,15 @@ python.pkgs.buildPythonPackage rec {
];

checkPhase = ''
if ! $out/bin/tahoe --version | grep --fixed-strings "${version}"; then
echo "Package version:"
$out/bin/tahoe --version
echo "Did not contain expected:"
echo "${version}"
exit 1
else
echo "Version string contained expected value \"${version}.\""
fi
${python}/bin/python -m twisted.trial -j $NIX_BUILD_CORES allmydata
'';
}

0 comments on commit 3b32ee3

Please sign in to comment.