mirror of
https://github.com/nix-community/dream2nix.git
synced 2024-09-11 14:35:30 +03:00
improve override system
- add utils.satisfiesSemver (from poetry2nix) - nix-parsec add LICENSE from https://github.com/nprindle/nix-parsec/issues/5 - remove builtin overrides (moved to dreampkgs)
This commit is contained in:
parent
bccf3b25c7
commit
39db511926
26
flake.lock
26
flake.lock
@ -18,11 +18,11 @@
|
||||
"nix-parsec": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1614150306,
|
||||
"narHash": "sha256-h5fZgIhwvekg5WTNDdrV5EJ4zxXvlSqITmPVuz/OM+w=",
|
||||
"lastModified": 1635533376,
|
||||
"narHash": "sha256-/HrG0UPGnI5VdkhrNrpDiM2+nhdL6lD/bqyGtYv0QDE=",
|
||||
"owner": "nprindle",
|
||||
"repo": "nix-parsec",
|
||||
"rev": "a28e73fce98227cc46edfdbb8518697c0982e034",
|
||||
"rev": "1bf25dd9c5de1257a1c67de3c81c96d05e8beb5e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@ -62,12 +62,30 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"poetry2nix": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1632969109,
|
||||
"narHash": "sha256-jPDclkkiAy5m2gGLBlKgH+lQtbF7tL4XxBrbSzw+Ioc=",
|
||||
"owner": "nix-community",
|
||||
"repo": "poetry2nix",
|
||||
"rev": "aee8f04296c39d88155e05d25cfc59dfdd41cc77",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"ref": "1.21.0",
|
||||
"repo": "poetry2nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"mach-nix": "mach-nix",
|
||||
"nix-parsec": "nix-parsec",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"node2nix": "node2nix"
|
||||
"node2nix": "node2nix",
|
||||
"poetry2nix": "poetry2nix"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
17
flake.nix
17
flake.nix
@ -12,9 +12,19 @@
|
||||
|
||||
# required for builder nodejs/node2nix
|
||||
node2nix = { url = "github:svanderburg/node2nix"; flake = false; };
|
||||
|
||||
# required for utils.satisfiesSemver
|
||||
poetry2nix = { url = "github:nix-community/poetry2nix/1.21.0"; flake = false; };
|
||||
};
|
||||
|
||||
outputs = { self, mach-nix, nix-parsec, nixpkgs, node2nix, }@inp:
|
||||
outputs = {
|
||||
self,
|
||||
mach-nix,
|
||||
nix-parsec,
|
||||
nixpkgs,
|
||||
node2nix,
|
||||
poetry2nix,
|
||||
}@inp:
|
||||
let
|
||||
|
||||
b = builtins;
|
||||
@ -46,6 +56,11 @@
|
||||
nix-parsec = [
|
||||
"parsec.nix"
|
||||
"lexer.nix"
|
||||
"LICENSE"
|
||||
];
|
||||
poetry2nix = [
|
||||
"semver.nix"
|
||||
"LICENSE"
|
||||
];
|
||||
};
|
||||
|
||||
|
@ -1,6 +1,10 @@
|
||||
{
|
||||
lib,
|
||||
pkgs,
|
||||
|
||||
# dream2nix
|
||||
satisfiesSemver,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
@ -8,106 +12,6 @@ let
|
||||
in
|
||||
|
||||
{
|
||||
degit = {
|
||||
run-build = {
|
||||
installScript = ''
|
||||
npm run build
|
||||
cp help.md ./dist
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
esbuild = {
|
||||
"add-binary-0.12.17" = {
|
||||
_condition = pkg: pkg.version == "0.12.17";
|
||||
ESBUILD_BINARY_PATH =
|
||||
let
|
||||
esbuild = pkgs.buildGoModule rec {
|
||||
pname = "esbuild";
|
||||
version = "0.12.17";
|
||||
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "evanw";
|
||||
repo = "esbuild";
|
||||
rev = "v${version}";
|
||||
sha256 = "sha256-wZOBjNOgGmwIQNCrhzwGPmI/fW/yZiDqq8l4oSDTvZs=";
|
||||
};
|
||||
|
||||
vendorSha256 = "sha256-2ABWPqhK2Cf4ipQH7XvRrd+ZscJhYPc3SV2cGT0apdg=";
|
||||
};
|
||||
in
|
||||
"${esbuild}/bin/esbuild";
|
||||
};
|
||||
};
|
||||
|
||||
geckodriver = {
|
||||
add-binary = {
|
||||
GECKODRIVER_FILEPATH = "${pkgs.geckodriver}/bin/geckodriver";
|
||||
};
|
||||
};
|
||||
|
||||
gifsicle = {
|
||||
add-binary = {
|
||||
installScript = ''
|
||||
ln -s ${pkgs.gifsicle}/bin/gifsicle ./vendor/gifsicle
|
||||
npm run postinstall
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
mozjpeg = {
|
||||
add-binary = {
|
||||
installScript = ''
|
||||
ln -s ${pkgs.mozjpeg}/bin/cjpeg ./vendor/cjpeg
|
||||
npm run postinstall
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
optipng-bin = {
|
||||
add-binary = {
|
||||
installScript = ''
|
||||
ln -s ${pkgs.optipng}/bin/optipng ./vendor/optipng
|
||||
npm run postinstall
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
pngquant-bin = {
|
||||
add-binary = {
|
||||
installScript = ''
|
||||
ln -s ${pkgs.pngquant}/bin/pngquant ./vendor/pngquant
|
||||
npm run postinstall
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
webpack = {
|
||||
remove-webpack-cli-check = {
|
||||
_condition = pkg: pkg.version == "5.41.1";
|
||||
ignoreScripts = false;
|
||||
patches = [
|
||||
./webpack/remove-webpack-cli-check.patch
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
webpack-cli = {
|
||||
remove-webpack-check = {
|
||||
_condition = pkg: pkg.version == "4.7.2";
|
||||
ignoreScripts = false;
|
||||
patches = [
|
||||
./webpack-cli/remove-webpack-check.patch
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
"@mattermost/webapp" = {
|
||||
run-webpack = {
|
||||
installScript = ''
|
||||
NODE_ENV=production node --max-old-space-size=8192 ./node_modules/webpack/bin/webpack.js
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,12 +0,0 @@
|
||||
diff --git a/packages/webpack-cli/bin/cli.js b/packages/webpack-cli/bin/cli.js
|
||||
--- a/bin/cli.js
|
||||
+++ b/bin/cli.js
|
||||
@@ -21,7 +21,7 @@ if (!process.env.WEBPACK_CLI_SKIP_IMPORT_LOCAL) {
|
||||
|
||||
process.title = "webpack";
|
||||
|
||||
-if (utils.packageExists("webpack")) {
|
||||
+if (true) {
|
||||
runCLI(process.argv, originalModuleCompile);
|
||||
} else {
|
||||
const { promptInstallation, logger, colors } = utils;
|
@ -1,12 +0,0 @@
|
||||
diff --git a/bin/webpack.js b/bin/webpack.js
|
||||
--- a/bin/webpack.js
|
||||
+++ b/bin/webpack.js
|
||||
@@ -87,7 +87,7 @@ const cli = {
|
||||
url: "https://github.com/webpack/webpack-cli"
|
||||
};
|
||||
|
||||
-if (!cli.installed) {
|
||||
+if (false) {
|
||||
const path = require("path");
|
||||
const fs = require("graceful-fs");
|
||||
const readLine = require("readline");
|
@ -9,6 +9,7 @@
|
||||
|
||||
# dream2nix inputs
|
||||
callPackageDream,
|
||||
externalSources,
|
||||
...
|
||||
}:
|
||||
let
|
||||
@ -23,6 +24,16 @@ let
|
||||
|
||||
translatorUtils = callPackageDream ./translator.nix {};
|
||||
|
||||
poetry2nixSemver = import "${externalSources.poetry2nix}/semver.nix" {
|
||||
inherit lib;
|
||||
# copied from poetry2nix
|
||||
ireplace = idx: value: list: (
|
||||
lib.genList
|
||||
(i: if i == idx then value else (b.elemAt list i))
|
||||
(b.length list)
|
||||
);
|
||||
};
|
||||
|
||||
in
|
||||
|
||||
parseUtils
|
||||
@ -152,6 +163,8 @@ rec {
|
||||
(v1: v2: versionGreater v1 v2)
|
||||
versions);
|
||||
|
||||
satisfiesSemver = poetry2nixSemver.satisfiesSemver;
|
||||
|
||||
# like nixpkgs recursiveUpdateUntil, but the depth of the
|
||||
recursiveUpdateUntilDepth = depth: lhs: rhs:
|
||||
lib.recursiveUpdateUntil (path: l: r: (b.length path) > depth) lhs rhs;
|
||||
|
@ -15,6 +15,8 @@ let
|
||||
lib.genAttrs (utils.dirNames dir) (name:
|
||||
import (dir + "/${name}") {
|
||||
inherit lib pkgs;
|
||||
satisfiesSemver = constraint: pkg:
|
||||
utils.satisfiesSemver pkg.version constraint;
|
||||
});
|
||||
in
|
||||
b.foldl'
|
||||
@ -69,13 +71,14 @@ let
|
||||
# filter the overrides by the package name and conditions
|
||||
overridesToApply =
|
||||
let
|
||||
regexOverrides =
|
||||
lib.filterAttrs
|
||||
(name: data:
|
||||
lib.hasPrefix "^" name
|
||||
&&
|
||||
b.match name pname != null)
|
||||
conditionalOverrides;
|
||||
# TODO: figure out if regex names will be useful
|
||||
regexOverrides = {};
|
||||
# lib.filterAttrs
|
||||
# (name: data:
|
||||
# lib.hasPrefix "^" name
|
||||
# &&
|
||||
# b.match name pname != null)
|
||||
# conditionalOverrides;
|
||||
|
||||
overridesForPackage =
|
||||
b.foldl'
|
||||
@ -103,6 +106,19 @@ let
|
||||
# the condition is not evaluated anymore here
|
||||
applyOneOverride = pkg: condOverride:
|
||||
let
|
||||
base_derivation =
|
||||
if condOverride ? _replace then
|
||||
if lib.isFunction condOverride._replace then
|
||||
condOverride._replace pkg
|
||||
else if lib.isDerivation condOverride._replace then
|
||||
condOverride._replace
|
||||
else
|
||||
throw
|
||||
("override attr ${pname}.${condOverride._name}._replace"
|
||||
+ " must either be a derivation or a function")
|
||||
else
|
||||
pkg;
|
||||
|
||||
overrideFuncs =
|
||||
lib.mapAttrsToList
|
||||
(funcName: func: { inherit funcName func; })
|
||||
@ -115,7 +131,7 @@ let
|
||||
(funcName: func: lib.attrNames (lib.functionArgs func))
|
||||
(lib.filterAttrs
|
||||
(funcName: func: lib.hasPrefix "override" funcName)
|
||||
pkg);
|
||||
base_derivation);
|
||||
|
||||
getOverrideFuncNameForAttrName = attrName:
|
||||
let
|
||||
@ -157,7 +173,7 @@ let
|
||||
(attrName: functionOrValue:
|
||||
applySingleAttributeOverride old."${attrName}" functionOrValue)
|
||||
updateAttrsFuncs))
|
||||
pkg
|
||||
base_derivation
|
||||
(overrideFuncs ++ singleArgOverrideFuncs);
|
||||
in
|
||||
# apply the overrides to the given pkg
|
||||
|
Loading…
Reference in New Issue
Block a user