Skip to content
Snippets Groups Projects
Commit 1831a8d1 authored by Philipp Arras's avatar Philipp Arras
Browse files

flake.nix: Add flake support

parent 5b2b29d8
No related branches found
No related tags found
1 merge request!977Tweaks
.envrc 0 → 100644
use flake
# nix-related
result
.nix-nifty-venv
.direnv
docs/source/user/getting_started_0.rst
docs/source/user/custom_nonlinearities.rst
......
{
"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": 1735834308,
"narHash": "sha256-dklw3AXr3OGO4/XT1Tu3Xz9n/we8GctZZ75ZWVqAVhk=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "6df24922a1400241dae323af55f30e4318a6ca65",
"type": "github"
},
"original": {
"id": "nixpkgs",
"ref": "nixos-unstable",
"type": "indirect"
}
},
"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
}
{
description = "Numerical Information Field Theory";
inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
myPyPkgs = pkgs.python3Packages;
version = "8.5.2";
req.minimal = with myPyPkgs; [ numpy scipy ducc0 ];
req.dev = with myPyPkgs; [ pytest pytest-cov matplotlib ];
# req.mpi = [ myPyPkgs.mpi4py pkgs.openmpi pkgs.openssh ];
req.jax = with myPyPkgs; [ jax jaxlib ];
req.rest = with myPyPkgs; [ astropy h5py ];
req.docs = with myPyPkgs; [
sphinx
pkgs.jupyter # python3Packages.jupyter is broken, see https://github.com/NixOS/nixpkgs/issues/299385
jupytext
pydata-sphinx-theme
myst-parser
];
allreqs = pkgs.lib.attrValues req;
nifty = myPyPkgs.buildPythonPackage {
pname = "nifty8";
inherit version;
src = ./.;
pyproject = true;
build-system = with pkgs.python3.pkgs; [ setuptools ];
dependencies = req.minimal;
# TODO Add MPI tests
checkInputs = [ myPyPkgs.pytestCheckHook ] ++ allreqs;
disabledTestPaths = [ "test/test_mpi" ];
pythonImportsCheck = [ "nifty8" ];
};
nifty-docs = pkgs.stdenv.mkDerivation {
name = "nifty-docs";
inherit version;
src = ./.;
buildInputs = allreqs ++ [ nifty ];
buildPhase = "sh docs/generate.sh";
installPhase = ''
mkdir $out
mv docs/build/* $out
'';
};
in {
# Standard nifty package
packages.default = nifty;
# Build nifty docs (`nix build .#docs`)
packages."docs" = nifty-docs;
# Development shell (`nix develop .`) including python-lsp-server for development
devShells.default = pkgs.mkShell {
nativeBuildInputs =
(with myPyPkgs; [ python-lsp-server python-lsp-ruff ])
++ (with pkgs; [ ruff ruff-lsp ]) ++ allreqs;
};
# Shell in which nifty is installed (`nix develop .#nifty-installed`),
# e.g., for building the docs (`sh docs/generate.sh`) or running demos
devShells."nifty-installed" = pkgs.mkShell {
nativeBuildInputs = allreqs;
packages = [ nifty ];
};
});
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment