From a4883480ae278c874a9a16782bf233bf70b87243 Mon Sep 17 00:00:00 2001 From: Tim Van Baak Date: Tue, 20 Jun 2023 18:46:41 +0000 Subject: [PATCH] Add nixos module and package overlay --- README.md | 2 ++ flake.nix | 55 +++++++++++++++++++++++++++++++++++-------------------- 2 files changed, 37 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 20886b7..f20afb6 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ This repo contains programs that act as `intake` feed sources. +The provided NixOS module adds the default overlay to `nixpkgs`, providing each feed source program individually as well as the `intakeSources` package that provides all of them together. + ## intake-rss A feed source that wraps an RSS or Atom feed. diff --git a/flake.nix b/flake.nix index a68e3ef..c7e863a 100644 --- a/flake.nix +++ b/flake.nix @@ -6,31 +6,20 @@ outputs = { self, nixpkgs }: let system = "x86_64-linux"; - pkgs = nixpkgs.legacyPackages.${system}; - pypkgs = pkgs.python38Packages; - pythonPackage = name: path: deps: pypkgs.buildPythonPackage { - inherit name; - src = builtins.path { inherit name path; }; - format = "pyproject"; - propagatedBuildInputs = [ pypkgs.setuptools ] ++ deps; - }; in { - packages.${system} = { - default = pkgs.symlinkJoin { - name = "intake-sources"; - paths = [ - self.packages.${system}.intake-rss - self.packages.${system}.intake-reddit - self.packages.${system}.intake-hackernews - ]; - }; - intake-rss = pythonPackage "intake-rss" ./intake-rss [ pypkgs.feedparser ]; - intake-reddit = pythonPackage "intake-reddit" ./intake-reddit []; - intake-hackernews = pythonPackage "intake-hackernews" ./intake-hackernews []; + packages.${system} = let + pkgs = (import nixpkgs { + inherit system; + overlays = [ self.overlays.default ]; + }); + in { + default = pkgs.intakeSources; + inherit (pkgs) intake-rss intake-reddit intake-hackernews; }; devShells.${system} = { python = let + pkgs = nixpkgs.legacyPackages.${system}; pythonEnv = pkgs.python38.withPackages (pypkgs: with pypkgs; [ black feedparser ]); in pkgs.mkShell { packages = [ pythonEnv ]; @@ -39,6 +28,32 @@ ''; }; }; + + overlays.default = final: prev: let + pythonPackage = name: path: deps: final.python38Packages.buildPythonPackage { + inherit name; + src = builtins.path { inherit name path; }; + format = "pyproject"; + propagatedBuildInputs = [ final.python38Packages.setuptools ] ++ deps; + }; + in + { + intakeSources = final.symlinkJoin { + name = "intake-sources"; + paths = [ + final.intake-rss + final.intake-reddit + final.intake-hackernews + ]; + }; + intake-rss = pythonPackage "intake-rss" ./intake-rss [ final.python38Packages.feedparser ]; + intake-reddit = pythonPackage "intake-reddit" ./intake-reddit []; + intake-hackernews = pythonPackage "intake-hackernews" ./intake-hackernews []; + }; + + nixosModules.default = { + nixpkgs.overlays = [ self.overlays.default ]; + }; }; }