From cb8b1cbb0b40c30a792332b95fc6638d8367e379 Mon Sep 17 00:00:00 2001 From: Stefan Date: Sat, 7 Dec 2024 02:56:42 +0000 Subject: [PATCH] Export lib.mkJekyllSite --- flake.nix | 67 ++++++++++++++++++++----------------------------------- 1 file changed, 24 insertions(+), 43 deletions(-) diff --git a/flake.nix b/flake.nix index b1356d6..a31fee6 100644 --- a/flake.nix +++ b/flake.nix @@ -1,25 +1,16 @@ { description = "Jekyll site builder flake"; - inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11"; flake-utils.url = "github:numtide/flake-utils"; }; - - outputs = { self, nixpkgs, flake-utils }: - flake-utils.lib.eachDefaultSystem (system: - let - pkgs = nixpkgs.legacyPackages.${system}; - - mkJekyllSite = { - pname, - version ? "1.0.0", - src, - gemset ? ./gemset.nix, - gemfile ? ./Gemfile, - lockfile ? ./Gemfile.lock - }: + outputs = { self, nixpkgs, flake-utils }: { + # Export mkJekyllSite directly at the top level + lib = { + mkJekyllSite = { pname, version ? "1.0.0", src, gemset ? ./gemset.nix, gemfile ? ./Gemfile, lockfile ? ./Gemfile.lock }: let + system = "x86_64-linux"; # Or make this an argument + pkgs = nixpkgs.legacyPackages.${system}; env = pkgs.bundlerEnv { name = pname; inherit (pkgs) ruby; @@ -28,52 +19,42 @@ in pkgs.stdenv.mkDerivation { inherit pname version src; - nativeBuildInputs = with pkgs; [ ruby_3_3 minify ]; - configurePhase = '' export HOME=$TMPDIR mkdir -p _site ''; - buildPhase = '' echo "Building site with Jekyll..." JEKYLL_ENV=production ${env}/bin/jekyll build --source . --destination _site --trace - echo 'Minifying HTML' minify --all --recursive --output . _site ''; - installPhase = '' mkdir -p $out cp -r _site/* $out/ ''; }; + }; - # Import tests - tests = import ./tests.nix { inherit pkgs mkJekyllSite; }; - - in - { - packages.default = mkJekyllSite { - pname = "my-jekyll-site"; - src = builtins.filterSource - (path: type: !(builtins.elem (baseNameOf path) [ - "_site" - ".jekyll-cache" - ".git" - "node_modules" - "result" - "vendor" - ])) - ./.; - }; - - lib.mkJekyllSite = mkJekyllSite; - - inherit (tests) checks apps; - }); + # Keep the per-system outputs for compatibility + packages = flake-utils.lib.eachDefaultSystem (system: { + default = self.lib.mkJekyllSite { + pname = "my-jekyll-site"; + src = builtins.filterSource + (path: type: !(builtins.elem (baseNameOf path) [ + "_site" + ".jekyll-cache" + ".git" + "node_modules" + "result" + "vendor" + ])) + ./.; + }; + }); + }; }