Add Python env

This commit is contained in:
Luc Perkins 2022-07-31 22:33:11 +02:00
parent 2fcdc9353f
commit a71da05d19
No known key found for this signature in database
GPG key ID: 4F102D0C16E232F2
5 changed files with 174 additions and 0 deletions

View file

@ -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

View file

@ -130,6 +130,11 @@
description = "Protobuf development environment";
};
python = {
path = ./python;
description = "Python development environment";
};
ruby = {
path = ./ruby;
description = "Ruby development environment";

1
python/.envrc Normal file
View file

@ -0,0 +1 @@
use flake .

127
python/flake.lock Normal file
View file

@ -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
}

30
python/flake.nix Normal file
View file

@ -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
'';
};
};
});
}