From f58a8ba308eec71019762ea07fbb5436577349dd Mon Sep 17 00:00:00 2001 From: Michele Guerini Rocco Date: Wed, 15 Dec 2021 02:30:49 +0100 Subject: [PATCH] add Nix package --- .gitignore | 1 + default.nix | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 default.nix diff --git a/.gitignore b/.gitignore index a4aa7b8..a82aee7 100755 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .DS_store build configure.mk +result diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..d675e86 --- /dev/null +++ b/default.nix @@ -0,0 +1,41 @@ +{ static ? false }: + +let + # Pinned Nixpkgs for reproducibility + nixpkgs = import (builtins.fetchTarball + { name = "nixpkgs-21.05-ee90403e147"; + url = "https://github.com/nixos/nixpkgs/archive/ee90403e147.tar.gz"; + sha256 = "1mk3s4ncfa8z8mr6vrgjh74s8dci12yam7plpc1bqgz12wld73ax"; + }) {}; + + # Exclude this file and build artifacts + source = builtins.filterSource + (path: type: + !builtins.elem path [ "configure.mk" "default.nix" ] + && baseNameOf path != "build") ./.; + + inherit (nixpkgs) lib pkgs; + +in + pkgs.stdenv.mkDerivation rec { + pname = "gray"; + version = "0.1"; + src = source; + + nativeBuildInputs = with pkgs; [ makefile2graph graphviz gfortran ]; + buildInputs = lib.optional static pkgs.glibc.static; + + hardeningDisable = [ "format" ]; + configureFlags = [ + (lib.enableFeature static "static") + "GIT_REV=${version}" + "GIT_DIRTY=" + ]; + + 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? + }; + }