diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..4254af5 --- /dev/null +++ b/.envrc @@ -0,0 +1,6 @@ +#TODO: Find way to inherit this part from direnv template +if ! has nix_direnv_version || ! nix_direnv_version 2.0.0; then + source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.0.0/direnvrc" "sha256-gMHKKyEOq/T0XmHKgz+pN+fUQC/1EKPAuOtYM95lLnU=" +fi +use flake +layout python3 diff --git a/.gitignore b/.gitignore index 3487a9f..4060d34 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,6 @@ __pycache__ build/* *.egg-info/* */_version.py +.direnv/* +dist/* +result diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..b0e3dc9 --- /dev/null +++ b/flake.lock @@ -0,0 +1,43 @@ +{ + "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1649676176, + "narHash": "sha256-OWKJratjt2RW151VUlJPRALb7OU2S5s+f0vLj4o1bHM=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "a4b154ebbdc88c8498a5c7b01589addc9e9cb678", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1652133925, + "narHash": "sha256-kfATGChLe9/fQVZkXN9G71JAVMlhePv1qDbaRKklkQs=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "51d859cdab1ef58755bd342d45352fc607f5e59b", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..a106b5e --- /dev/null +++ b/flake.nix @@ -0,0 +1,32 @@ +{ + description = "Flake to setup python virtualenv with direnv"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs?ref=nixpkgs-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + in rec { + packages = rec { + pythonEnv = pkgs.python3.withPackages( + ps: with ps; [ + virtualenv + ] + ); + annexremote = pkgs.python3Packages.buildPythonPackage rec { + pname = "annexremote"; + version = self.rev; + format = "pyproject"; + src = self; + }; + default = annexremote; + }; + + defaultPackage = packages.default; + devShell = packages.pythonEnv.env; + }); +}