Skip to content

Commit

Permalink
added nix flake
Browse files Browse the repository at this point in the history
  • Loading branch information
youhaveme9 committed Sep 9, 2024
1 parent a934a25 commit 91756ed
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
nix_direnv_watch_file requirements.txt
use flake
54 changes: 54 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
description = "Python application flake";

inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";

mach-nix.url = "github:davhau/mach-nix";
};

outputs = { nixpkgs, mach-nix, flake-utils, ... }:
let
pythonVersion = "python39";
in
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
mach = mach-nix.lib.${system};

pythonApp = mach.buildPythonApplication ./.;
pythonAppEnv = mach.mkPython {
python = pythonVersion;
requirements = builtins.readFile ./requirements.txt;
};
pythonAppImage = pkgs.dockerTools.buildLayeredImage {
name = pythonApp.pname;
contents = [ pythonApp ];
config.Cmd = [ "${pythonApp}/bin/main" ];
};
in
rec
{
packages = {
image = pythonAppImage;

pythonPkg = pythonApp;
default = packages.pythonPkg;
};

apps.default = {
type = "app";
program = "${packages.pythonPkg}/bin/main";
};

devShells.default = pkgs.mkShellNoCC {
packages = [ pythonAppEnv ];

shellHook = ''
export PYTHONPATH="${pythonAppEnv}/bin/python"
'';
};
}
);
}
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pyfiglet==1.0.2
requests==2.31.0
rich==13.7.1
setuptools==74.1.2
11 changes: 11 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[metadata]
name = apkinfo
version = 1.0.0

[options]
packages = find:
install_requires =

[options.entry_points]
console_scripts =
main = apkinfo
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from setuptools import setup

setup()

0 comments on commit 91756ed

Please sign in to comment.