From 6bad8af2dbbfcf00a6d5cf2dcdfd881c93e6b727 Mon Sep 17 00:00:00 2001 From: Nathan Henrie Date: Sun, 7 Jul 2024 06:27:14 -0600 Subject: [PATCH] Use nix --- flake.lock | 27 +++++++++++++++++++++++ flake.nix | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..3abab16 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1720181791, + "narHash": "sha256-i4vJL12/AdyuQuviMMd1Hk2tsGt02hDNhA0Zj1m16N8=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "4284c2b73c8bce4b46a6adf23e16d9e2ec8da4bb", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "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 0000000..bda339c --- /dev/null +++ b/flake.nix @@ -0,0 +1,65 @@ +{ + description = "Flake for https://github.com/n8henrie/fastcli"; + + inputs.nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + outputs = + { self, nixpkgs }: + let + systems = [ + "aarch64-darwin" + "x86_64-darwin" + "x86_64-linux" + "aarch64-linux" + ]; + eachSystem = + with nixpkgs.lib; + f: foldAttrs mergeAttrs { } (map (s: mapAttrs (_: v: { ${s} = v; }) (f s)) systems); + in + eachSystem ( + system: + let + pkgs = nixpkgs.legacyPackages.${system}; + pname = "fastcli"; + in + { + packages = { + default = pkgs.python311.withPackages (_: [ self.packages.${system}.${pname} ]); + ${pname} = pkgs.callPackage ( + { lib, python3Packages }: + python3Packages.buildPythonPackage { + inherit pname; + version = builtins.elemAt (lib.splitString "\"" ( + lib.findSingle (val: builtins.match "^__version__ = \".*\"$" val != null) (abort "none") + (abort "multiple") + (lib.splitString "\n" (builtins.readFile ./${pname}/__init__.py)) + )) 1; + src = lib.cleanSource ./.; + pyproject = true; + nativeBuildInputs = with python3Packages; [ pythonRelaxDepsHook ]; + build-system = [ python3Packages.setuptools-scm ]; + dependencies = with python3Packages; [ aiohttp ]; + pythonRelaxDeps = [ "aiohttp" ]; + } + ) { }; + }; + + devShells.${system}.default = pkgs.mkShell { + buildInputs = with pkgs; [ + python38 + python39 + python310 + python311 + (python312.withPackages ( + ps: + propagatedBuildInputs + ++ (with ps; [ + mypy + pytest + tox + ]) + )) + ]; + }; + } + ); +}