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

1
python/.envrc Normal file
View file

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

127
python/flake.lock generated 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
'';
};
};
});
}