From 6df2ef639806567bf7ef9b3b50bef08b9cfb7e3a Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Sun, 31 Mar 2024 23:40:32 +0200 Subject: refactor({python,markdown}): Also move them to the templates diretory --- templates/unmaintained/python/flake.nix | 67 +++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 templates/unmaintained/python/flake.nix (limited to 'templates/unmaintained/python/flake.nix') diff --git a/templates/unmaintained/python/flake.nix b/templates/unmaintained/python/flake.nix new file mode 100644 index 0000000..36c7478 --- /dev/null +++ b/templates/unmaintained/python/flake.nix @@ -0,0 +1,67 @@ +{ + description = ""; # TODO: fill this out + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + + mach-nix.url = "github:davhau/mach-nix"; + }; + + outputs = { + self, + nixpkgs, + mach-nix, + flake-utils, + ... + }: let + pythonVersion = "python39"; # TODO: update if necessary + 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 { + packages = { + image = pythonAppImage; + pythonPkg = pythonApp; + + default = self.packages.pythonPkg; + }; + + apps.default = { + type = "app"; + program = "${self.packages.pythonPkg}/bin/main"; + }; + + devShells.default = pkgs.mkShell { + packages = with pkgs; [ + pythonAppEnv + black + ruff + python310Packages.python-lsp-server + gnat + ]; + + env = { + LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [ + pkgs.stdenv.cc.cc + ]; + + PYTHONPATH = "${pythonAppEnv}/bin/python"; + }; + }; + } + ); +} -- cgit 1.4.1