Created
March 12, 2023 06:29
-
-
Save trickster/c3fd5ae2f9b79faad11a8cbd6ea49096 to your computer and use it in GitHub Desktop.
python flake
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
description = "Python dev shell"; | |
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, flake-utils, mach-nix, ... }: | |
flake-utils.lib.eachDefaultSystem | |
(system: | |
let | |
pkgs = import nixpkgs { | |
inherit system; | |
}; | |
pythonVersion = "python39"; | |
mach = mach-nix.lib.${system}; | |
requirements = builtins.readFile ./requirements.txt; | |
pythonEnv = mach.mkPython { | |
python = pythonVersion; | |
inherit requirements; | |
}; | |
dockerImage = mach.mkDockerImage { | |
inherit requirements; | |
}; | |
in | |
with pkgs; | |
{ | |
packages = { | |
image = dockerImage.override { | |
name = "pythonapp"; | |
tag = "latest"; | |
contents = [ | |
([ pythonEnv ] ++ [ pkgs.bash ]) | |
]; | |
}; | |
}; | |
devShells.default = mkShell { | |
buildInputs = [ | |
dive | |
google-cloud-sdk | |
pythonEnv | |
]; | |
}; | |
} | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment