1{
2 lib,
3 buildNpmPackage,
4 fetchFromGitHub,
5 callPackage,
6 testers,
7 runCommand,
8 writeText,
9 nix-update-script,
10 lessc,
11}:
12
13buildNpmPackage rec {
14 pname = "lessc";
15 version = "4.2.2";
16
17 src = fetchFromGitHub {
18 owner = "less";
19 repo = "less.js";
20 rev = "v${version}";
21 hash = "sha256-vO/1laFb1yC+OESXTx9KuGdwSNC9Iv49F3V7kfXnyJU=";
22 };
23 sourceRoot = "${src.name}/packages/less";
24
25 npmDepsHash = "sha256-3GlngmaxcUGXSv+ZwN2aovwEqcek6FJ1ZaL5KpjwNn4=";
26
27 postPatch = ''
28 sed -i ./package.json \
29 -e '/@less\/test-data/d' \
30 -e '/@less\/test-import-module/d'
31 '';
32
33 env.PUPPETEER_SKIP_DOWNLOAD = 1;
34
35 passthru = {
36 updateScript = nix-update-script { };
37 plugins = callPackage ./plugins { };
38 wrapper = callPackage ./wrapper { };
39 withPlugins = fn: lessc.wrapper.override { plugins = fn lessc.plugins; };
40 tests = {
41 version = testers.testVersion { package = lessc; };
42
43 simple = testers.testEqualContents {
44 assertion = "lessc compiles a basic less file";
45 expected = writeText "expected" ''
46 body h1 {
47 color: red;
48 }
49 '';
50 actual =
51 runCommand "actual"
52 {
53 nativeBuildInputs = [ lessc ];
54 base = writeText "base" ''
55 @color: red;
56 body {
57 h1 {
58 color: @color;
59 }
60 }
61 '';
62 }
63 ''
64 lessc $base > $out
65 '';
66 };
67 };
68 };
69
70 meta = {
71 homepage = "https://github.com/less/less.js";
72 description = "Dynamic stylesheet language";
73 mainProgram = "lessc";
74 license = lib.licenses.asl20;
75 maintainers = with lib.maintainers; [ lelgenio ];
76 };
77}