Skip to content

Instantly share code, notes, and snippets.

@trickster
Created March 12, 2023 06:29
Show Gist options
  • Save trickster/c3fd5ae2f9b79faad11a8cbd6ea49096 to your computer and use it in GitHub Desktop.
Save trickster/c3fd5ae2f9b79faad11a8cbd6ea49096 to your computer and use it in GitHub Desktop.
python flake
{
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