uboot: (firmwareOdroidC2/C4) don't invoke patch tool, use patches = [] instead

https://github.com/NixOS/nixpkgs/blob/master/pkgs/stdenv/generic/setup.sh#L948
this can do it nicely.

Signed-off-by: Anton Arapov <anton@deadbeef.mx>
This commit is contained in:
Anton Arapov 2021-04-03 12:58:10 +02:00 committed by Alan Daniels
commit 56de2bcd43
30691 changed files with 3076956 additions and 0 deletions

View file

@ -0,0 +1,294 @@
# Using resholve's Nix API
resholve replaces bare references (subject to a PATH search at runtime) to external commands and scripts with absolute paths.
This small super-power helps ensure script dependencies are declared, present, and don't unexpectedly shift when the PATH changes.
resholve is developed to enable the Nix package manager to package and integrate Shell projects, but its features are not Nix-specific and inevitably have other applications.
<!-- generated from resholve's repo; best to suggest edits there (or at least notify me) -->
This will hopefully make its way into the Nixpkgs manual soon, but
until then I'll outline how to use the functions:
- `resholve.mkDerivation` (formerly `resholvePackage`)
- `resholve.writeScript` (formerly `resholveScript`)
- `resholve.writeScriptBin` (formerly `resholveScriptBin`)
- `resholve.phraseSolution` (new in resholve 0.8.0)
> Fair warning: resholve does *not* aspire to resolving all valid Shell
> scripts. It depends on the OSH/Oil parser, which aims to support most (but
> not all) Bash. resholve aims to be a ~90% sort of solution.
## API Concepts
The main difference between `resholve.mkDerivation` and other builder functions
is the `solutions` attrset, which describes which scripts to resolve and how.
Each "solution" (k=v pair) in this attrset describes one resholve invocation.
> NOTE: For most shell packages, one invocation will probably be enough:
> - Packages with a single script will only need one solution.
> - Packages with multiple scripts can still use one solution if the scripts
> don't require conflicting directives.
> - Packages with scripts that require conflicting directives can use multiple
> solutions to resolve the scripts separately, but produce a single package.
`resholve.writeScript` and `resholve.writeScriptBin` support a _single_
`solution` attrset. This is basically the same as any single solution in `resholve.mkDerivation`, except that it doesn't need a `scripts` attr (it is automatically added). `resholve.phraseSolution` also only accepts a single solution--but it _does_ still require the `scripts` attr.
## Basic `resholve.mkDerivation` Example
Here's a simple example of how `resholve.mkDerivation` is already used in nixpkgs:
<!-- TODO: figure out how to pull this externally? -->
```nix
{ lib
, fetchFromGitHub
, resholve
, substituteAll
, bash
, coreutils
, goss
, which
}:
resholve.mkDerivation rec {
pname = "dgoss";
version = "0.3.16";
src = fetchFromGitHub {
owner = "aelsabbahy";
repo = "goss";
rev = "v${version}";
sha256 = "1m5w5vwmc9knvaihk61848rlq7qgdyylzpcwi64z84rkw8qdnj6p";
};
dontConfigure = true;
dontBuild = true;
installPhase = ''
sed -i '2i GOSS_PATH=${goss}/bin/goss' extras/dgoss/dgoss
install -D extras/dgoss/dgoss $out/bin/dgoss
'';
solutions = {
default = {
scripts = [ "bin/dgoss" ];
interpreter = "${bash}/bin/bash";
inputs = [ coreutils which ];
fake = {
external = [ "docker" ];
};
};
};
meta = with lib; {
homepage = "https://github.com/aelsabbahy/goss/blob/v${version}/extras/dgoss/README.md";
description = "Convenience wrapper around goss that aims to bring the simplicity of goss to docker containers";
license = licenses.asl20;
platforms = platforms.linux;
maintainers = with maintainers; [ hyzual ];
};
}
```
## Basic `resholve.writeScript` and `resholve.writeScriptBin` examples
Both of these functions have the same basic API. This example is a little
trivial for now. If you have a real usage that you find helpful, please PR it.
```nix
resholvedScript = resholve.writeScript "name" {
inputs = [ file ];
interpreter = "${bash}/bin/bash";
} ''
echo "Hello"
file .
'';
resholvedScriptBin = resholve.writeScriptBin "name" {
inputs = [ file ];
interpreter = "${bash}/bin/bash";
} ''
echo "Hello"
file .
'';
```
## Basic `resholve.phraseSolution` example
This function has a similar API to `writeScript` and `writeScriptBin`, except it does require a `scripts` attr. It is intended to make resholve a little easier to mix into more types of build. This example is a little
trivial for now. If you have a real usage that you find helpful, please PR it.
```nix
{ stdenv, resholve, module1 }:
stdenv.mkDerivation {
# pname = "testmod3";
# version = "unreleased";
# src = ...;
installPhase = ''
mkdir -p $out/bin
install conjure.sh $out/bin/conjure.sh
${resholve.phraseSolution "conjure" {
scripts = [ "bin/conjure.sh" ];
interpreter = "${bash}/bin/bash";
inputs = [ module1 ];
fake = {
external = [ "jq" "openssl" ];
};
}}
'';
}
```
## Options
`resholve.mkDerivation` maps Nix types/idioms into the flags and environment variables
that the `resholve` CLI expects. Here's an overview:
| Option | Type | Containing |
|--------|------|------------|
| scripts | `<list>` | scripts to resolve (`$out`-relative paths) |
| interpreter | `"none"` `<path>` | The absolute interpreter `<path>` for the script's shebang. The special value `none` ensures there is no shebang. |
| inputs | `<packages>` | Packages to resolve external dependencies from. |
| fake | `<directives>` | pretend some commands exist |
| fix | `<directives>` | fix things we can't auto-fix/ignore |
| keep | `<directives>` | keep things we can't auto-fix/ignore |
| lore | `<directory>` | control nested resolution |
| execer | `<statements>` | modify nested resolution |
| wrapper | `<statements>` | modify nested resolution |
| prologue | `<file>` | insert file before resolved script |
| epilogue | `<file>` | insert file after resolved script |
<!-- TODO: section below is largely custom for nixpkgs, but I would LIKE to wurst it. -->
## Controlling resolution with directives
In order to resolve a script, resholve will make you disambiguate how it should
handle any potential problems it encounters with directives. There are currently
3 types:
1. `fake` directives tell resholve to pretend it knows about an identifier
such as a function, builtin, external command, etc. if there's a good reason
it doesn't already know about it. Common examples:
- builtins for a non-bash shell
- loadable builtins
- platform-specific external commands in cross-platform conditionals
2. `fix` directives give resholve permission to fix something that it can't
safely fix automatically. Common examples:
- resolving commands in aliases (this is appropriate for standalone scripts
that use aliases non-interactively--but it would prevent profile/rc
scripts from using the latest current-system symlinks.)
- resolve commands in a variable definition
- resolve an absolute command path from inputs as if it were a bare reference
3. `keep` directives tell resholve not to raise an error (i.e., ignore)
something it would usually object to. Common examples:
- variables used as/within the first word of a command
- pre-existing absolute or user-relative (~) command paths
- dynamic (variable) arguments to commands known to accept/run other commands
> NOTE: resholve has a (growing) number of directives detailed in `man resholve`
> via `nixpkgs.resholve`.
Each of these 3 types is represented by its own attrset, where you can think
of the key as a scope. The value should be:
- `true` for any directives that the resholve CLI accepts as a single word
- a list of strings for all other options
<!--
TODO: these should be fully-documented here, but I'm already maintaining
more copies of their specification/behavior than I like, and continuing to
add more at this early date will only ensure that I spend more time updating
docs and less time filling in feature gaps.
Full documentation may be greatly accellerated if someone can help me sort out
single-sourcing. See: https://github.com/abathur/resholve/issues/19
-->
This will hopefully make more sense when you see it. Here are CLI examples
from the manpage, and the Nix equivalents:
```nix
# --fake 'f:setUp;tearDown builtin:setopt source:/etc/bashrc'
fake = {
# fake accepts the initial of valid identifier types as a CLI convenience.
# Use full names in the Nix API.
function = [ "setUp" "tearDown" ];
builtin = [ "setopt" ];
source = [ "/etc/bashrc" ];
};
# --fix 'aliases $GIT:gix /bin/bash'
fix = {
# all single-word directives use `true` as value
aliases = true;
"$GIT" = [ "gix" ];
"/bin/bash";
};
# --keep 'source:$HOME /etc/bashrc ~/.bashrc'
keep = {
source = [ "$HOME" ];
"/etc/bashrc" = true;
"~/.bashrc" = true;
};
```
> **Note:** For now, at least, you'll need to reference the manpage to completely understand these examples.
## Controlling nested resolution with lore
Initially, resolution of commands in the arguments to command-executing
commands was limited to one level for a hard-coded list of builtins and
external commands. resholve can now resolve these recursively.
This feature combines information (_lore_) that the resholve Nix API
obtains via binlore ([nixpkgs](../../tools/analysis/binlore), [repo](https://github.com/abathur/resholve)),
with some rules (internal to resholve) for locating sub-executions in
some of the more common commands.
- "execer" lore identifies whether an executable can, cannot,
or might execute its arguments. Every "can" or "might" verdict requires
either built-in rules for finding the executable, or human triage.
- "wrapper" lore maps shell exec wrappers to the programs they exec so
that resholve can substitute an executable's verdict for its wrapper's.
> **Caution:** At least when it comes to common utilities, it's best to treat
> overrides as a stopgap until they can be properly handled in resholve and/or
> binlore. Please report things you have to override and, if possible, help
> get them sorted.
There will be more mechanisms for controlling this process in the future
(and your reports/experiences will play a role in shaping them...) For now,
the main lever is the ability to substitute your own lore. This is how you'd
do it piecemeal:
```nix
# --execer 'cannot:${openssl.bin}/bin/openssl can:${openssl.bin}/bin/c_rehash'
execer = [
/*
This is the same verdict binlore will
come up with. It's a no-op just to demo
how to fiddle lore via the Nix API.
*/
"cannot:${openssl.bin}/bin/openssl"
# different verdict, but not used
"can:${openssl.bin}/bin/c_rehash"
];
# --wrapper '${gnugrep}/bin/egrep:${gnugrep}/bin/grep'
execer = [
/*
This is the same verdict binlore will
come up with. It's a no-op just to demo
how to fiddle lore via the Nix API.
*/
"${gnugrep}/bin/egrep:${gnugrep}/bin/grep"
];
```
The format is fairly simple to generate--you can script your own generator if
you need to modify the lore.

View file

@ -0,0 +1,21 @@
{ callPackage
, ...
}:
let
source = callPackage ./source.nix { };
deps = callPackage ./deps.nix { };
in
rec {
# resholve itself
resholve = callPackage ./resholve.nix {
inherit (source) rSrc version;
inherit (deps.oil) oildev;
inherit resholve-utils;
};
# funcs to validate and phrase invocations of resholve
# and use those invocations to build packages
resholve-utils = callPackage ./resholve-utils.nix {
inherit resholve;
};
}

18
pkgs/development/misc/resholve/deps.nix generated Normal file
View file

@ -0,0 +1,18 @@
{ callPackage
, ...
}:
/*
Notes on specific dependencies:
- if/when python2.7 is removed from nixpkgs, this may need to figure
out how to build oil's vendored python2
- I'm not sure if glibcLocales is worth the addition here. It's to fix
a libc test oil runs. My oil fork just disabled the libc tests, but
I haven't quite decided if that's the right long-term call, so I
didn't add a patch for it here yet.
*/
rec {
# binlore = callPackage ./binlore.nix { };
oil = callPackage ./oildev.nix { };
}

View file

@ -0,0 +1,131 @@
{ lib
, stdenv
, python27Packages
, callPackage
, fetchFromGitHub
, makeWrapper
, # re2c deps
autoreconfHook
, # py-yajl deps
git
, # oil deps
readline
, cmark
, file
, glibcLocales
}:
rec {
re2c = stdenv.mkDerivation rec {
pname = "re2c";
version = "1.0.3";
sourceRoot = "${src.name}/re2c";
src = fetchFromGitHub {
owner = "skvadrik";
repo = "re2c";
rev = version;
sha256 = "0grx7nl9fwcn880v5ssjljhcb9c5p2a6xpwil7zxpmv0rwnr3yqi";
};
nativeBuildInputs = [ autoreconfHook ];
preCheck = ''
patchShebangs run_tests.sh
'';
};
py-yajl = python27Packages.buildPythonPackage rec {
pname = "oil-pyyajl-unstable";
version = "2019-12-05";
src = fetchFromGitHub {
owner = "oilshell";
repo = "py-yajl";
rev = "eb561e9aea6e88095d66abcc3990f2ee1f5339df";
sha256 = "17hcgb7r7cy8r1pwbdh8di0nvykdswlqj73c85k6z8m0filj3hbh";
fetchSubmodules = true;
};
# just for submodule IIRC
nativeBuildInputs = [ git ];
};
/*
Upstream isn't interested in packaging this as a library
(or accepting all of the patches we need to do so).
This creates one without disturbing upstream too much.
*/
oildev = python27Packages.buildPythonPackage rec {
pname = "oildev-unstable";
version = "2021-07-14";
src = fetchFromGitHub {
owner = "oilshell";
repo = "oil";
# rev == present HEAD of release/0.8.12
rev = "799c0703d1da86cb80d1f5b163edf9369ad77cf1";
hash = "sha256-QNSISr719ycZ1Z0quxHWzCb3IvHGj9TpogaYz20hDM4=";
/*
It's not critical to drop most of these; the primary target is
the vendored fork of Python-2.7.13, which is ~ 55M and over 3200
files, dozens of which get interpreter script patches in fixup.
Note: -f is necessary to keep it from being a pain to update
hash on rev updates. Command will fail w/o and not print hash.
*/
postFetch = ''
rm -rf Python-2.7.13 benchmarks metrics py-yajl rfc gold web testdata services demo devtools cpp
'';
};
# patch to support a python package, pass tests on macOS, etc.
patchSrc = fetchFromGitHub {
owner = "abathur";
repo = "nix-py-dev-oil";
rev = "v0.8.12.2";
hash = "sha256-+dVxzPKMGNKFE+7Ggzx9iWjjvwW2Ow3UqmjjUud9Mqo=";
};
patches = [
"${patchSrc}/0001-add_setup_py.patch"
"${patchSrc}/0002-add_MANIFEST_in.patch"
"${patchSrc}/0004-disable-internal-py-yajl-for-nix-built.patch"
"${patchSrc}/0006-disable_failing_libc_tests.patch"
"${patchSrc}/0007-namespace_via_init.patch"
"${patchSrc}/0009-avoid_nix_arch64_darwin_toolchain_bug.patch"
];
buildInputs = [ readline cmark py-yajl ];
nativeBuildInputs = [ re2c file makeWrapper ];
propagatedBuildInputs = with python27Packages; [ six typing ];
doCheck = true;
preBuild = ''
build/dev.sh all
'';
postPatch = ''
patchShebangs asdl build core doctools frontend native oil_lang
'';
/*
We did convince oil to upstream an env for specifying
this to support a shell.nix. Would need a patch if they
later drop this support. See:
https://github.com/oilshell/oil/blob/46900310c7e4a07a6223eb6c08e4f26460aad285/doctools/cmark.py#L30-L34
*/
_NIX_SHELL_LIBCMARK = "${cmark}/lib/libcmark${stdenv.hostPlatform.extensions.sharedLibrary}";
# See earlier note on glibcLocales TODO: verify needed?
LOCALE_ARCHIVE = lib.optionalString (stdenv.buildPlatform.libc == "glibc") "${glibcLocales}/lib/locale/locale-archive";
# not exhaustive; just a spot-check for now
pythonImportsCheck = [ "oil" "oil._devbuild" ];
meta = {
license = with lib.licenses; [
psfl # Includes a portion of the python interpreter and standard library
asl20 # Licence for Oil itself
];
};
};
}

View file

@ -0,0 +1,203 @@
{ lib, stdenv, resholve, binlore, writeTextFile }:
rec {
/* These functions break up the work of partially validating the
'solutions' attrset and massaging it into env/cli args.
Note: some of the left-most args do not *have* to be passed as
deep as they are, but I've done so to provide more error context
*/
# for brevity / line length
spaces = l: builtins.concatStringsSep " " l;
colons = l: builtins.concatStringsSep ":" l;
semicolons = l: builtins.concatStringsSep ";" l;
/* Throw a fit with dotted attr path context */
nope = path: msg:
throw "${builtins.concatStringsSep "." path}: ${msg}";
/* Special-case directive value representations by type */
phraseDirective = solution: env: name: val:
if builtins.isInt val then builtins.toString val
else if builtins.isString val then name
else if true == val then name
else if false == val then "" # omit!
else if null == val then "" # omit!
else if builtins.isList val then "${name}:${semicolons (map lib.escapeShellArg val)}"
else nope [ solution env name ] "unexpected type: ${builtins.typeOf val}";
/* Build fake/fix/keep directives from Nix types */
phraseDirectives = solution: env: val:
lib.mapAttrsToList (phraseDirective solution env) val;
/* Custom ~search-path routine to handle relative path strings */
relSafeBinPath = input:
if lib.isDerivation input then ((lib.getOutput "bin" input) + "/bin")
else if builtins.isString input then input
else throw "unexpected type for input: ${builtins.typeOf input}";
/* Special-case value representation by type/name */
phraseEnvVal = solution: env: val:
if env == "inputs" then (colons (map relSafeBinPath val))
else if builtins.isString val then val
else if builtins.isList val then spaces val
else if builtins.isAttrs val then spaces (phraseDirectives solution env val)
else nope [ solution env ] "unexpected type: ${builtins.typeOf val}";
/* Shell-format each env value */
shellEnv = solution: env: value:
lib.escapeShellArg (phraseEnvVal solution env value);
/* Build a single ENV=val pair */
phraseEnv = solution: env: value:
"RESHOLVE_${lib.toUpper env}=${shellEnv solution env value}";
/* Discard attrs:
- claimed by phraseArgs
- only needed for binlore.collect
*/
removeUnneededArgs = value:
removeAttrs value [ "scripts" "flags" "unresholved" ];
/* Verify required arguments are present */
validateSolution = { scripts, inputs, interpreter, ... }: true;
/* Pull out specific solution keys to build ENV=val pairs */
phraseEnvs = solution: value:
spaces (lib.mapAttrsToList (phraseEnv solution) (removeUnneededArgs value));
/* Pull out specific solution keys to build CLI argstring */
phraseArgs = { flags ? [ ], scripts, ... }:
spaces (flags ++ scripts);
phraseBinloreArgs = value:
let
hasUnresholved = builtins.hasAttr "unresholved" value;
in {
drvs = value.inputs ++
lib.optionals hasUnresholved [ value.unresholved ];
strip = if hasUnresholved then [ value.unresholved ] else [ ];
};
/* Build a single resholve invocation */
phraseInvocation = solution: value:
if validateSolution value then
# we pass resholve a directory
"RESHOLVE_LORE=${binlore.collect (phraseBinloreArgs value) } ${phraseEnvs solution value} ${resholve}/bin/resholve --overwrite ${phraseArgs value}"
else throw "invalid solution"; # shouldn't trigger for now
injectUnresholved = solutions: unresholved: (builtins.mapAttrs (name: value: value // { inherit unresholved; } ) solutions);
/* Build resholve invocation for each solution. */
phraseCommands = solutions: unresholved:
builtins.concatStringsSep "\n" (
lib.mapAttrsToList phraseInvocation (injectUnresholved solutions unresholved)
);
/*
subshell/PS4/set -x and : command to output resholve envs
and invocation. Extra context makes it clearer what the
Nix API is doing, makes nix-shell debugging easier, etc.
*/
phraseContext = { invokable, prep ? ''cd "$out"'' }: ''
(
${prep}
PS4=$'\x1f'"\033[33m[resholve context]\033[0m "
set -x
: invoking resholve with PWD=$PWD
${invokable}
)
'';
phraseContextForPWD = invokable: phraseContext { inherit invokable; prep = ""; };
phraseContextForOut = invokable: phraseContext { inherit invokable; };
phraseSolution = name: solution: (phraseContextForOut (phraseInvocation name solution));
phraseSolutions = solutions: unresholved:
phraseContextForOut (phraseCommands solutions unresholved);
writeScript = name: partialSolution: text:
writeTextFile {
inherit name text;
executable = true;
checkPhase = ''
${(phraseContextForPWD (
phraseInvocation name (
partialSolution // {
scripts = [ "${placeholder "out"}" ];
}
)
)
)}
${partialSolution.interpreter} -n $out
'';
};
writeScriptBin = name: partialSolution: text:
writeTextFile rec {
inherit name text;
executable = true;
destination = "/bin/${name}";
checkPhase = ''
${phraseContextForOut (
phraseInvocation name (
partialSolution // {
scripts = [ "bin/${name}" ];
}
)
)
}
${partialSolution.interpreter} -n $out/bin/${name}
'';
};
mkDerivation = { pname
, src
, version
, passthru ? { }
, solutions
, ...
}@attrs:
let
inherit stdenv;
/*
Knock out our special solutions arg, but otherwise
just build what the caller is giving us. We'll
actually resholve it separately below (after we
generate binlore for it).
*/
unresholved = (stdenv.mkDerivation ((removeAttrs attrs [ "solutions" ])
// {
inherit pname version src;
}));
in
/*
resholve in a separate derivation; some concerns:
- we aren't keeping many of the user's args, so they
can't readily set LOGLEVEL and such...
- not sure how this affects multiple outputs
*/
lib.extendDerivation true passthru (stdenv.mkDerivation {
src = unresholved;
version = unresholved.version;
pname = "resholved-${unresholved.pname}";
buildInputs = [ resholve ];
# retain a reference to the base
passthru = unresholved.passthru // {
unresholved = unresholved;
};
# do these imply that we should use NoCC or something?
dontConfigure = true;
dontBuild = true;
installPhase = ''
cp -R $src $out
'';
# enable below for verbose debug info if needed
# supports default python.logging levels
# LOGLEVEL="INFO";
preFixup = phraseSolutions solutions unresholved;
});
}

View file

@ -0,0 +1,61 @@
{ lib
, stdenv
, callPackage
, python27Packages
, installShellFiles
, rSrc
, version
, oildev
, binlore
, resholve-utils
}:
python27Packages.buildPythonApplication {
pname = "resholve";
inherit version;
src = rSrc;
nativeBuildInputs = [ installShellFiles ];
propagatedBuildInputs = [
oildev
/*
Disable configargparse's tests on aarch64-darwin.
Several of py27 scandir's tests fail on aarch64-darwin. Chain:
configargparse -> pytest-check-hook -> pytest -> pathlib2 -> scandir
TODO: drop if https://github.com/NixOS/nixpkgs/issues/156807 resolves?
*/
(python27Packages.configargparse.overridePythonAttrs (old: {
doCheck = stdenv.hostPlatform.system != "aarch64-darwin";
}))
];
patchPhase = ''
for file in setup.cfg _resholve/version.py; do
substituteInPlace $file --subst-var-by version ${version}
done
'';
postInstall = ''
installManPage resholve.1
'';
# Do not propagate Python; may be obsoleted by nixos/nixpkgs#102613
# for context on why, see abathur/resholve#20
postFixup = ''
rm $out/nix-support/propagated-build-inputs
'';
passthru = {
inherit (resholve-utils) mkDerivation phraseSolution writeScript writeScriptBin;
tests = callPackage ./test.nix { inherit rSrc binlore; };
};
meta = with lib; {
description = "Resolve external shell-script dependencies";
homepage = "https://github.com/abathur/resholve";
license = with licenses; [ mit ];
maintainers = with maintainers; [ abathur ];
platforms = platforms.all;
};
}

View file

@ -0,0 +1,19 @@
{ fetchFromGitHub
, ...
}:
rec {
version = "0.8.0";
rSrc =
# local build -> `make ci`; `make clean` to restore
# return to remote source
# if builtins.pathExists ./.local
# then ./.
# else
fetchFromGitHub {
owner = "abathur";
repo = "resholve";
rev = "v${version}";
hash = "sha256-oWS4ZBPjgH2UvYmvHVVRcyl15r3VS964BmB89y9DGo8=";
};
}

View file

@ -0,0 +1,182 @@
{ lib
, stdenv
, callPackage
, resholve
, shunit2
, fetchFromGitHub
, coreutils
, gnused
, gnugrep
, findutils
, jq
, bash
, bats
, libressl
, openssl
, python27
, file
, gettext
, rSrc
, runDemo ? false
, binlore
, sqlite
, util-linux
, gawk
, rlwrap
, gnutar
, bc
}:
let
default_packages = [ bash file findutils gettext ];
parsed_packages = [ coreutils sqlite util-linux gnused gawk findutils rlwrap gnutar bc ];
in
rec {
module1 = resholve.mkDerivation {
pname = "testmod1";
version = "unreleased";
src = rSrc;
setSourceRoot = "sourceRoot=$(echo */tests/nix/libressl)";
installPhase = ''
mkdir -p $out/{bin,submodule}
install libressl.sh $out/bin/libressl.sh
install submodule/helper.sh $out/submodule/helper.sh
'';
solutions = {
libressl = {
# submodule to demonstrate
scripts = [ "bin/libressl.sh" "submodule/helper.sh" ];
interpreter = "none";
inputs = [ jq module2 libressl.bin ];
};
};
is_it_okay_with_arbitrary_envs = "shonuff";
};
module2 = resholve.mkDerivation {
pname = "testmod2";
version = "unreleased";
src = rSrc;
setSourceRoot = "sourceRoot=$(echo */tests/nix/openssl)";
installPhase = ''
mkdir -p $out/bin $out/libexec
install openssl.sh $out/bin/openssl.sh
install libexec.sh $out/libexec/invokeme
install profile $out/profile
'';
# LOGLEVEL="DEBUG";
solutions = {
openssl = {
fix = {
aliases = true;
};
scripts = [ "bin/openssl.sh" "libexec/invokeme" ];
interpreter = "none";
inputs = [ shunit2 openssl.bin "libexec" "libexec/invokeme" ];
execer = [
/*
This is the same verdict binlore will
come up with. It's a no-op just to demo
how to fiddle lore via the Nix API.
*/
"cannot:${openssl.bin}/bin/openssl"
# different verdict, but not used
"can:${openssl.bin}/bin/c_rehash"
];
};
profile = {
scripts = [ "profile" ];
interpreter = "none";
inputs = [ ];
};
};
};
# demonstrate that we could use resholve in larger build
module3 = stdenv.mkDerivation {
pname = "testmod3";
version = "unreleased";
src = rSrc;
setSourceRoot = "sourceRoot=$(echo */tests/nix/future_perfect_tense)";
installPhase = ''
mkdir -p $out/bin
install conjure.sh $out/bin/conjure.sh
${resholve.phraseSolution "conjure" {
scripts = [ "bin/conjure.sh" ];
interpreter = "${bash}/bin/bash";
inputs = [ module1 ];
fake = {
external = [ "jq" "openssl" ];
};
}}
'';
};
cli = stdenv.mkDerivation {
name = "resholve-test";
src = rSrc;
installPhase = ''
mkdir $out
cp *.ansi $out/
'';
doCheck = true;
buildInputs = [ resholve ];
checkInputs = [ coreutils bats python27 ];
# LOGLEVEL="DEBUG";
# default path
RESHOLVE_PATH = "${lib.makeBinPath default_packages}";
# but separate packages for combining as needed
PKG_FILE = "${lib.makeBinPath [ file ]}";
PKG_FINDUTILS = "${lib.makeBinPath [ findutils ]}";
PKG_GETTEXT = "${lib.makeBinPath [ gettext ]}";
PKG_COREUTILS = "${lib.makeBinPath [ coreutils ]}";
RESHOLVE_LORE = "${binlore.collect { drvs = default_packages ++ [ coreutils ] ++ parsed_packages; } }";
PKG_PARSED = "${lib.makeBinPath parsed_packages}";
# explicit interpreter for demo suite; maybe some better way...
INTERP = "${bash}/bin/bash";
checkPhase = ''
patchShebangs .
mkdir empty_lore
touch empty_lore/{execers,wrappers}
export EMPTY_LORE=$PWD/empty_lore
printf "\033[33m============================= resholve test suite ===================================\033[0m\n" > test.ansi
if ./test.sh &>> test.ansi; then
cat test.ansi
else
cat test.ansi && exit 1
fi
'' + lib.optionalString runDemo ''
printf "\033[33m============================= resholve demo ===================================\033[0m\n" > demo.ansi
if ./demo &>> demo.ansi; then
cat demo.ansi
else
cat demo.ansi && exit 1
fi
'';
};
# Caution: ci.nix asserts the equality of both of these w/ diff
resholvedScript = resholve.writeScript "resholved-script" {
inputs = [ file ];
interpreter = "${bash}/bin/bash";
} ''
echo "Hello"
file .
'';
resholvedScriptBin = resholve.writeScriptBin "resholved-script-bin" {
inputs = [ file ];
interpreter = "${bash}/bin/bash";
} ''
echo "Hello"
file .
'';
}