diff options
| author | Quentin Aristote <quentin@aristote.fr> | 2022-11-16 00:32:50 +0100 |
|---|---|---|
| committer | Quentin Aristote <quentin@aristote.fr> | 2022-11-16 00:32:50 +0100 |
| commit | 8f829f172b670702cebcbc8dac62271ba98a94c6 (patch) | |
| tree | b01fddeaed96f23a97b24ded91cd204b822c02b7 | |
| parent | 8d45a910b271cf6bfa26c0ed4007392635866dc8 (diff) | |
clean css with uncss at build time
| -rw-r--r-- | default.nix | 37 | ||||
| -rw-r--r-- | flake.lock | 32 | ||||
| -rw-r--r-- | flake.nix | 28 | ||||
| -rw-r--r-- | pkgs/default.nix | 5 | ||||
| -rw-r--r-- | pkgs/line-awesome-css.nix | 2 |
5 files changed, 77 insertions, 27 deletions
diff --git a/default.nix b/default.nix index cd1bdfe..aefee61 100644 --- a/default.nix +++ b/default.nix @@ -30,21 +30,34 @@ let in pkgs.callPackage ({ # Packages - line-awesome, line-awesome-css, yuicompressor, + line-awesome, line-awesome-css, uncss, yuicompressor, # Source files index-html ? indexHTML, classless-css ? classlessCSS, files ? data.files , icon ? ./static/icon.png }: - let compress = "'${yuicompressor}/bin/yuicompressor'"; + let + compress = "'${yuicompressor}/bin/yuicompressor'"; + clean = "'${uncss}/bin/uncss'"; in pkgs.runCommand "webpage" { } '' - mkdir "$out" - ln -sT "${index-html}" "$out/index.html" - mkdir "$out/static" - ln -sT "${icon}" "$out/static/icon.png" - ln -sT "${files}" "$out/static/files" - mkdir -p "$out/static/css" - ${compress} "${classless-css}" --type css -o "$out/static/css/classless.min.css" - mkdir -p "$out/static/css/fonts/line-awesome" - ln -sT "${line-awesome}/share/fonts/woff2" "$out/static/css/fonts/line-awesome/webfonts" - ${compress} "${line-awesome-css}" --type css -o "$out/static/css/fonts/line-awesome/line-awesome.min.css" + set -o xtrace + mkdir "$out" && pushd "$_" + ln -sT "${index-html}" index.html + popd + + mkdir "$out/static" && pushd "$_" + ln -sT "${icon}" icon.png + ln -sT "${files}" files + popd + + mkdir -p "$out/static/css" && pushd "$_" + ${clean} "${index-html}" --stylesheets file://${classless-css} \ + | ${compress} --type css >classless.min.css + popd + + mkdir -p "$out/static/css/fonts/line-awesome" && pushd "$_" + ln -sT "${line-awesome}/share/fonts/woff2" webfonts + ${clean} "${index-html}" --stylesheets file://${line-awesome-css} \ + | ${compress} --type css >line-awesome.min.css + popd + '') { } @@ -39,11 +39,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1668266328, - "narHash": "sha256-+nAW+XR8nswyEnt5IkQlkrz9erTcQWBVLkhtNHxckFw=", + "lastModified": 1668531822, + "narHash": "sha256-rNt2SphDCQTbAgWBX9ZCMIn5ISxeb0l6b6kRLvzbFVo=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "5ca8e2e9e1fa5e66a749b39261ad6bd0e07bc87f", + "rev": "97b8d9459f7922ce0e666113a1e8e6071424ae16", "type": "github" }, "original": { @@ -55,7 +55,31 @@ "inputs": { "data": "data", "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "uncss": "uncss" + } + }, + "uncss": { + "inputs": { + "flake-utils": [ + "flake-utils" + ], + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1668549614, + "narHash": "sha256-1C2qBUB5Wz7DPPYR4DQi8hh2xoFA89WgEfdI2bsv4pI=", + "owner": "qaristote", + "repo": "uncss", + "rev": "0e5a335e85ec85ff6f764ea87adb5c7da83b0924", + "type": "github" + }, + "original": { + "owner": "qaristote", + "repo": "uncss", + "type": "github" } } }, @@ -1,15 +1,24 @@ { description = "Source code of Quentin Aristote's personal webpage."; - inputs.data = { - url = "github:qaristote/info"; - inputs = { - nixpkgs.follows = "/nixpkgs"; - flake-utils.follows = "/flake-utils"; + inputs = { + data = { + url = "github:qaristote/info"; + inputs = { + nixpkgs.follows = "/nixpkgs"; + flake-utils.follows = "/flake-utils"; + }; + }; + uncss = { + url = "github:qaristote/uncss"; + inputs = { + nixpkgs.follows = "/nixpkgs"; + flake-utils.follows = "/flake-utils"; + }; }; }; - outputs = { self, nixpkgs, flake-utils, data }: + outputs = { self, nixpkgs, flake-utils, data, uncss }: { lib = import ./lib { inherit (nixpkgs) lib; }; overlays.default = final: prev: import ./pkgs { pkgs = final; }; @@ -17,10 +26,13 @@ let pkgs = import nixpkgs { inherit system; - overlays = [ self.overlays.default ]; + overlays = [ + self.overlays.default + (final: prev: { uncss = uncss.packages."${system}".default; }) + ]; }; in { - packages = import ./pkgs { inherit pkgs; } // { + packages = import ./pkgs { inherit pkgs system; } // { webpage = import ./default.nix { inherit pkgs; inherit (self.lib.pp) html; diff --git a/pkgs/default.nix b/pkgs/default.nix index af2ab5e..5f8048d 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -1,5 +1,6 @@ -{ pkgs }: +{ pkgs, system ? builtins.currentSystem }: { - line-awesome-css = pkgs.callPackage ./line-awesome-css.nix {}; + line-awesome-css = pkgs.callPackage ./line-awesome-css.nix { }; + # uncss = (import ./uncss { inherit pkgs system; }).package; } diff --git a/pkgs/line-awesome-css.nix b/pkgs/line-awesome-css.nix index a00e128..0da29ac 100644 --- a/pkgs/line-awesome-css.nix +++ b/pkgs/line-awesome-css.nix @@ -1,6 +1,6 @@ { stdenv, fetchurl, fontsRelativeDirectory ? "./webfonts" }: stdenv.mkDerivation rec { - name = "line-awesome-css"; + name = "line-awesome.css"; version = "v1.2.1"; src = fetchurl { |
