- First open the specific package
default.nix
file - Packages always contains a
src =
section which defines where the sources are being pulled from. E.g. A package can be fetched fromGitHub
by specifying aowner
,repo
, therev
and thehash
.rev
can be a tag or a commit, and usually uses the version defined in the package. - To update to a new version, set the new version in
version =
and after that comment outhash
in the src section. We need to comment out thehash
, so nix recognizes the change and refetches the source. It will then tell us the new hash of the source directory, after runningnix build .#packagename
and we can use the new hash as replacement of the old. - Last but not least we can attempt to rebuild the package with
nix build .#packagename
which will then pull the src again and validate the hash, if everything works it will now build the new version of the package. Note, that there might be more to the version bump, like a change in dependencies.
- Open
precice-packages/dealii/default.nix
- Change the version from
9.4.1
->9.5.1
- Delete the line inside the
src
block starting withhash
- Run
nix build '.#dealii'
- Set the new hash value, resulting in
hash = "sha256-ifZjBOyHHezbpbaFtqTQ3xUzwwji7qKGtjq9QutWRhA="
- Run
nix build '.#dealii'
again - In this case the build works, but it seems like the tests fail, you can inspect the logs with
nix log ...
,nix build
will tell you the complete command. - The log output indicates that
perl
is missing for the tests, so you can add a new test dependency. There are a lot of different input types that nix has which are present at different parts of the stage, see reference. Here, we are looking fornativeCheckInputs
, which are inputs that are present at the check/test phase. We already have an input in thenativeCheckInputs
so we need to extend the current inputs withperl
resulting innativeCheckInputs = [ openssh perl ];
, but we also need to define it as an input into the package. We can do that at the top of the file with the following diff
diff --git a/precice-packages/dealii/default.nix b/precice-packages/dealii/default.nix
index 1e8c6e3..a6c0a49 100644
--- a/precice-packages/dealii/default.nix
+++ b/precice-packages/dealii/default.nix
@@ -20,6 +20,7 @@
, petsc
, zlib
, openssh
+, perl
}:
stdenv.mkDerivation rec {
This basically adds perl as a new input.
9. We can now run nix build '.#dealli
again and see if the tests now succeed.
As an alternative, you could have also disabled the check/test phase by changing doCheck = true;
to doCheck = false;