diff --git a/flake.lock b/flake.lock index edec07a..1c09934 100644 --- a/flake.lock +++ b/flake.lock @@ -1,23 +1,5 @@ { "nodes": { - "flake-utils": { - "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1681202837, - "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "cfacdce06f30d2b68473a46042957675eebb3401", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, "nixpkgs": { "locked": { "lastModified": 1681303793, @@ -36,24 +18,8 @@ }, "root": { "inputs": { - "flake-utils": "flake-utils", "nixpkgs": "nixpkgs" } - }, - "systems": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 514c2e0..163117b 100644 --- a/flake.nix +++ b/flake.nix @@ -2,47 +2,75 @@ description = "A very basic python flake template, providing a devshell."; inputs = { - nixpkgs.url = github:nixos/nixpkgs/nixos-unstable; - flake-utils.url = github:numtide/flake-utils; + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; }; - outputs = { self, nixpkgs, flake-utils }: - flake-utils.lib.eachDefaultSystem ( - system: - let - pkgs = nixpkgs.legacyPackages.${system}; - pyPkgs = pkgs.python310Packages; - customPython = pkgs.python39.buildEnv.override { - extraLibs = with pyPkgs; [ - ipython - setuptools - requests - ]; - }; - packageName = with builtins; head (match "^.*name[[:space:]]*=[[:space:]][\"]([^[:space:]]*)[\"][,].*$" (readFile ./setup.py)); - version = with builtins; head (match "^.*version[[:space:]]*=[[:space:]][\"]([^[:space:]]*)[\"][,].*$" (readFile ./setup.py)); + outputs = { self, nixpkgs }: + let + supportedSystems = + [ "aarch64-linux" "x86_64-linux" "aarch64-darwin" "x86_64-darwin" ]; + + forAllSystems = + nixpkgs.lib.genAttrs supportedSystems; + + nixpkgsFor = + forAllSystems (system: + import nixpkgs { + inherit system; + } + ); + + pyPkgs = system: + nixpkgsFor.${system}.python310Packages; + + packageName = with builtins; + head (match "^.*name[[:space:]]*=[[:space:]][\"]([^[:space:]]*)[\"][,].*$" (readFile ./setup.py)); + + version = with builtins; + head (match "^.*version[[:space:]]*=[[:space:]][\"]([^[:space:]]*)[\"][,].*$" (readFile ./setup.py)); + in { + packages = + forAllSystems (system: + let + pkgs = + nixpkgsFor.${system}; + + in + { + default = (pyPkgs system).buildPythonPackage { + pname = packageName; + inherit version; + src = ./.; + doCheck = false; + + propagatedBuildInputs = [ (pyPkgs system).requests ]; + meta = { + homepage = "https://github.com/jeslie0/npm-lockfile-fix"; + description = ""; + license = pkgs.lib.licenses.mit; + }; + }; + } + ); + + devShells = + forAllSystems (system: + let + pkgs = + nixpkgsFor.${system}; + in + { + default = + pkgs.mkShell { + packages = with pkgs; + [ python310Packages.python-lsp-server ]; - packages.default = pyPkgs.buildPythonPackage { - pname = packageName; - inherit version; - src = ./.; - doCheck = false; - - propagatedBuildInputs = [ pyPkgs.requests ]; - meta = { - homepage = "https://github.com/jeslie0/npm-lockfile-fix"; - description = ""; - license = pkgs.lib.licenses.mit; - }; - }; - - devShell = pkgs.mkShell { - packages = with pkgs; - [ python310Packages.python-lsp-server ]; - inputsFrom = [ self.packages.${system}.default ]; - }; - } - ); + inputsFrom = + [ self.packages.${system}.default ]; + }; + } + ); + }; }