Skip to content

Commit

Permalink
nixish v1
Browse files Browse the repository at this point in the history
  • Loading branch information
pawelchcki committed Jul 5, 2024
1 parent 50c8fba commit 473f4b3
Show file tree
Hide file tree
Showing 5 changed files with 388 additions and 0 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`
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
269 changes: 269 additions & 0 deletions flake.lock

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

105 changes: 105 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
{
description = "ddapm_test_agent";
nixConfig.bash-prompt-prefix = "\[ddapm_test_agent\] ";

inputs = {
flake-utils.url = "github:numtide/flake-utils";
treefmt-nix.url = "github:numtide/treefmt-nix";
nixpkgs.url = "github:NixOS/nixpkgs/24.05";


ddsketch-flake.url = "github:pawelchcki/sketches-py/pawel/nix";

nix2containerPkg.url = "github:nlewo/nix2container";
};

outputs =
{ self
, nixpkgs
, flake-utils
, treefmt-nix
, ddsketch-flake
, nix2containerPkg
,
}:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
nix2container = nix2containerPkg.packages.${system}.nix2container;
ddsketch = ddsketch-flake.packages.${system}.default;

python = ddsketch-flake.packages.${system}.python;

pythonDevEnv = python;

treefmt = treefmt-nix.lib.evalModule pkgs ./treefmt.nix;

finalApp = python.pkgs.buildPythonApplication rec {
name = "ddapm-test-agent";
version = "0.0.0";
src = ./.;

doCheck = false;

propagatedBuildInputs = with python.pkgs; [ aiohttp msgpack ddsketch ];
nativeBuildInputs = with python.pkgs; [
setuptools
setuptools_scm
yarl
requests
];
env.SETUPTOOLS_SCM_PRETEND_VERSION = version;
};

devEnv = pkgs.buildEnv {
name = "root";
paths = [ pkgs.bashInteractive pkgs.coreutils treefmt.config.build.wrapper pythonDevEnv ];
pathsToLink = [ "/bin" ];
};
in
{
packages = {
python = python;
ddsketch = ddsketch-flake;
ciContainer = nix2container.buildImage {
name = "registry.ddbuild.io/apm-reliability-environment/handmade/nixci";

copyToRoot = pkgs.buildEnv {
name = "root";
paths = [ devEnv python.pkgs.pytest ];
pathsToLink = [ "/bin" ];
};
};
toolContainer = nix2container.buildImage {
name = "registry.ddbuild.io/apm-reliability-environment/handmade/docker-builder";
tag = "latest";
config = {
entrypoint = [ "/bin/docker-builder" ];
};

copyToRoot = pkgs.buildEnv {
name = "root";
paths = [ finalApp ];
pathsToLink = [ "/bin" ];
};
};
};

packages.default = finalApp;
formatter = treefmt.config.build.wrapper;

devShells.default =
pkgs.mkShell
{
venvDir = "./.venv";
nativeBuildInputs = [ pythonDevEnv python.pkgs.venvShellHook ];
packages = [
devEnv
python.pkgs.pytest
];
postShellHook = ''
export PYTHONPATH="$PYTHONPATH:$(pwd)" # ensuring pytest invocation works
'';
};
});
}
1 change: 1 addition & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(builtins.getFlake ("git+file://" + toString ./.)).devShells.${builtins.currentSystem}.default

0 comments on commit 473f4b3

Please sign in to comment.