From 2a32b7983dfbc624f2b00712460c8d7243c5d4bb Mon Sep 17 00:00:00 2001 From: Pim Kunis Date: Thu, 5 Oct 2023 15:49:14 +0200 Subject: [PATCH] add nix development environment --- .envrc | 1 + .gitignore | 1 + flake.lock | 27 +++++++++++++++++++++++++++ flake.nix | 24 ++++++++++++++++++++++++ setup.cfg | 2 +- 5 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 .envrc create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.envrc b/.envrc new file mode 100644 index 00000000..c4b17d79 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use_flake diff --git a/.gitignore b/.gitignore index c4b136e5..749be9f9 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ __pycache__ build/ dist/ pip-wheel-metadata/ +.direnv diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..47b2f9ec --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1696374741, + "narHash": "sha256-gt8B3G0ryizT9HSB4cCO8QoxdbsHnrQH+/BdKxOwqF0=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "8a4c17493e5c39769f79117937c79e1c88de6729", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..9dc04deb --- /dev/null +++ b/flake.nix @@ -0,0 +1,24 @@ +{ + description = "A Nix-flake-based Python development environment"; + + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05"; + + outputs = { self, nixpkgs }: + let + supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; + forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f { + pkgs = import nixpkgs { inherit system; }; + }); + in + { + devShells = forEachSupportedSystem ({ pkgs }: { + default = pkgs.mkShell { + packages = with pkgs; [ python311 virtualenv borgbackup ] ++ + (with pkgs.python311Packages; [ apprise pipx tox isort flexmock ]); + shellHook = '' + export PATH=~/.local/bin/:$PATH + ''; + }; + }); + }; +} diff --git a/setup.cfg b/setup.cfg index a5ba3a6a..8557c5b6 100644 --- a/setup.cfg +++ b/setup.cfg @@ -16,7 +16,7 @@ docstring-quotes = ''' profile=black known_first_party = borgmatic line_length = 100 -skip = .tox +skip = .tox,.direnv [codespell] skip = .git,.tox,build