{ description = "Application packaged using poetry2nix"; inputs = { flake-utils.url = "github:numtide/flake-utils"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11"; poetry2nix = { url = "github:nix-community/poetry2nix"; inputs.nixpkgs.follows = "nixpkgs"; }; mnotify = { url = "git+file:../tasting/mnotify"; inputs.nixpkgs.follows = "nixpkgs"; }; }; outputs = { self, nixpkgs, flake-utils, poetry2nix, mnotify }: flake-utils.lib.eachDefaultSystem (system: let # see https://github.com/nix-community/poetry2nix/tree/master#api for more functions and examples. pkgs = nixpkgs.legacyPackages.${system}; inherit (poetry2nix.lib.mkPoetry2Nix { inherit pkgs; }) mkPoetryApplication cleanPythonSources; in { packages = rec { myapp = mkPoetryApplication { projectDir = self; }; default = self.packages.${system}.myapp; env = default.dependencyEnv; docker = pkgs.dockerTools.buildImage { name = "sms2matrix"; tag = "latest"; copyToRoot = pkgs.buildEnv { name = "image-root"; paths = [ default.dependencyEnv mnotify.packages.${system}.default pkgs.dockerTools.fakeNss # for mnotify pkgs.cacert (pkgs.lib.fileset.toSource { root = ./.; fileset = pkgs.lib.fileset.fromSource (cleanPythonSources { src = ./app; }); }) ]; pathsToLink = [ "/bin" "/app" "/etc" ]; }; config = { Cmd = [ "/bin/uvicorn" "app.main:app" "--host" "0.0.0.0" ]; #"/bin/python" ]; WorkingDir = "/app"; Volumes = { "/app" = { }; }; }; }; }; devShells.default = pkgs.mkShell { inputsFrom = [ self.packages.${system}.myapp ]; packages = [ pkgs.poetry ]; }; }); }