Skip to content

Commit f5ef019

Browse files
fix(nix): Get python app version from new location (#23)
* feat(nix): use niv for channel management and versioning * fix(nix): extract version from src/beku/version.py since it is no longer extractable from the pyproject.toml file * Apply suggestions from code review Co-authored-by: Natalie Klestrup Röijezon <nat@nullable.se> * fix(nix): remove remaining references to pkg * chore(nix): remove unused dependency * chore(nix): extract version from src/beku/version.py via python --------- Co-authored-by: Natalie Klestrup Röijezon <nat@nullable.se>
1 parent 2f0174c commit f5ef019

File tree

5 files changed

+233
-8
lines changed

5 files changed

+233
-8
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nix/** linguist-generated

beku.nix

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
1-
{ python3 }:
2-
with python3;
1+
{ python3, runCommand, lib }:
32
let
4-
manifest = (pkgs.lib.importTOML ./pyproject.toml).project;
3+
# I wish there was a better way. If the command fails, it is very hard to see
4+
# that the problem is here. Perhaps there is some way to evaluate it in python
5+
# and reference __version__ directly?
6+
version = builtins.readFile (runCommand "foo" { src = [ ./src ]; } ''
7+
PYTHONPATH=$src ${python3}/bin/python -c 'import beku.version; print(beku.version.__version__)' > $out
8+
'');
9+
manifest = (lib.importTOML ./pyproject.toml).project;
510
in
6-
pkgs.buildPythonApplication {
11+
python3.pkgs.buildPythonApplication {
712
pname = manifest.name;
8-
version = manifest.version;
13+
# The version is no longer set in pyproject.toml, so we have to jump through
14+
# hoops to extract it from a python script.
15+
# version = manifest.version;
16+
inherit version;
917

1018
format = "pyproject";
1119

@@ -14,13 +22,14 @@ pkgs.buildPythonApplication {
1422
name = manifest.name;
1523
};
1624

17-
nativeBuildInputs = with pkgs; [
25+
nativeBuildInputs = with python3.pkgs; [
1826
setuptools
1927
];
2028

21-
propagatedBuildInputs = with pkgs; [
29+
propagatedBuildInputs = with python3.pkgs; [
2230
jinja2
2331
pyyaml
2432
];
2533
}
2634

35+

default.nix

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
{ pkgs ? import <nixpkgs> {} }:
1+
{ sources ? import ./nix/sources.nix # managed by https://github.com/nmattia/niv
2+
, nixpkgs ? sources.nixpkgs
3+
, pkgs ? import nixpkgs {}
4+
}:
25

36
{
47
beku = pkgs.callPackage ./beku.nix {};

nix/sources.json

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

nix/sources.nix

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

0 commit comments

Comments
 (0)