Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ __pycache__
venv*

.pytest_cache
.idea
.idea
result
124 changes: 5 additions & 119 deletions flake.lock

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

41 changes: 14 additions & 27 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,18 @@
description = "wanda - WAN Data Aggregator";

inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
inputs.poetry2nix = {
url = "github:nix-community/poetry2nix";
inputs.nixpkgs.follows = "nixpkgs";
};
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";

outputs = { self, nixpkgs, flake-utils, poetry2nix }:
outputs = { self, nixpkgs, flake-utils }:
{
# Nixpkgs overlay providing the application
overlay = nixpkgs.lib.composeManyExtensions [
poetry2nix.overlays.default
(final: prev: {
# The application
wanda = prev.poetry2nix.mkPoetryApplication {
projectDir = with final.lib; cleanSourceWith {
src = ./.;
filter = path: type: !(hasSuffix ".nix" path) && baseNameOf path != ".nix";
};
};

# Used to run tests for wanda
wandaTestEnv = prev.poetry2nix.mkPoetryEnv {
projectDir = ./.;
};

wandaNixosTest = final.nixosTest (import ./nixos-test.nix);
})
];
overlay = (final: prev: let
pyprojectFile = builtins.fromTOML (builtins.readFile ./pyproject.toml);
# We absolutly want to ship our own deps, so we use our own python and our own python3Packages.
pkgs = nixpkgs.legacyPackages.${final.stdenv.hostPlatform.system};
in {
wanda = pkgs.python3.pkgs.callPackage ./package.nix { wanda-version = pyprojectFile.tool.poetry.version; };
});
} // (flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
Expand All @@ -39,14 +23,17 @@
in
{
packages = {
inherit (pkgs) wanda wandaNixosTest;
inherit (pkgs) wanda;
default = pkgs.wanda;
};

checks = {
wandaTest = pkgs.callPackage ./nixos-test.nix { inherit self; };
};

devShell = pkgs.mkShell {
buildInputs = with pkgs; [
bgpq4
wanda.dependencyEnv
];
};
}));
Expand Down
8 changes: 5 additions & 3 deletions nixos-test.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{ lib, pkgs, ... }: {
name = "peering-manager";
{ lib, pkgs, ... }:

pkgs.nixosTest {
name = "wanda";

meta = with lib.maintainers; {
maintainers = [ yuka ];
Expand All @@ -12,7 +14,7 @@
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
'';
};
environment.systemPackages = with pkgs; [ wanda wandaTestEnv bgpq4 ];
environment.systemPackages = with pkgs; [ wanda wanda.pythonEnv ];
};

testScript = { nodes }: let
Expand Down
38 changes: 38 additions & 0 deletions package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{ python,
buildPythonApplication,
poetry-core,
requests,
pyyaml,
enlighten,
pytest,
pytest-mock,
wanda-version,
}:

buildPythonApplication rec {
version = wanda-version;

pname = "wanda";
pyproject = true;

src = ./.;

build-system = [
poetry-core
];

dependencies = [
requests
pyyaml
enlighten
];

optional-dependencies = [
pytest
pytest-mock
];

passthru = {
pythonEnv = python.withPackages (_: (dependencies ++ optional-dependencies));
};
}
Loading