From d36d2e631e4baceed0a8c0c00859ebb2ab8cb82f Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 13 Nov 2026 21:28:11 +0100 Subject: populate: drop the shell implementation Populate is the program in Rust only. pkgs.populate checks its arguments, and returns a script running the program with them as JSON. The arguments it took for the shell implementation, dash, jq, and implementation, stay accepted and unused, so overrides setting them keep working. Copying flakes to remote targets using sudo gets refused during evaluation, as before, by checks.nix, and by the program for specs from elsewhere. The jq test goes with the jq programs; the program's unit tests cover their equivalents. --- tests/jq.sh | 149 ------------------------------------------------------------ 1 file changed, 149 deletions(-) delete mode 100755 tests/jq.sh (limited to 'tests/jq.sh') diff --git a/tests/jq.sh b/tests/jq.sh deleted file mode 100755 index 3794ce2..0000000 --- a/tests/jq.sh +++ /dev/null @@ -1,149 +0,0 @@ -#! /bin/sh -# Runs populate's jq programs for flakes over lock files in the shapes -# different versions of Nix write, without VMs. -# -# usage: jq.sh DIR -# -# DIR contains the programs as selected.jq, selfIsRemote.jq, and -# selfLocked.jq, and the Nix function for the target as metadataSubdir.nix. -set -efu - -programs=$1 -failed=0 - -# usage: expect WHAT ACTUAL EXPECTED -expect() { - if test "$2" != "$3"; then - printf 'FAIL: %s\n expected: %s\n got: %s\n' "$1" "$3" "$2" >&2 - failed=1 - fi -} - -# usage: expect_error WHAT ACTUAL MESSAGE -expect_error() { - case $2 in - *"$3"*) ;; - *) - printf 'FAIL: %s\n expected an error: %s\n got: %s\n' "$1" "$3" "$2" >&2 - failed=1 - ;; - esac -} - -# usage: selection METADATA INPUT -selection() { - printf '%s\n' "$1" | - timeout 10 jq -c --argjson input "$2" --from-file "$programs"/selected.jq 2>&1 || - : -} - -# A flake with an input dep, which has an input inner following the flake's -# input inner, and an input sub, a flake in a subdirectory, written as -# attribute dir or as query parameter dir of the URL. -metadata() { - cat <&1 || : -} -export HOME=${TMPDIR:-/tmp} -export NIX_STATE_DIR=$HOME/nix-state -expect "subdirectory as attribute, on the target" "$(metadata_subdir '{ - "locked": { "type": "tarball", "url": "http://x/mono.tar.gz", "dir": "sub" }, - "original": { "type": "tarball", "url": "http://x/mono.tar.gz", "dir": "sub" } -}')" '"sub"' -expect "subdirectory in the URL, on the target" "$(metadata_subdir '{ - "locked": { "type": "tarball", "url": "http://x/mono.tar.gz?dir=sub&narHash=sha256-mono" }, - "original": { "type": "tarball", "url": "http://x/mono.tar.gz?dir=sub" } -}')" '"sub"' -expect "subdirectory in the original reference only, on the target" "$(metadata_subdir '{ - "locked": { "type": "tarball", "url": "http://x/mono.tar.gz" }, - "original": { "type": "tarball", "url": "http://x/mono.tar.gz?rev=1&dir=sub" } -}')" '"sub"' -expect "no subdirectory, on the target" "$(metadata_subdir '{ - "locked": { "type": "path", "path": "/src/top" } -}')" '""' - -exit "$failed" -- cgit v1.3.1