mirror of
https://github.com/nix-community/nix-on-droid.git
synced 2025-11-08 19:46:07 +01:00
tests: increase readability through small helper functions
This commit is contained in:
parent
7f983228fe
commit
248632699e
4 changed files with 20 additions and 15 deletions
|
|
@ -10,10 +10,9 @@ load lib
|
|||
# set up / build / activate the configuration
|
||||
cat "$ON_DEVICE_TESTS_DIR/config-flake-h-m.cfg.nix" \
|
||||
> ~/.config/nixpkgs/nix-on-droid.nix
|
||||
nix-shell -p gnused --run \
|
||||
"sed 's|<<FLAKE_URL>>|$FLAKE_URL|g' \
|
||||
< '$ON_DEVICE_TESTS_DIR/config-flake-h-m.flake.nix' \
|
||||
> ~/.config/nixpkgs/flake.nix"
|
||||
_sed "s|<<FLAKE_URL>>|$FLAKE_URL|g" \
|
||||
"$ON_DEVICE_TESTS_DIR/config-flake-h-m.flake.nix" \
|
||||
> ~/.config/nixpkgs/flake.nix
|
||||
pushd ~/.config/nixpkgs
|
||||
nix-shell -p nixFlakes --run \
|
||||
'nix build \
|
||||
|
|
|
|||
|
|
@ -8,17 +8,15 @@ load lib
|
|||
assert_no_command unzip
|
||||
|
||||
# set up / build / activate the configuration
|
||||
nix-shell -p gnused --run \
|
||||
"sed \
|
||||
-e s/vim/nano/ \
|
||||
-e s/#unzip/unzip/ \
|
||||
< '$CHANNEL_DIR/modules/environment/login/nix-on-droid.nix.default' \
|
||||
> ~/.config/nixpkgs/nix-on-droid.nix"
|
||||
_sed \
|
||||
-e 's/vim/nano/' \
|
||||
-e 's/#unzip/unzip/' \
|
||||
"$CHANNEL_DIR/modules/environment/login/nix-on-droid.nix.default" \
|
||||
> ~/.config/nixpkgs/nix-on-droid.nix
|
||||
|
||||
nix-shell -p gnused --run \
|
||||
"sed 's|<<FLAKE_URL>>|$FLAKE_URL|g' \
|
||||
< '$ON_DEVICE_TESTS_DIR/config-flake.nix' \
|
||||
> ~/.config/nixpkgs/flake.nix"
|
||||
_sed "s|<<FLAKE_URL>>|$FLAKE_URL|g" \
|
||||
"$ON_DEVICE_TESTS_DIR/config-flake.nix" \
|
||||
> ~/.config/nixpkgs/flake.nix
|
||||
|
||||
# this is more cumbersome than options,
|
||||
# but this is what we recommend to users, so taking the hard way
|
||||
|
|
|
|||
|
|
@ -4,7 +4,9 @@
|
|||
TEMPDIR=/tmp/.tmp-gnumake.$$
|
||||
mkdir -p "$TEMPDIR"
|
||||
echo -e 'x:\n\techo desired output > x' > "$TEMPDIR/Makefile"
|
||||
nix-shell -p gnumake --run "make -C $TEMPDIR x"
|
||||
|
||||
"$(nix-build "<nixpkgs>" --no-out-link --attr gnumake)/bin/make" -C "$TEMPDIR" x
|
||||
|
||||
[[ -e "$TEMPDIR/x" ]]
|
||||
[[ "$(cat "$TEMPDIR/x")" == 'desired output' ]]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,3 +51,9 @@ switch_to_default_config() {
|
|||
> ~/.config/nixpkgs/nix-on-droid.nix
|
||||
nix-on-droid switch
|
||||
}
|
||||
|
||||
_sed() {
|
||||
local storePath
|
||||
storePath="$(nix-build "<nixpkgs>" --no-out-link --attr gnused)"
|
||||
"${storePath}/bin/sed" "$@"
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue