switch pip python to mach-nix

This commit is contained in:
Noah Masur 2022-06-27 16:41:29 -04:00
parent 9b936105a0
commit b5f3e83f15
3 changed files with 75 additions and 27 deletions

View File

@ -1 +1 @@
use flake . --no-use-registries use flake

View File

@ -2,11 +2,11 @@
"nodes": { "nodes": {
"flake-utils": { "flake-utils": {
"locked": { "locked": {
"lastModified": 1653893745, "lastModified": 1642700792,
"narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=", "narHash": "sha256-XqHrk7hFb+zBvRg6Ghl+AZDq03ov6OshJLiSWOoX5es=",
"owner": "numtide", "owner": "numtide",
"repo": "flake-utils", "repo": "flake-utils",
"rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1", "rev": "846b2ae0fc4cc943637d3d1def4454213e203cba",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -15,25 +15,75 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgs": { "mach-nix": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs",
"pypi-deps-db": "pypi-deps-db"
},
"locked": { "locked": {
"lastModified": 1655779787, "lastModified": 1654084003,
"narHash": "sha256-Z5VL2AANN3Rk92xFs/3pPVyDQVTIcmNAIeTQNFOJnNE=", "narHash": "sha256-j/XrVVistvM+Ua+0tNFvO5z83isL+LBgmBi9XppxuKA=",
"owner": "NixOS", "owner": "DavHau",
"repo": "nixpkgs", "repo": "mach-nix",
"rev": "ce83dc760cd3428ce9938aa711a0c7c81f55c567", "rev": "7e14360bde07dcae32e5e24f366c83272f52923f",
"type": "github" "type": "github"
}, },
"original": { "original": {
"id": "mach-nix",
"ref": "3.5.0",
"type": "indirect"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1643805626,
"narHash": "sha256-AXLDVMG+UaAGsGSpOtQHPIKB+IZ0KSd9WS77aanGzgc=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "554d2d8aa25b6e583575459c297ec23750adb6cb",
"type": "github"
},
"original": {
"id": "nixpkgs",
"ref": "nixos-unstable",
"type": "indirect"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1656250965,
"narHash": "sha256-B5wj+k8uSe9YNijcTW7BHYAZzrzFQq5NMpmrnOGvxqo=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "9a17f325397d137ac4d219ecbd5c7f15154422f4",
"type": "github"
},
"original": {
"id": "nixpkgs",
"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" "type": "github"
} }
}, },
"root": { "root": {
"inputs": { "inputs": {
"flake-utils": "flake-utils", "mach-nix": "mach-nix",
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs_2"
} }
} }
}, },

View File

@ -1,20 +1,18 @@
{ {
description = "Python pip flake"; description = "Python pip flake";
inputs.flake-utils.url = "github:numtide/flake-utils"; inputs.mach-nix.url = "github:mach-nix/3.5.0";
inputs.nixpkgs.url = "github:NixOS/nixpkgs";
outputs = { self, nixpkgs, flake-utils }: outputs = { self, nixpkgs, mach-nix }@inp:
flake-utils.lib.eachDefaultSystem (system: let
let supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" ];
pkgs = import nixpkgs { inherit system; }; forAllSystems = f:
pythonEnv = pkgs.python310.withPackages (pypi: nixpkgs.lib.genAttrs supportedSystems
with pypi; (system: f system (import nixpkgs { inherit system; }));
[ in {
# Add requirements here devShell = forAllSystems (system: pkgs:
requests mach-nix.lib."${system}".mkPythonShell {
]); requirements = builtins.readFile ./requirements.txt;
in { });
devShells.default = pkgs.mkShell { buildInputs = [ pythonEnv ]; }; };
});
} }