From 49130f93b73e61a9e3dff31c3c13c5a9096fa969 Mon Sep 17 00:00:00 2001 From: Dominik Xaver Hörl Date: Mon, 11 Jan 2021 17:23:24 +0100 Subject: nixos/modules-closure.sh: don't fail if firmware is missing Since fdf32154fc90698ef72ffa96ef39d920e1b9c951, we no longer allow missing modules in the initrd. Unfortunately since before this commit, the modules-closure script would also fail on missing firmware, which is a very common case (e.g. xhci-pci.ko.xz lists renesas_usb_fw.mem as dependent firmware). Fix this by only issuing a warning instead. --- pkgs/build-support/kernel/modules-closure.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'pkgs/build-support') diff --git a/pkgs/build-support/kernel/modules-closure.sh b/pkgs/build-support/kernel/modules-closure.sh index 3f895d9cfed9..3b3a38ea1d33 100644 --- a/pkgs/build-support/kernel/modules-closure.sh +++ b/pkgs/build-support/kernel/modules-closure.sh @@ -81,7 +81,8 @@ for module in $(cat closure); do for i in $(modinfo -b $kernel --set-version "$version" -F firmware $module | grep -v '^name:'); do mkdir -p "$out/lib/firmware/$(dirname "$i")" echo "firmware for $module: $i" - cp "$firmware/lib/firmware/$i" "$out/lib/firmware/$i" 2>/dev/null || if test -z "$allowMissing"; then exit 1; fi + cp "$firmware/lib/firmware/$i" "$out/lib/firmware/$i" 2>/dev/null \ + || echo "WARNING: missing firmware $i for module $module" done done -- cgit 1.4.1 From e4dae65515fa70434359723d72d2da61de4872f8 Mon Sep 17 00:00:00 2001 From: Dominik Xaver Hörl Date: Mon, 11 Jan 2021 22:13:51 +0100 Subject: writers: deduplicate binary stripping logic --- pkgs/build-support/writers/default.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'pkgs/build-support') diff --git a/pkgs/build-support/writers/default.nix b/pkgs/build-support/writers/default.nix index 9c709921d210..5945dc42c20e 100644 --- a/pkgs/build-support/writers/default.nix +++ b/pkgs/build-support/writers/default.nix @@ -63,7 +63,7 @@ rec { # # Examples: # writeSimpleC = makeBinWriter { compileScript = name: "gcc -o $out $contentPath"; } - makeBinWriter = { compileScript }: nameOrPath: content: + makeBinWriter = { compileScript, strip ? true }: nameOrPath: content: assert lib.or (types.path.check nameOrPath) (builtins.match "([0-9A-Za-z._])[0-9A-Za-z._-]*" nameOrPath != null); assert lib.or (types.path.check content) (types.str.check content); let @@ -76,6 +76,8 @@ rec { contentPath = content; }) '' ${compileScript} + ${ lib.optionalString strip + "${pkgs.binutils-unwrapped}/bin/strip --strip-unneeded $out" } ${optionalString (types.path.check nameOrPath) '' mv $out tmp mkdir -p $out/$(dirname "${nameOrPath}") @@ -131,7 +133,6 @@ rec { -Wall \ -x c \ "$contentPath" - strip --strip-unneeded "$out" ''; } name; @@ -172,7 +173,6 @@ rec { cp $contentPath tmp.hs ${ghc.withPackages (_: libraries )}/bin/ghc ${lib.escapeShellArgs ghcArgs} tmp.hs mv tmp $out - ${pkgs.binutils-unwrapped}/bin/strip --strip-unneeded "$out" ''; } name; -- cgit 1.4.1 From c6ff4f7143fc3b45c523ec6b77c0420aad4c8873 Mon Sep 17 00:00:00 2001 From: Dominik Xaver Hörl Date: Mon, 11 Jan 2021 22:14:33 +0100 Subject: writers: add rust --- pkgs/build-support/writers/default.nix | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) (limited to 'pkgs/build-support') diff --git a/pkgs/build-support/writers/default.nix b/pkgs/build-support/writers/default.nix index 5945dc42c20e..89edbd513d50 100644 --- a/pkgs/build-support/writers/default.nix +++ b/pkgs/build-support/writers/default.nix @@ -76,8 +76,8 @@ rec { contentPath = content; }) '' ${compileScript} - ${ lib.optionalString strip - "${pkgs.binutils-unwrapped}/bin/strip --strip-unneeded $out" } + ${lib.optionalString strip + "${pkgs.binutils-unwrapped}/bin/strip --strip-unneeded $out"} ${optionalString (types.path.check nameOrPath) '' mv $out tmp mkdir -p $out/$(dirname "${nameOrPath}") @@ -111,7 +111,10 @@ rec { # return 0; # } # '' - writeC = name: { libraries ? [] }: + writeC = name: { + libraries ? [], + strip ? true + }: makeBinWriter { compileScript = '' PATH=${makeBinPath [ @@ -134,6 +137,7 @@ rec { -x c \ "$contentPath" ''; + inherit strip; } name; # writeCBin takes the same arguments as writeC but outputs a directory (like writeScriptBin) @@ -166,7 +170,8 @@ rec { writeHaskell = name: { libraries ? [], ghc ? pkgs.ghc, - ghcArgs ? [] + ghcArgs ? [], + strip ? true }: makeBinWriter { compileScript = '' @@ -174,12 +179,29 @@ rec { ${ghc.withPackages (_: libraries )}/bin/ghc ${lib.escapeShellArgs ghcArgs} tmp.hs mv tmp $out ''; + inherit strip; } name; # writeHaskellBin takes the same arguments as writeHaskell but outputs a directory (like writeScriptBin) writeHaskellBin = name: writeHaskell "/bin/${name}"; + writeRust = name: { + rustc ? pkgs.rustc, + rustcArgs ? [], + strip ? true + }: + makeBinWriter { + compileScript = '' + cp "$contentPath" tmp.rs + PATH=${makeBinPath [pkgs.gcc]} ${lib.getBin rustc}/bin/rustc ${lib.escapeShellArgs rustcArgs} -o "$out" tmp.rs + ''; + inherit strip; + } name; + + writeRustBin = name: + writeRust "/bin/${name}"; + # writeJS takes a name an attributeset with libraries and some JavaScript sourcecode and # returns an executable # -- cgit 1.4.1 From 14205a64294c3a14c3b3121bbe05ada82afe3e72 Mon Sep 17 00:00:00 2001 From: Dominik Xaver Hörl Date: Tue, 12 Jan 2021 11:03:08 +0100 Subject: writers: add test for rust --- pkgs/build-support/writers/test.nix | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'pkgs/build-support') diff --git a/pkgs/build-support/writers/test.nix b/pkgs/build-support/writers/test.nix index d284bda43d05..0febad2929a0 100644 --- a/pkgs/build-support/writers/test.nix +++ b/pkgs/build-support/writers/test.nix @@ -31,6 +31,12 @@ let test '~' = '~' && echo 'success' ''; + rust = writeRustBin "test_writers" {} '' + fn main(){ + println!("success") + } + ''; + haskell = writeHaskellBin "test_writers" { libraries = [ haskellPackages.acme-default ]; } '' import Data.Default -- cgit 1.4.1