From a71da05d1960122ab03d883dc2633e17cd93bdf9 Mon Sep 17 00:00:00 2001 From: Luc Perkins Date: Sun, 31 Jul 2022 22:33:11 +0200 Subject: [PATCH] Add Python env --- README.md | 11 ++++ flake.nix | 5 ++ python/.envrc | 1 + python/flake.lock | 127 ++++++++++++++++++++++++++++++++++++++++++++++ python/flake.nix | 30 +++++++++++ 5 files changed, 174 insertions(+) create mode 100644 python/.envrc create mode 100644 python/flake.lock create mode 100644 python/flake.nix diff --git a/README.md b/README.md index 43180d6..d54163c 100644 --- a/README.md +++ b/README.md @@ -152,6 +152,13 @@ The sections below list what each template includes. In all cases, you're free t - The [Buf CLI][buf] 1.7.0 - [protoc][protobuf] 3.19.4 +### [`python`](./python/) + +- [Python] 3.11.0b4 +- [pip] +- [Virtualenv] +- [mach-nix] + ### [`ruby`](./ruby/) - [Ruby] 3.1.2p20, plus the standard Ruby tools (`bundle`, `gem`, etc.) @@ -204,6 +211,7 @@ All of the templates have only the root [flake](./flake.nix) as a flake input. T [kotlin]: https://kotlinlang.org [levant]: https://github.com/hashicorp/levant [lorri]: https://github.com/target/lorri +[mach-nix]: https://github.com/DavHau/mach-nix [maven]: https://maven.apache.org [mix]: https://elixir-lang.org/getting-started/mix-otp/introduction-to-mix.html [nim]: https://nim-lang.org @@ -220,9 +228,11 @@ All of the templates have only the root [flake](./flake.nix) as a flake input. T [nomad-pack]: https://github.com/hashicorp/nomad-pack [opa]: https://openpolicyagent.org [packer]: https://packer.io +[pip]: https://pypi.org/project/pip [phoenix]: https://phoenixframework.org [pnpm]: https://pnpm.io [protobuf]: https://developers.google.com/protocol-buffers +[python]: https://python.org [ruby]: https://ruby-lang.org [rust]: https://rust-lang.org [scala]: https://scala-lang.org @@ -230,6 +240,7 @@ All of the templates have only the root [flake](./flake.nix) as a flake input. T [sbt]: https://www.scala-sbt.org [terraform]: https://terraform.io [terragrunt]: https://terragrunt.gruntwork.io +[virtualenv]: https://pypi.org/project/virtualenv [vulnix]: https://github.com/flyingcircusio/vulnix [yarn]: https://yarnpkg.com [zig]: https://ziglang.org diff --git a/flake.nix b/flake.nix index f0144f5..e81d42b 100644 --- a/flake.nix +++ b/flake.nix @@ -130,6 +130,11 @@ description = "Protobuf development environment"; }; + python = { + path = ./python; + description = "Python development environment"; + }; + ruby = { path = ./ruby; description = "Ruby development environment"; diff --git a/python/.envrc b/python/.envrc new file mode 100644 index 0000000..a5dbbcb --- /dev/null +++ b/python/.envrc @@ -0,0 +1 @@ +use flake . diff --git a/python/flake.lock b/python/flake.lock new file mode 100644 index 0000000..4ddd91b --- /dev/null +++ b/python/flake.lock @@ -0,0 +1,127 @@ +{ + "nodes": { + "dev": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1659297620, + "narHash": "sha256-Uvb9YfBbnF4j+yA2y2EPWZapEdMwORPtsWFj3XpNYko=", + "owner": "the-nix-way", + "repo": "dev-templates", + "rev": "677e040123767876901e808ed6fb515b024558f5", + "type": "github" + }, + "original": { + "owner": "the-nix-way", + "repo": "dev-templates", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1656928814, + "narHash": "sha256-RIFfgBuKz6Hp89yRr7+NR5tzIAbn52h8vT6vXkYjZoM=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "7e2a3b3dfd9af950a856d66b0a7d01e3c18aa249", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "locked": { + "lastModified": 1642700792, + "narHash": "sha256-XqHrk7hFb+zBvRg6Ghl+AZDq03ov6OshJLiSWOoX5es=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "846b2ae0fc4cc943637d3d1def4454213e203cba", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "mach-nix": { + "inputs": { + "flake-utils": "flake-utils_2", + "nixpkgs": "nixpkgs_2", + "pypi-deps-db": "pypi-deps-db" + }, + "locked": { + "lastModified": 1659091740, + "narHash": "sha256-aNtnezQfUX1QS/bFno2H5661qIY/Rn7BmHnspuuyI+4=", + "owner": "DavHau", + "repo": "mach-nix", + "rev": "f15ea8677df951cb4fe608945fd98725dcd033b3", + "type": "github" + }, + "original": { + "owner": "DavHau", + "repo": "mach-nix", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1659295566, + "narHash": "sha256-ICqvf+Y782V3G2XHe6m43dBkTzv0Y1DPgXcffoNqa2Q=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "33ab71dafbaa6674243830e29b11e8b674f49a70", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1643805626, + "narHash": "sha256-AXLDVMG+UaAGsGSpOtQHPIKB+IZ0KSd9WS77aanGzgc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "554d2d8aa25b6e583575459c297ec23750adb6cb", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-unstable", + "type": "indirect" + } + }, + "pypi-deps-db": { + "flake": false, + "locked": { + "lastModified": 1643877077, + "narHash": "sha256-jv8pIvRFTP919GybOxXE5TfOkrjTbdo9QiCO1TD3ZaY=", + "owner": "DavHau", + "repo": "pypi-deps-db", + "rev": "da53397f0b782b0b18deb72ef8e0fb5aa7c98aa3", + "type": "github" + }, + "original": { + "owner": "DavHau", + "repo": "pypi-deps-db", + "type": "github" + } + }, + "root": { + "inputs": { + "dev": "dev", + "mach-nix": "mach-nix" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/python/flake.nix b/python/flake.nix new file mode 100644 index 0000000..dc0d0a0 --- /dev/null +++ b/python/flake.nix @@ -0,0 +1,30 @@ +{ + description = "A Nix-flake-based Protobuf development environment"; + + inputs = { dev.url = "github:the-nix-way/dev-templates"; mach-nix.url = "github:/DavHau/mach-nix"; }; + + outputs = { self, dev, mach-nix }: + let inherit (dev.lib) flake-utils nixpkgs; + in flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { inherit system; }; + inherit (pkgs) mkShell; + + python = pkgs.python311; + + machNix = mach-nix.defaultPackage.${system}; + + pythonTools = with pkgs; [ virtualenv ] ++ (with pkgs.python311Packages; [ pip ]); + nixTools = [ machNix ]; + in { + devShells = { + default = mkShell { + buildInputs = [ python ] ++ pythonTools ++ nixTools; + + shellHook = '' + ${python}/bin/python --version + ''; + }; + }; + }); +}