Skip to content

Commit

Permalink
nix updates for pyopensci review (#2975)
Browse files Browse the repository at this point in the history
Fix #2905 #2907 

- Use `DeterminateSystems/nix-installer-action` and
`DeterminateSystems/magic-nix-cache-action` for installing nix and
caching
- Also run nix on macos-14 (arm64)
- run `nix develop` instead of `nix-shell` to mirror direnv
  • Loading branch information
luizirber committed Feb 10, 2024
1 parent aef3c61 commit 7edcf14
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 33 deletions.
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Pre-commit updates (#2427)
fee62922d8857ce93f1d4e90fd7240629d606997
20 changes: 9 additions & 11 deletions .github/workflows/dev_envs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,23 @@ on:
branches: [latest]
jobs:
nix:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-14]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: cachix/install-nix-action@v25
with:
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- uses: cachix/cachix-action@v14
with:
name: sourmash-bio
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v4
- name: Run the Magic Nix Cache
uses: DeterminateSystems/magic-nix-cache-action@v1

- run: nix run .# -- --version

- run: nix-shell --command "tox -e py310"
- run: nix develop --command bash -c "tox -e py310"

mamba:
runs-on: ubuntu-latest
Expand Down
18 changes: 9 additions & 9 deletions flake.lock

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

45 changes: 32 additions & 13 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30,40 +30,55 @@
rustc = rustVersion;
};

inherit (pkgs) lib;

python = pkgs.python311Packages;

stdenv = if pkgs.stdenv.isDarwin then pkgs.overrideSDK pkgs.stdenv "11.0" else pkgs.stdenv;

commonArgs = {
src = ./.;
stdenv = stdenv;
preConfigure = lib.optionalString stdenv.isDarwin ''
export MACOSX_DEPLOYMENT_TARGET=10.14
'';

# Work around https://github.com/NixOS/nixpkgs/issues/166205.
env = lib.optionalAttrs stdenv.cc.isClang {
NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}";
};

buildInputs = lib.optionals stdenv.isDarwin [ pkgs.libiconv pkgs.darwin.apple_sdk.frameworks.Security ];

nativeBuildInputs = with rustPlatform; [ cargoSetupHook maturinBuildHook bindgenHook ];
};

in

with pkgs;
{
packages = {

lib = rustPlatform.buildRustPackage {
lib = rustPlatform.buildRustPackage ( commonArgs // {
name = "libsourmash";
src = lib.cleanSource ./.;
copyLibs = true;
cargoLock.lockFile = ./Cargo.lock;
nativeBuildInputs = with rustPlatform; [ bindgenHook ];
};
});

sourmash = python.buildPythonPackage rec {
sourmash = python.buildPythonPackage ( commonArgs // rec {
pname = "sourmash";
version = "4.8.6-dev";
format = "pyproject";

src = ./.;

cargoDeps = rustPlatform.importCargoLock {
lockFile = ./Cargo.lock;
};

nativeBuildInputs = with rustPlatform; [ cargoSetupHook maturinBuildHook bindgenHook ];

buildInputs = lib.optionals stdenv.isDarwin [ libiconv ];
propagatedBuildInputs = with python; [ cffi deprecation cachetools bitstring numpy scipy matplotlib screed ];

DYLD_LIBRARY_PATH = "${self.packages.${system}.lib}/lib";
};
});

docker =
let
Expand All @@ -83,7 +98,7 @@

defaultPackage = self.packages.${system}.sourmash;

devShell = mkShell {
devShells.default = pkgs.mkShell.override { stdenv = stdenv; } (commonArgs // {
nativeBuildInputs = with rustPlatform; [ bindgenHook ];

buildInputs = [
Expand Down Expand Up @@ -113,15 +128,19 @@
cargo-outdated
cargo-udeps
cargo-deny
cargo-semver-checks
#cargo-semver-checks
nixpkgs-fmt
];

shellHook = ''
export MACOSX_DEPLOYMENT_TARGET=10.14
'';

# Needed for matplotlib
LD_LIBRARY_PATH = lib.makeLibraryPath [ pkgs.stdenv.cc.cc.lib ];

# workaround for https://github.com/NixOS/nixpkgs/blob/48dfc9fa97d762bce28cc8372a2dd3805d14c633/doc/languages-frameworks/python.section.md#python-setuppy-bdist_wheel-cannot-create-whl
SOURCE_DATE_EPOCH = 315532800; # 1980
};
});
});
}
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ wheel_build_env = .pkg
pass_env =
LIBCLANG_PATH
BINDGEN_EXTRA_CLANG_ARGS
NIX_*

[testenv:pypy3]
deps =
Expand Down

0 comments on commit 7edcf14

Please sign in to comment.