summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKlaus T. Aehlig <aehlig@linta.de>2024-06-27 16:30:53 +0200
committerKlaus T. Aehlig <aehlig@linta.de>2024-06-27 16:30:53 +0200
commit866e07a8baa21707ec73109b6e502af4fe4c41bf (patch)
tree67386b8a9812b2b49a8aa8fa976505dedfa814e1
parent05b2d6fc51146fe07340a58bc87fbbd99e788143 (diff)
downloadhello-nix-866e07a8baa21707ec73109b6e502af4fe4c41bf.tar.gz
nix-shell: also add a wrapper script besides the alias
... as aliases are not honored in `nix-shell --run`. In this way, we can add an outer script running all the tests in the correct environment.
-rw-r--r--README.md8
-rw-r--r--nix-dependencies/dependencies.nix11
-rwxr-xr-xrun-tests1
-rw-r--r--shell.nix1
4 files changed, 19 insertions, 2 deletions
diff --git a/README.md b/README.md
index 5ab1a0d..1ae6676 100644
--- a/README.md
+++ b/README.md
@@ -73,7 +73,8 @@ way as follows.
pinned using [niv](https://github.com/nmattia/niv).
- A [nix shell](./shell.nix) uses the derivation at the pinned
snapshot of the `nixpkgs` and sets an alias for `just-mr` to
- use the derived rc-file.
+ use the derived rc-file. It also adds a script `withRc-just-mr`
+ that execs `just-mr` with the derived rc-file.
So to build with the correct dependencies for the checked out version,
simply start a `nix-shell` at the top level of this repository and
@@ -90,6 +91,11 @@ by using the current justbuild when checking out older snapshots,
we can reconstruct the old actions without the need of cleaning up
the local build root.
+The just described way of working in a `nix-shell` using the
+alias is useful for interactive development. For CI-like usage,
+the script [run-tests](./run-tests) can be used that simply runs
+`withRc-just-mr` in a `nix-shell`.
+
## Shell commands
The built-in rule `"generic"` allows to define a target by
diff --git a/nix-dependencies/dependencies.nix b/nix-dependencies/dependencies.nix
index 10a1b3e..2e73468 100644
--- a/nix-dependencies/dependencies.nix
+++ b/nix-dependencies/dependencies.nix
@@ -1,5 +1,6 @@
{ stdenv
, jo
+, bash
, pkg-config
, coreutils
, protobuf_25
@@ -25,6 +26,7 @@ stdenv.mkDerivation rec {
protobuf_25
grpc
jo
+ bash
];
buildInputs = [
@@ -52,12 +54,19 @@ stdenv.mkDerivation rec {
) > config.json
cat config.json
jo "just files"=$(jo config=$(jo -a $(jo root=system path=$out/share/config.json))) > rc.json
+
+ cat > withRc-just-mr <<EOF
+ #!${bash}/bin/bash
+ exec just-mr --rc $out/share/rc.json "\$@"
+ EOF
'';
installPhase = ''
- mkdir -p $out/share
+ mkdir -p $out/share $out/bin
cp config.json $out/share
cp rc.json $out/share
+ cp withRc-just-mr $out/bin
+ chmod 555 $out/bin/withRc-just-mr
'';
}
diff --git a/run-tests b/run-tests
new file mode 100755
index 0000000..c3d4938
--- /dev/null
+++ b/run-tests
@@ -0,0 +1 @@
+nix-shell --run "withRc-just-mr --main test build"
diff --git a/shell.nix b/shell.nix
index a42d2ae..70c8edd 100644
--- a/shell.nix
+++ b/shell.nix
@@ -17,6 +17,7 @@ in pkgs.mkShell rec {
niv
update-deps
cargo
+ nix-dependencies
];
shellHook = ''