gray/default.nix
Michele Guerini Rocco bc28d14ebe
add infrastructure for making releases
Idea: a release will be a git tag, distributed as an autogenerated
archive (eg. by GitLab release feature).
This version string must therefore be stored in a revisioned file, so we
use `.version` for this purpose. Before tagging a new release this file
will have to be updated with the new version number.

When building gray the revision (shown in the output headers and usage
screen) will be set to either

- the latest commit hash when building from a git checkout,

- from the .version file when building from release archive.

The implementation is based on whether the .git directory is present.
2024-12-04 16:39:25 +01:00

85 lines
2.1 KiB
Nix

{ static ? false }:
let
# Pinned Nixpkgs for reproducibility
nixpkgs = builtins.fetchTarball
{ name = "nixpkgs-23.05.5a237aecb572";
url = "https://github.com/nixos/nixpkgs/archive/5a237aecb572.tar.gz";
sha256 = "166yxg4ff2jxvl9mbngd90dr1k3rdj6xmiccga41xynhh2zr0vmb";
};
# Needed for HTML manual
katex = builtins.fetchTarball {
url = "https://github.com/KaTeX/KaTeX/releases/download/v0.15.1/katex.tar.gz";
sha256 = "007nv11r0z9fz593iwzn55nc0p0wj5lpgf0k2brhs1ynmikq9gjr";
};
# Exclude this file, build artifacts and git
source = builtins.filterSource
(path: type:
!builtins.elem path [ "configure.mk" "default.nix" "result" ]
&& baseNameOf path != "build"
&& baseNameOf path != ".git") ./.;
inherit (import nixpkgs {}) lib pkgs;
in
pkgs.stdenv.mkDerivation rec {
pname = "gray";
version = builtins.readFile ./.version;
src = source;
doCheck = true;
checkInputs = with pkgs.python3Packages; [
numpy scipy matplotlib
];
nativeBuildInputs = with pkgs; [
# fortran
gfortran
# debugging
makefile2graph graphviz
# documentation
help2man pandoc librsvg
haskellPackages.pandoc-crossref
(texlive.combine {
inherit (texlive) scheme-small xetex fontspec;
})
# save nixpkgs tarball from gc
nixpkgs
];
buildInputs = lib.optional static pkgs.glibc.static;
# fonts needed for the PDF manual
FONTCONFIG_FILE = pkgs.makeFontsConf {
fontDirectories = with pkgs; [ libertinus julia-mono ];
};
preConfigure = ''
# set directories for temporary files
export XDG_CACHE_HOME=$NIX_BUILD_TOP
export XDG_CONFIG_HOME=$NIX_BUILD_TOP
'';
enableParallelBuilding = true;
hardeningDisable = [ "format" ];
configureFlags = [
(lib.enableFeature static "static")
"--with-katex=${katex}"
"--enable-deterministic"
];
meta = {
homepage = "https://doi.org/10.13182/FST07-A1494";
description = "A quasi-optical beam-tracing code for EC waves in tokamaks";
platforms = lib.platforms.unix;
# license?
};
}