Skip to content

Commit 17bbeba

Browse files
johannwagneryuyuyureka
authored andcommitted
feat: Move packaging from poetry2nix to upstream packages
1 parent 3a9eecb commit 17bbeba

File tree

7 files changed

+348
-282
lines changed

7 files changed

+348
-282
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ __pycache__
33
venv*
44

55
.pytest_cache
6-
.idea
6+
.idea
7+
result

flake.lock

Lines changed: 5 additions & 119 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,18 @@
22
description = "wanda - WAN Data Aggregator";
33

44
inputs.flake-utils.url = "github:numtide/flake-utils";
5-
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
6-
inputs.poetry2nix = {
7-
url = "github:nix-community/poetry2nix";
8-
inputs.nixpkgs.follows = "nixpkgs";
9-
};
5+
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
106

11-
outputs = { self, nixpkgs, flake-utils, poetry2nix }:
7+
outputs = { self, nixpkgs, flake-utils }:
128
{
139
# Nixpkgs overlay providing the application
14-
overlay = nixpkgs.lib.composeManyExtensions [
15-
poetry2nix.overlays.default
16-
(final: prev: {
17-
# The application
18-
wanda = prev.poetry2nix.mkPoetryApplication {
19-
projectDir = with final.lib; cleanSourceWith {
20-
src = ./.;
21-
filter = path: type: !(hasSuffix ".nix" path) && baseNameOf path != ".nix";
22-
};
23-
};
24-
25-
# Used to run tests for wanda
26-
wandaTestEnv = prev.poetry2nix.mkPoetryEnv {
27-
projectDir = ./.;
28-
};
29-
30-
wandaNixosTest = final.nixosTest (import ./nixos-test.nix);
31-
})
32-
];
10+
overlay = (final: prev: let
11+
pyprojectFile = builtins.fromTOML (builtins.readFile ./pyproject.toml);
12+
# We absolutly want to ship our own deps, so we use our own python and our own python3Packages.
13+
pkgs = nixpkgs.legacyPackages.${final.stdenv.hostPlatform.system};
14+
in {
15+
wanda = pkgs.python3.pkgs.callPackage ./package.nix { wanda-version = pyprojectFile.tool.poetry.version; };
16+
});
3317
} // (flake-utils.lib.eachDefaultSystem (system:
3418
let
3519
pkgs = import nixpkgs {
@@ -39,14 +23,17 @@
3923
in
4024
{
4125
packages = {
42-
inherit (pkgs) wanda wandaNixosTest;
26+
inherit (pkgs) wanda;
4327
default = pkgs.wanda;
4428
};
29+
30+
checks = {
31+
wandaTest = pkgs.callPackage ./nixos-test.nix { inherit self; };
32+
};
4533

4634
devShell = pkgs.mkShell {
4735
buildInputs = with pkgs; [
4836
bgpq4
49-
wanda.dependencyEnv
5037
];
5138
};
5239
}));

nixos-test.nix

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
{ lib, pkgs, ... }: {
2-
name = "peering-manager";
1+
{ lib, pkgs, ... }:
2+
3+
pkgs.nixosTest {
4+
name = "wanda";
35

46
meta = with lib.maintainers; {
57
maintainers = [ yuka ];
@@ -12,7 +14,7 @@
1214
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
1315
'';
1416
};
15-
environment.systemPackages = with pkgs; [ wanda wandaTestEnv bgpq4 ];
17+
environment.systemPackages = with pkgs; [ wanda wanda.pythonEnv ];
1618
};
1719

1820
testScript = { nodes }: let

package.nix

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{ python,
2+
buildPythonApplication,
3+
poetry-core,
4+
requests,
5+
pyyaml,
6+
enlighten,
7+
pytest,
8+
pytest-mock,
9+
wanda-version,
10+
}:
11+
12+
buildPythonApplication rec {
13+
version = wanda-version;
14+
15+
pname = "wanda";
16+
pyproject = true;
17+
18+
src = ./.;
19+
20+
build-system = [
21+
poetry-core
22+
];
23+
24+
dependencies = [
25+
requests
26+
pyyaml
27+
enlighten
28+
];
29+
30+
optional-dependencies = [
31+
pytest
32+
pytest-mock
33+
];
34+
35+
passthru = {
36+
pythonEnv = python.withPackages (_: (dependencies ++ optional-dependencies));
37+
};
38+
}

0 commit comments

Comments
 (0)