From 36ddc5925320cd072eb597c4b4b0905198f25fe1 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Mon, 29 Apr 2024 00:15:03 +0200 Subject: [PATCH] flake.nix: add support for more architectures + misc --- flake.lock | 8 ++++---- flake.nix | 47 +++++++++++++++++++++++++++++++---------------- 2 files changed, 35 insertions(+), 20 deletions(-) diff --git a/flake.lock b/flake.lock index 40d199a..2fc7d0b 100644 --- a/flake.lock +++ b/flake.lock @@ -2,16 +2,16 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1683014792, - "narHash": "sha256-6Va9iVtmmsw4raBc3QKvQT2KT/NGRWlvUlJj46zN8B8=", + "lastModified": 1714272655, + "narHash": "sha256-3/ghIWCve93ngkx5eNPdHIKJP/pMzSr5Wc4rNKE1wOc=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "1a411f23ba299db155a5b45d5e145b85a7aafc42", + "rev": "12430e43bd9b81a6b4e79e64f87c624ade701eaf", "type": "github" }, "original": { "id": "nixpkgs", - "ref": "nixos-unstable", + "ref": "nixos-23.11", "type": "indirect" } }, diff --git a/flake.nix b/flake.nix index c3cdd6a..904b67b 100644 --- a/flake.nix +++ b/flake.nix @@ -1,23 +1,42 @@ { - # inputs.nixpkgs.url = "nixpkgs/nixos-22.11"; - inputs.nixpkgs.url = "nixpkgs/nixos-unstable"; + inputs.nixpkgs.url = "nixpkgs/nixos-23.11"; outputs = { self, nixpkgs }: let - system = "x86_64-linux"; - pkgs = nixpkgs.legacyPackages.${system}; - inherit (pkgs) lib; + systems = [ + "x86_64-linux" + "aarch64-linux" + "x86_64-darwin" + "aarch64-darwin" + ]; + forAllSystems = f: nixpkgs.lib.genAttrs systems (system: let + pkgs = nixpkgs.legacyPackages.${system}; + in f system pkgs); in { - apps.${system} = let - app = program: { + apps = forAllSystems (system: pkgs: let + mkApp = program: { type = "app"; inherit program; }; in { - default = self.apps.${system}.worblehat; - worblehat = app "${self.packages.${system}.worblehat}/bin/worblehat"; - }; + default = mkApp self.packages.${system}.default; + }); - packages.${system} = { + devShells = forAllSystems (_: pkgs: { + default = pkgs.mkShell { + packages = with pkgs; [ + poetry + sqlite + ]; + shellHook = '' + poetry install + poetry shell && exit + ''; + }; + }); + + overlays.default = final: prev: self.packages.${final.system}; + + packages = forAllSystems (system: pkgs: { default = self.packages.${system}.worblehat; worblehat = with pkgs.python3Packages; buildPythonPackage { pname = "worblehat"; @@ -38,10 +57,6 @@ sqlalchemy ]; }; - }; - - devShells.${system}.default = pkgs.mkShell { - packages = with pkgs; [ poetry sqlite ]; - }; + }); }; }