Skip to content

Commit

Permalink
Add nix flake
Browse files Browse the repository at this point in the history
  • Loading branch information
MathieuMoalic committed Jan 26, 2024
1 parent a0f3cb6 commit 74b6ab6
Show file tree
Hide file tree
Showing 2 changed files with 140 additions and 0 deletions.
61 changes: 61 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

79 changes: 79 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{
description = "A flake for the amumax project";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
};

outputs = {
nixpkgs,
flake-utils,
...
}:
flake-utils.lib.eachDefaultSystem (
system: let
pkgs = import nixpkgs {
inherit system;
config = {
allowUnfree = true; # if your dependencies are unfree
};
};
buildAmumax = pkgs:
pkgs.buildGoModule rec {
pname = "amumax";
version = "2023.12.14";

src = pkgs.fetchFromGitHub {
owner = "MathieuMoalic";
repo = "amumax";
rev = version;
hash = "sha256-U9e8DvgAb5/e2JTDI0yXPF9ollixax3JjeyEFiJbesM=";
};

vendorHash = "sha256-YqB7EofpTqDnqOQ+ARDJNvZVFltAy0j210lbSwEvifw=";

nativeBuildInputs = [
pkgs.cudaPackages.cuda_nvcc
pkgs.addDriverRunpath
];

buildInputs = [
pkgs.cudaPackages.cuda_cudart
pkgs.cudaPackages.cuda_nvcc.dev
pkgs.cudaPackages.libcufft
pkgs.cudaPackages.libcurand
];

CGO_CFLAGS = [
"-lcufft"
"-lcurand"
];

CGO_LDFLAGS = ["-L${pkgs.cudaPackages.cuda_cudart.lib}/lib/stubs/"];

ldflags = [
"-s"
"-w"
];

doCheck = false;

postFixup = ''
addDriverRunpath $out/bin/*
'';

meta = with pkgs.lib; {
description = "Fork of mumax3";
homepage = "https://github.com/MathieuMoalic/amumax/tree/main";
license = licenses.gpl3;
maintainers = [];
mainProgram = "amumax";
};
};
in {
packages.amumax = buildAmumax pkgs;
defaultPackage = buildAmumax pkgs;
}
);
}

0 comments on commit 74b6ab6

Please sign in to comment.