From a69953c97dda9ebb71ebcc81a5094be1e6e6792a Mon Sep 17 00:00:00 2001 From: Yusuf Bera Ertan Date: Sat, 15 May 2021 22:23:14 +0300 Subject: [PATCH] feat: use nixpkgs input, add apps for easily running examples --- examples/serve.nix | 2 +- flake.lock | 43 +++++++++++++++++++++++++++++ flake.nix | 68 ++++++++++++++++++++++++++++------------------ 3 files changed, 86 insertions(+), 27 deletions(-) create mode 100644 flake.lock diff --git a/examples/serve.nix b/examples/serve.nix index 7816206..ba309c0 100644 --- a/examples/serve.nix +++ b/examples/serve.nix @@ -1,4 +1,4 @@ -{ tags, pkgsLib, pkgs ? import { overlays = [ pkgsLib ]; } }: +{ tags, pkgs }: with pkgs.htmlNix; let index = with tags; diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..f354d95 --- /dev/null +++ b/flake.lock @@ -0,0 +1,43 @@ +{ + "nodes": { + "flakeUtils": { + "locked": { + "lastModified": 1620759905, + "narHash": "sha256-WiyWawrgmyN0EdmiHyG2V+fqReiVi8bM9cRdMaKQOFg=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b543720b25df6ffdfcf9227afafc5b8c1fabfae8", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1621084586, + "narHash": "sha256-raHuJ7ohDLDPqohJzZxhaER7sSh4/1xR6YcUYMj3c3E=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "e83b3f3394834c41c0d25017f6808d65c3d6f880", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flakeUtils": "flakeUtils", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix index b72465f..d47c4d2 100644 --- a/flake.nix +++ b/flake.nix @@ -1,33 +1,49 @@ { - outputs = { self }: - let - utils = import ./utils.nix; + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + flakeUtils.url = "github:numtide/flake-utils"; + }; - lib = { - tags = import ./tags.nix { inherit utils; }; + outputs = { self, flakeUtils, nixpkgs }: + flakeUtils.lib.eachDefaultSystem (system: + let + utils = import ./utils.nix; - templaters = { - basic = import ./templaters/basic.nix; + lib = { + tags = import ./tags.nix { inherit utils; }; + + templaters = { + basic = import ./templaters/basic.nix; + }; }; - }; - pkgsLib = (final: prev: { - htmlNix = import ./pkgs-lib.nix { pkgs = prev; utils = utils // { inherit (lib) tags; }; }; + pkgsLib = (final: prev: { + htmlNix = import ./pkgs-lib.nix { pkgs = prev; utils = utils // { inherit (lib) tags; }; }; + }); + + pkgs = import nixpkgs { inherit system; overlays = [ pkgsLib ]; }; + in + { + inherit lib; + + overlays = { + inherit pkgsLib; + }; + + apps = with flakeUtils.lib; { + site = mkApp { + drv = let inherit (pkgs) htmlNix; in + htmlNix.mkServeFromSite (htmlNix.mkSiteFrom { src = ./examples/site; templater = lib.templaters.basic; }); + name = "serve"; + }; + basicServe = mkApp { + drv = import ./examples/serve.nix { inherit (lib) tags; inherit pkgs; }; + name = "serve"; + }; + }; + + examples = { + tags = import ./examples/tags.nix lib.tags; + }; }); - in - { - inherit lib; - - overlays = { - inherit pkgsLib; - }; - - examples = { - siteServe = - let inherit (import { overlays = [ pkgsLib ]; }) htmlNix; in - htmlNix.mkServeFromSite (htmlNix.mkSiteFrom { src = ./examples/site; templater = lib.templaters.basic; }); # needs --impure - tags = import ./examples/tags.nix lib.tags; - serve = import ./examples/serve.nix { inherit (lib) tags; inherit pkgsLib; }; # needs --impure - }; - }; }