diff --git a/flake.nix b/flake.nix index 64ca0a3..44f5587 100644 --- a/flake.nix +++ b/flake.nix @@ -10,53 +10,55 @@ inherit system; }; nixite = import ./nixite/. {inherit pkgs;}; - in nixite // { + in + nixite + // { + packages.${system} = { + default = nixite.mkSite ( + nixite.site.applyStyle ./testing/src/style.css + (nixite.site.extractPaths { + "index.html" = with nixite.elems; (doc [ + [ + (title "Nixite") + ] + (main [ + (link "/blog" "blog") + (nixite.html.tag "img" {src = ./testing/src/favicon.png;} "") + (list [ + "item 1" + "item 2" + "item 3" + ]) + ]) + ]); + blog = { + "index.html" = with nixite.elems; (doc [ + [ + (title "A post") + ] + (main [ + (p '' + This is a post + '') + (link "/" "Home") + ]) + ]); + }; + }) + ); - packages.${system} = { - default = nixite.mkSite ( - nixite.site.applyStyle ./testing/src/style.css - (nixite.site.extractPaths { - "index.html" = with nixite.elems; (doc [ - [ - (title "Nixite") - ] - (main [ - (link "/blog" "blog") - (nixite.html.tag "img" {src = ./testing/src/favicon.png;} "") - (list [ - "item 1" - "item 2" - "item 3" - ]) - ]) - ]); - blog = { - "index.html" = with nixite.elems; (doc [ - [ - (title "A post") - ] - (main [ - (p '' - This is a post - '') - (link "/" "Home") - ]) - ]); - }; - })); + serve = self.serve self.packages.${system}.default; - serve = self.serve self.packages.${system}.default; - - test = let - test = import ./testing/import.nix; - in - pkgs.writeShellScriptBin "test" '' - ${test ./testing/md.test.nix} - ${test ./testing/html.test.nix} - ${test ./testing/elems.test.nix} - ${test ./testing/site.test.nix} - ${test ./testing/style.test.nix} - ''; + test = let + test = import ./testing/import.nix; + in + pkgs.writeShellScriptBin "test" '' + ${test ./testing/md.test.nix} + ${test ./testing/html.test.nix} + ${test ./testing/elems.test.nix} + ${test ./testing/site.test.nix} + ${test ./testing/style.test.nix} + ''; + }; }; - }; } diff --git a/nixite/site.nix b/nixite/site.nix index 59f2fc0..50bec05 100644 --- a/nixite/site.nix +++ b/nixite/site.nix @@ -32,19 +32,20 @@ in rec { getPaths = content: (builtins.listToAttrs (getPathsKV content)); - getPathsKV = path: - (if builtins.isPath path - then [ - { - name = baseNameOf path; - value = path; - } - ] - else if builtins.isAttrs path - then builtins.concatLists (map getPathsKV ( builtins.attrValues path )) - else if builtins.isList path - then builtins.concatLists (map getPathsKV path) - else []); + getPathsKV = path: ( + if builtins.isPath path + then [ + { + name = baseNameOf path; + value = path; + } + ] + else if builtins.isAttrs path + then builtins.concatLists (map getPathsKV (builtins.attrValues path)) + else if builtins.isList path + then builtins.concatLists (map getPathsKV path) + else [] + ); copyTo = prefix: site: builtins.toString ( diff --git a/testing/site.test.nix b/testing/site.test.nix index f3b9fe4..939a7f6 100644 --- a/testing/site.test.nix +++ b/testing/site.test.nix @@ -103,5 +103,4 @@ in }; }; }) - ]