2024-12-10 17:34:31 +01:00
|
|
|
{
|
2024-12-12 03:13:17 +01:00
|
|
|
static ? false
|
|
|
|
, system ? builtins.currentSystem
|
2024-12-10 17:34:31 +01:00
|
|
|
}:
|
2021-12-15 02:30:49 +01:00
|
|
|
|
|
|
|
let
|
|
|
|
# Pinned Nixpkgs for reproducibility
|
2022-05-04 10:17:17 +02:00
|
|
|
nixpkgs = builtins.fetchTarball
|
2024-12-10 17:34:31 +01:00
|
|
|
{ name = "nixpkgs-23.05.5a237aecb572";
|
|
|
|
url = "https://github.com/nixos/nixpkgs/archive/5a237aecb572.tar.gz";
|
2023-10-17 11:09:26 +02:00
|
|
|
sha256 = "166yxg4ff2jxvl9mbngd90dr1k3rdj6xmiccga41xynhh2zr0vmb";
|
2022-05-04 10:17:17 +02:00
|
|
|
};
|
2021-12-15 02:30:49 +01:00
|
|
|
|
2021-12-15 02:30:58 +01:00
|
|
|
# Needed for HTML manual
|
2024-12-10 17:34:31 +01:00
|
|
|
katex = builtins.fetchTarball
|
|
|
|
{ url = "https://github.com/KaTeX/KaTeX/releases/download/v0.15.1/katex.tar.gz";
|
|
|
|
sha256 = "007nv11r0z9fz593iwzn55nc0p0wj5lpgf0k2brhs1ynmikq9gjr";
|
|
|
|
};
|
|
|
|
|
|
|
|
# Exclude this file, .git and more from source
|
|
|
|
sieve = path: type:
|
|
|
|
!builtins.elem (baseNameOf path) (
|
|
|
|
[ "default.nix" ".git" ]
|
|
|
|
++ lib.splitString "\n" (lib.readFile ./.gitignore));
|
|
|
|
|
2024-12-12 03:13:17 +01:00
|
|
|
inherit (import nixpkgs { inherit system; }) lib pkgs;
|
2024-12-10 17:34:31 +01:00
|
|
|
|
|
|
|
python = pkgs.python3;
|
|
|
|
|
|
|
|
gray-python = python.pkgs.buildPythonPackage {
|
|
|
|
pname = "gray";
|
|
|
|
version = builtins.readFile ./.version;
|
|
|
|
src = builtins.filterSource sieve ./.;
|
|
|
|
|
|
|
|
format = "other";
|
|
|
|
propagatedBuildInputs = with pkgs.python3Packages; [ numpy matplotlib ];
|
|
|
|
makeFlags = [ "PREFIX=$(out)" ];
|
2021-12-15 02:30:58 +01:00
|
|
|
|
2024-12-10 17:34:31 +01:00
|
|
|
dontConfigure = true;
|
|
|
|
dontBuild = true;
|
|
|
|
installTargets = "install-python";
|
2021-12-15 02:30:49 +01:00
|
|
|
|
2024-12-10 17:34:31 +01:00
|
|
|
pythonImportsCheck = [ "gray" ];
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
description = "Python interface to GRAY";
|
|
|
|
platforms = python.meta.platforms;
|
|
|
|
};
|
|
|
|
};
|
2021-12-15 02:30:49 +01:00
|
|
|
|
|
|
|
in
|
2024-12-10 17:34:31 +01:00
|
|
|
pkgs.stdenv.mkDerivation {
|
2021-12-15 02:30:49 +01:00
|
|
|
pname = "gray";
|
2024-12-04 16:18:32 +01:00
|
|
|
version = builtins.readFile ./.version;
|
2024-12-10 17:34:31 +01:00
|
|
|
src = builtins.filterSource sieve ./.;
|
2021-12-15 02:30:49 +01:00
|
|
|
|
2023-12-18 00:52:11 +01:00
|
|
|
doCheck = true;
|
|
|
|
|
2024-12-10 17:34:31 +01:00
|
|
|
checkInputs = with python.pkgs; [ numpy scipy matplotlib ];
|
2023-12-18 00:52:11 +01:00
|
|
|
|
2021-12-15 02:30:58 +01:00
|
|
|
nativeBuildInputs = with pkgs; [
|
|
|
|
# fortran
|
|
|
|
gfortran
|
|
|
|
|
|
|
|
# debugging
|
|
|
|
makefile2graph graphviz
|
|
|
|
|
|
|
|
# documentation
|
2024-11-09 12:02:14 +01:00
|
|
|
help2man pandoc librsvg
|
2021-12-15 02:31:17 +01:00
|
|
|
haskellPackages.pandoc-crossref
|
2021-12-15 02:30:58 +01:00
|
|
|
(texlive.combine {
|
|
|
|
inherit (texlive) scheme-small xetex fontspec;
|
|
|
|
})
|
2022-05-04 10:17:17 +02:00
|
|
|
|
|
|
|
# save nixpkgs tarball from gc
|
|
|
|
nixpkgs
|
2021-12-15 02:30:58 +01:00
|
|
|
];
|
|
|
|
|
2024-12-10 17:34:31 +01:00
|
|
|
buildInputs =
|
|
|
|
lib.singleton (python.withPackages (p: [ gray-python ]))
|
|
|
|
++ lib.optional static pkgs.glibc.static;
|
2021-12-15 02:31:19 +01:00
|
|
|
|
2021-12-15 02:30:58 +01:00
|
|
|
# fonts needed for the PDF manual
|
2024-12-10 17:34:31 +01:00
|
|
|
env.FONTCONFIG_FILE = pkgs.makeFontsConf
|
|
|
|
{ fontDirectories = with pkgs; [ libertinus julia-mono ]; };
|
2024-12-03 16:54:18 +01:00
|
|
|
|
|
|
|
preConfigure = ''
|
|
|
|
# set directories for temporary files
|
|
|
|
export XDG_CACHE_HOME=$NIX_BUILD_TOP
|
|
|
|
export XDG_CONFIG_HOME=$NIX_BUILD_TOP
|
|
|
|
'';
|
2021-12-15 02:30:58 +01:00
|
|
|
|
2021-12-15 02:31:19 +01:00
|
|
|
enableParallelBuilding = true;
|
2021-12-15 02:30:49 +01:00
|
|
|
|
|
|
|
hardeningDisable = [ "format" ];
|
|
|
|
configureFlags = [
|
|
|
|
(lib.enableFeature static "static")
|
2021-12-15 02:30:58 +01:00
|
|
|
"--with-katex=${katex}"
|
2023-10-13 13:58:47 +02:00
|
|
|
"--enable-deterministic"
|
2021-12-15 02:30:49 +01:00
|
|
|
];
|
|
|
|
|
2024-12-10 17:34:31 +01:00
|
|
|
shellHook = ''
|
|
|
|
export PREFIX=build/
|
|
|
|
export PYTHONPATH=build/${python.sitePackages}
|
|
|
|
'';
|
|
|
|
|
|
|
|
passthru.python = gray-python;
|
|
|
|
|
2021-12-15 02:30:49 +01:00
|
|
|
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?
|
|
|
|
};
|
|
|
|
}
|