/ python / flake.nix
flake.nix
 1  {
 2    description = "A Nix-flake-based Python development environment";
 3  
 4    inputs = {
 5      nixpkgs.url = "github:NixOS/nixpkgs/release-22.11";
 6      flake-utils.url = "github:numtide/flake-utils";
 7      mach-nix.url = "github:/DavHau/mach-nix";
 8    };
 9  
10    outputs =
11      { self
12      , nixpkgs
13      , flake-utils
14      , mach-nix
15      }:
16  
17      flake-utils.lib.eachDefaultSystem (system:
18      let
19        overlays = [
20          (self: super: {
21            machNix = mach-nix.defaultPackage.${system};
22            python = super.python311;
23          })
24        ];
25  
26        pkgs = import nixpkgs { inherit overlays system; };
27      in
28      {
29        devShells.default = pkgs.mkShell {
30          packages = with pkgs; [ python machNix virtualenv ] ++
31            (with pkgs.python311Packages; [ pip ]);
32  
33          shellHook = ''
34            ${pkgs.python}/bin/python --version
35          '';
36        };
37      });
38  }