diff --git a/pkgs/by-name/am/amber-lang/fix_word_boundaries.patch b/pkgs/by-name/am/amber-lang/fix_word_boundaries.patch deleted file mode 100644 index ec73631eccae..000000000000 --- a/pkgs/by-name/am/amber-lang/fix_word_boundaries.patch +++ /dev/null @@ -1,38 +0,0 @@ -From efdbecaf721ccb217ece34a5105eaac68e27aa51 Mon Sep 17 00:00:00 2001 -From: Max Karou -Date: Sun, 4 Jan 2026 01:47:51 +0100 -Subject: [PATCH] sed_version: remove word boundary assertions - -Word boundary assertions (\b) are GNU regex extensions that may fail -on systems using non-glibc C libraries (e.g., musl, macOS). - -This was previously fixed in replace_regex() via NixOS/nixpkgs#388412, -which was subsequently upstreamed in amber-lang/amber#686. - -Changes in amber-lang/amber#717 reintroduced the same portability issue. ---- - src/std/text.ab | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/src/std/text.ab b/src/std/text.ab -index 5f2d935..a5dac3f 100644 ---- a/src/std/text.ab -+++ b/src/std/text.ab -@@ -51,12 +51,12 @@ const SED_VERSION_BUSYBOX = 2 - fun sed_version(): Int { - // We can't match against a word "GNU" because - // alpine's busybox sed returns "This is not GNU sed version" -- trust $ re='\bCopyright\b.+\bFree Software Foundation\b'; [[ \$(sed --version 2>/dev/null) =~ \$re ]] $ -+ trust $ re='Copyright.+Free Software Foundation'; [[ \$(sed --version 2>/dev/null) =~ \$re ]] $ - if status == 0 { - return SED_VERSION_GNU - } - // On BSD single `sed` waits for stdin. We must use `sed --help` to avoid this. -- trust $ re='\bBusyBox\b'; [[ \$(sed --help 2>&1) =~ \$re ]] $ -+ trust $ re='BusyBox'; [[ \$(sed --help 2>&1) =~ \$re ]] $ - if status == 0 { - return SED_VERSION_BUSYBOX - } --- -2.51.2 - diff --git a/pkgs/by-name/am/amber-lang/package.nix b/pkgs/by-name/am/amber-lang/package.nix index 40efcab57a60..f35e9b533e2f 100644 --- a/pkgs/by-name/am/amber-lang/package.nix +++ b/pkgs/by-name/am/amber-lang/package.nix @@ -4,7 +4,6 @@ rustPlatform, bc, util-linux, - gnused, makeWrapper, installShellFiles, versionCheckHook, @@ -12,31 +11,23 @@ runCommand, amber-lang, nix-update-script, + bash, + ksh, + zsh, }: rustPlatform.buildRustPackage rec { pname = "amber-lang"; - version = "0.5.1-alpha"; + version = "0.6.0-alpha"; src = fetchFromGitHub { owner = "amber-lang"; repo = "amber"; tag = version; - hash = "sha256-v1uJe3vVGKXaZcQzdoYzu/bJKMQnS4IYET4QLPW+J8Y="; + hash = "sha256-pyMsxb9XPtseroH2MORhMOg9+iaLyoxmgpUTCej+i+Y="; }; - patches = [ - # Upstreamed in #995, can be removed in >= 0.5.2 - # github.com/amber-lang/amber/pull/995 - ./fix_word_boundaries.patch - ]; - - cargoHash = "sha256-aXcxlmmDYLFbyRJYyGE1gbQMbdysHx4iWXsrUj10Eco="; - - preConfigure = '' - substituteInPlace src/compiler.rs \ - --replace-fail 'Command::new("/usr/bin/env")' 'Command::new("env")' - ''; + cargoHash = "sha256-7TZIRg4NK2uOivUUg09T5mbxrNlRmmVyec2xhmzSNvY="; nativeBuildInputs = [ makeWrapper @@ -44,15 +35,23 @@ rustPlatform.buildRustPackage rec { ]; nativeCheckInputs = [ + bash bc # 'rev' in generated bash script of test # tests::validity::variable_ref_function_invocation util-linux ]; + preCheck = '' + substituteInPlace src/tests/cli.rs \ + --replace-fail 'Command::new(amber_bin())' "Command::new(\"target/${stdenv.targetPlatform.rust.cargoShortTarget}/$cargoBuildType/amber\")" + substituteInPlace src/tests/cli.rs \ + --replace-fail 'cmd.env("AMBER_SHELL", "/bin/bash")' 'cmd.env("AMBER_SHELL", "bash")' + ''; + checkFlags = [ "--skip=tests::extra::download" - "--skip=tests::formatter::all_exist" + "--skip=tests::stdlib::test_stdlib_src_tests_stdlib_http_fetch_ab" ]; postInstall = '' @@ -70,21 +69,39 @@ rustPlatform.buildRustPackage rec { passthru = { updateScript = nix-update-script { extraArgs = [ "--version=unstable" ]; }; - tests.run = runCommand "amber-lang-eval-test" { nativeBuildInputs = [ amber-lang ]; } '' - diff -U3 --color=auto <(amber eval 'echo "Hello, World"') <(echo 'Hello, World') - touch $out - ''; + tests = + let + testHelloWorld = + type: pkg: + runCommand "amber-lang-test-eval-hello-world-${type}" + { + nativeBuildInputs = [ + amber-lang + pkg + ]; + } + '' + diff -U3 --color=auto <(amber eval --target ${type} 'echo("Hello, World")') <(echo 'Hello, World') + touch $out + ''; + in + { + eval-hello-world-bash = testHelloWorld "bash" bash; + eval-hello-world-bash-3_2 = testHelloWorld "bash-3.2" bash; + eval-hello-world-ksh = testHelloWorld "ksh" ksh; + eval-hello-world-zsh = testHelloWorld "zsh" zsh; + }; }; meta = { description = "Programming language compiled to bash"; homepage = "https://amber-lang.com"; - license = lib.licenses.gpl3Plus; + license = lib.licenses.lgpl3Only; mainProgram = "amber"; maintainers = with lib.maintainers; [ cafkafk aleksana + ilai-deutel ]; - platforms = lib.platforms.unix; }; }