Skip to content

Commit

Permalink
nixish v1
Browse files Browse the repository at this point in the history
  • Loading branch information
pawelchcki committed Jul 12, 2024
1 parent 50c8fba commit 0387b65
Show file tree
Hide file tree
Showing 13 changed files with 513 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .envrc.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# use https://github.com/nix-community/nix-direnv to load all tools needed to develop in the repository
# $ cp .envrc.example .envrc
# $ direnv allow .
use flake --impure .

# alternatively just use `nix develop` or `nix-shell`
33 changes: 33 additions & 0 deletions .github/workflows/nix-auto.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Nix Flake actions

on:
pull_request:
push:
branches:
- master
- main

jobs:
nix-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v27
- id: set-matrix
name: Generate Nix Matrix
run: |
set -Eeu
matrix="$(nix eval --json '.#githubActions.matrix')"
echo "matrix=$matrix" >> "$GITHUB_OUTPUT"
nix:
needs: nix-matrix
runs-on: ${{ matrix.os }}
strategy:
matrix: ${{fromJSON(needs.nix-matrix.outputs.matrix)}}
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v27
- run: nix build -L '.#githubActions.checks.${{ matrix.attr }}'
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,10 @@ htmlcov/
.coverage
.coverage.*
.cache

# Automated dev env setup - see .envrc.example
/.envrc
/.direnv/

# nix
/result
32 changes: 32 additions & 0 deletions ddsketch.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{ python, pkgs, ... }:
python.pkgs.buildPythonPackage rec {
name = "ddsketch";
version = "3.0.1";

src = pkgs.fetchFromGitHub {
owner = "datadog";
repo = "sketches-py";
rev = "refs/tags/v${version}";
hash = "sha256-SmdKq5aXi5B3FNBxPQDNKNBujGGEPXF132YGadGFPpo=";
};

propagatedBuildInputs = with python.pkgs; [
six
protobuf
setuptools
];
nativeBuildInputs = with python.pkgs; [ setuptools_scm ];
checkInputs = with python.pkgs; [
pytest
numpy
];
env.SETUPTOOLS_SCM_PRETEND_VERSION = version;

pythonImportsCheck = [ "ddsketch" ];

postPatch = ''
patchShebangs setup.py
ls -lah
echo version=\"${version}\" > ddsketch/__version.py
'';
}
71 changes: 71 additions & 0 deletions ddtrace.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
python,
pkgs,
ddsketch,
...
}:

let
envier = python.pkgs.buildPythonPackage rec {
pname = "envier";
version = "0.5.2";

pyproject = true;
propagatedBuildInputs = with python.pkgs; [
hatchling
hatch-vcs
];

src = pkgs.fetchPypi {
inherit pname version;
sha256 = "sha256-Tn45jLCajdNgUI734SURoVI1VCbSVEuEh6NNrSfMIK0=";
};
};

ddtrace = python.pkgs.buildPythonPackage rec {
pname = "ddtrace";
version = "2.9.2";
pyproject = true;

nativeBuildInputs =
[ pkgs.cmake ]
++ (with python.pkgs; [
cmake
setuptools
setuptools_scm
cython
])
++ pkgs.lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.IOKit ];

propagatedBuildInputs = with python.pkgs; [
attrs
cattrs
ddsketch
envier
opentelemetry-api
protobuf
six
xmltodict
bytecode
];

postPatch = ''
substituteInPlace setup.py --replace "cmake>=3.24.2,<3.28" "cmake"
# downloading artifacts is impossible in sandboxed build
substituteInPlace setup.py --replace "cls.download_artifacts()" "pass"
substituteInPlace pyproject.toml --replace "cmake>=3.24.2,<3.28" "cmake"
'';

dontUseCmakeConfigure = true;

src = pkgs.fetchFromGitHub {
owner = "datadog";
repo = "dd-trace-py";
rev = "refs/tags/v${version}";
hash = "sha256-Ax220/uBNwSZNBFYxbxAe0rmLrqYYf3a8K/PIuSE150=";
};
};
in
(ddtrace)
201 changes: 201 additions & 0 deletions flake.lock

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

Loading

0 comments on commit 0387b65

Please sign in to comment.