From e9f2416eef2c3cd050be1c7706d5bf250b18e4f1 Mon Sep 17 00:00:00 2001 From: Phillip Seeber Date: Tue, 10 Dec 2024 18:56:07 +0100 Subject: [PATCH] add nix build instructions and README section # Conflicts: # README.md --- README.md | 18 +++++++++++++ flake.lock | 60 +++++++++++++++++++++++++++++++++++++++++++ flake.nix | 24 +++++++++++++++++ tools/nix/overlay.nix | 11 ++++++++ tools/nix/trexio.nix | 55 +++++++++++++++++++++++++++++++++++++++ version_memo.txt | 2 +- 6 files changed, 169 insertions(+), 1 deletion(-) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 tools/nix/overlay.nix create mode 100644 tools/nix/trexio.nix diff --git a/README.md b/README.md index 6253c161..463932cb 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,7 @@ single- and/or multi-reference wave functions: * [Conda](#conda) * [Spack](#spack) * [Guix](#guix) + * [Nix](#nix) * [Debian/Ubuntu](#debianubuntu) * [Installation from source](#installation-from-source) * [Minimal requirements (for users):](#minimal-requirements-for-users) @@ -100,6 +101,23 @@ It can be installed as follows: guix package --cores=`getconf _NPROCESSORS_ONLN` --install-from-file=trexio.scm ``` +#### Nix + +The official releases of TREXIO `>=2.5.` can be used and installed via [Nix](https://nixos.org/). +This repository provides a [Nix Flake](https://nixos.wiki/wiki/Flakes), where [tools/nix/trexio.nix](https://github.com/TREX-CoE/trexio/blob/master/tools/nix/trexio.nix) provides the build specification. +You can inspect the flake or build the package with + +``` +nix flake show github:TREX-CoE/trexio +nix build github:TREX-CoE/trexio +``` + +TREXIO is also part of [NixPkgs](https://github.com/NixOS/nixpkgs) and can be used via that channel. + +``` +nix build nixpkgs#trexio +``` + #### Debian/Ubuntu The official release of TREXIO `2.2.0` is available as a Debian (`.deb`) package thanks to the [Debichem Team](https://wiki.debian.org/Debichem). diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..4155817f --- /dev/null +++ b/flake.lock @@ -0,0 +1,60 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1733852629, + "narHash": "sha256-lXMmrcEg1WxEdPiXpUfkxbJij0xS5acao1Jz4lnrNPY=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "9ad61cfc19c1f66e7d7d1ac9c71ae1b187065580", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..df93b878 --- /dev/null +++ b/flake.nix @@ -0,0 +1,24 @@ +{ + description = "TREX I/O library"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils }: + let overlay = import ./tools/nix/overlay.nix; + in flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { + inherit system; + overlays = [ overlay ]; + }; + in + { + packages.default = pkgs.trexio; + } + ) // { + overlays.default = overlay; + }; +} \ No newline at end of file diff --git a/tools/nix/overlay.nix b/tools/nix/overlay.nix new file mode 100644 index 00000000..4f43ffd5 --- /dev/null +++ b/tools/nix/overlay.nix @@ -0,0 +1,11 @@ +final: prev: { + trexio = final.callPackage ./trexio.nix { }; + + haskell = prev.haskell // { + packageOverrides = hfinal: hprev: { + trexio-hs = hfinal.callCabal2nix "trexio" ../haskell { + inherit (final) trexio; + }; + }; + }; +} diff --git a/tools/nix/trexio.nix b/tools/nix/trexio.nix new file mode 100644 index 00000000..6ed71729 --- /dev/null +++ b/tools/nix/trexio.nix @@ -0,0 +1,55 @@ +{ stdenv +, lib +, fetchFromGitHub +, cmake +, gfortran +, hdf5 +, python3 +, emacs +, swig +}: + +stdenv.mkDerivation rec { + pname = "trexio"; + version = "2.5.0"; + + src = lib.cleanSourceWith { + src = ../../.; + filter = path: type: ! (builtins.elem (builtins.baseNameOf path) [ + "haskell" + "docker" + "helpers-debian" + "ocaml" + "rust" + "python" + ] && type == "directory" ); + }; + + postPatch = '' + patchShebangs tools/* + ''; + + nativeBuildInputs = [ + cmake + gfortran + emacs + swig + python3 + ]; + + buildInputs = [ + hdf5 + ]; + + outputs = [ "out" "dev" ]; + + doCheck = true; + + meta = with lib; { + description = "File format and library for the storage of quantum chemical wave functions"; + homepage = "https://trex-coe.github.io/trexio/"; + downloadPage = "https://github.com/TREX-CoE/trexio"; + license = licenses.bsd3; + maintainers = [ maintainers.sheepforce ]; + }; +} diff --git a/version_memo.txt b/version_memo.txt index 67fcce71..54ef2b66 100644 --- a/version_memo.txt +++ b/version_memo.txt @@ -5,4 +5,4 @@ To update the version, change: - ocaml/trexio/trexio.opam - python/pytrexio/_version.py - rust/trexio/Cargo.toml - +- tools/nix/trexio.nix