Skip to content

Commit 36a13f9

Browse files
committed
staging-next 2024-08-23 (#336718)
2 parents f89e865 + 20766c8 commit 36a13f9

File tree

266 files changed

+7440
-7127
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

266 files changed

+7440
-7127
lines changed

doc/languages-frameworks/go.section.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,65 @@ The following is an example expression using `buildGoModule`:
6262
}
6363
```
6464

65+
### Obtaining and overriding `vendorHash` for `buildGoModule` {#buildGoModule-vendorHash}
66+
67+
We can use `nix-prefetch` to obtain the actual hash. The following command gets the value of `vendorHash` for package `pet`:
68+
69+
```sh
70+
cd path/to/nixpkgs
71+
nix-prefetch -E "{ sha256 }: ((import ./. { }).my-package.overrideAttrs { vendorHash = sha256; }).goModules"
72+
```
73+
74+
To obtain the hash without external tools, set `vendorHash = lib.fakeHash;` and run the build. ([more details here](#sec-source-hashes)).
75+
76+
`vendorHash` can be overridden with `overrideAttrs`. Override the above example like this:
77+
78+
```nix
79+
{
80+
pet_0_4_0 = pet.overrideAttrs (
81+
finalAttrs: previousAttrs: {
82+
version = "0.4.0";
83+
src = fetchFromGitHub {
84+
inherit (previousAttrs.src) owner repo;
85+
rev = "v${finalAttrs.version}";
86+
hash = "sha256-gVTpzmXekQxGMucDKskGi+e+34nJwwsXwvQTjRO6Gdg=";
87+
};
88+
vendorHash = "sha256-dUvp7FEW09V0xMuhewPGw3TuAic/sD7xyXEYviZ2Ivs=";
89+
}
90+
);
91+
}
92+
```
93+
94+
### Overriding `goModules` {#buildGoModule-goModules-override}
95+
96+
Overriding `<pkg>.goModules` by calling `goModules.overrideAttrs` is unsupported. Still, it is possible to override the `vendorHash` (`goModules`'s `outputHash`) and the `pre`/`post` hooks for both the build and patch phases of the primary and `goModules` derivation. Alternatively, the primary derivation provides an overridable `passthru.overrideModAttrs` function to store the attribute overlay implicitly taken by `goModules.overrideAttrs`. Here's an example usage of `overrideModAttrs`:
97+
98+
```nix
99+
{
100+
pet-overridden = pet.overrideAttrs (
101+
finalAttrs: previousAttrs: {
102+
passthru = previousAttrs.passthru // {
103+
# If the original package has an `overrideModAttrs` attribute set, you'd
104+
# want to extend it, and not replace it. Hence we use
105+
# `lib.composeExtensions`. If you are sure the `overrideModAttrs` of the
106+
# original package trivially does nothing, you can safely replace it
107+
# with your own by not using `lib.composeExtensions`.
108+
overrideModAttrs = lib.composeExtensions previousAttrs.passthru.overrideModAttrs (
109+
finalModAttrs: previousModAttrs: {
110+
# goModules-specific overriding goes here
111+
postBuild = ''
112+
# Here you have access to the `vendor` directory.
113+
substituteInPlace vendor/github.com/example/repo/file.go \
114+
--replace-fail "panic(err)" ""
115+
'';
116+
}
117+
);
118+
};
119+
}
120+
);
121+
}
122+
```
123+
65124
## `buildGoPackage` (legacy) {#ssec-go-legacy}
66125

67126
The function `buildGoPackage` builds legacy Go programs, not supporting Go modules.

doc/languages-frameworks/ruby.section.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Using Ruby {#using-ruby}
44

5-
Several versions of Ruby interpreters are available on Nix, as well as over 250 gems and many applications written in Ruby. The attribute `ruby` refers to the default Ruby interpreter, which is currently MRI 3.1. It's also possible to refer to specific versions, e.g. `ruby_3_y`, `jruby`, or `mruby`.
5+
Several versions of Ruby interpreters are available on Nix, as well as over 250 gems and many applications written in Ruby. The attribute `ruby` refers to the default Ruby interpreter, which is currently MRI 3.3. It's also possible to refer to specific versions, e.g. `ruby_3_y`, `jruby`, or `mruby`.
66

77
In the Nixpkgs tree, Ruby packages can be found throughout, depending on what they do, and are called from the main package set. Ruby gems, however are separate sets, and there's one default set for each interpreter (currently MRI only).
88

lib/strings.nix

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,7 +1026,8 @@ rec {
10261026
replaceStrings (builtins.attrNames toEscape) (lib.mapAttrsToList (_: c: "%${fixedWidthString 2 "0" (lib.toHexString c)}") toEscape);
10271027

10281028
/**
1029-
Quote `string` to be used safely within the Bourne shell.
1029+
Quote `string` to be used safely within the Bourne shell if it has any
1030+
special characters.
10301031
10311032
10321033
# Inputs
@@ -1051,10 +1052,17 @@ rec {
10511052
10521053
:::
10531054
*/
1054-
escapeShellArg = arg: "'${replaceStrings ["'"] ["'\\''"] (toString arg)}'";
1055+
escapeShellArg = arg:
1056+
let
1057+
string = toString arg;
1058+
in
1059+
if match "[[:alnum:],._+:@%/-]+" string == null
1060+
then "'${replaceStrings ["'"] ["'\\''"] string}'"
1061+
else string;
10551062

10561063
/**
1057-
Quote all arguments to be safely passed to the Bourne shell.
1064+
Quote all arguments that have special characters to be safely passed to the
1065+
Bourne shell.
10581066
10591067
# Inputs
10601068
@@ -1073,7 +1081,7 @@ rec {
10731081
10741082
```nix
10751083
escapeShellArgs ["one" "two three" "four'five"]
1076-
=> "'one' 'two three' 'four'\\''five'"
1084+
=> "one 'two three' 'four'\\''five'"
10771085
```
10781086
10791087
:::

lib/tests/misc.nix

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,26 @@ runTests {
470470
expected = [ "A" "B" ];
471471
};
472472

473+
testEscapeShellArg = {
474+
expr = strings.escapeShellArg "esc'ape\nme";
475+
expected = "'esc'\\''ape\nme'";
476+
};
477+
478+
testEscapeShellArgEmpty = {
479+
expr = strings.escapeShellArg "";
480+
expected = "''";
481+
};
482+
483+
testEscapeShellArgs = {
484+
expr = strings.escapeShellArgs ["one" "two three" "four'five"];
485+
expected = "one 'two three' 'four'\\''five'";
486+
};
487+
488+
testEscapeShellArgsUnicode = {
489+
expr = strings.escapeShellArg "á";
490+
expected = "'á'";
491+
};
492+
473493
testSplitStringsDerivation = {
474494
expr = take 3 (strings.splitString "/" (derivation {
475495
name = "name";
@@ -569,12 +589,12 @@ runTests {
569589
'';
570590
expected = ''
571591
STRing01='just a '\'''string'\''''
572-
declare -a _array_=('with' 'more strings')
592+
declare -a _array_=(with 'more strings')
573593
declare -A assoc=(['with some']='strings
574594
possibly newlines
575595
')
576-
drv='/drv'
577-
path='/path'
596+
drv=/drv
597+
path=/path
578598
stringable='hello toString'
579599
'';
580600
};
@@ -1754,7 +1774,7 @@ runTests {
17541774
verbose = true;
17551775
};
17561776

1757-
expected = "'-X' 'PUT' '--data' '{\"id\":0}' '--retry' '3' '--url' 'https://example.com/foo' '--url' 'https://example.com/bar' '--verbose'";
1777+
expected = "-X PUT --data '{\"id\":0}' --retry 3 --url https://example.com/foo --url https://example.com/bar --verbose";
17581778
};
17591779

17601780
testSanitizeDerivationNameLeadingDots = testSanitizeDerivationName {

nixos/doc/manual/release-notes/rl-2411.section.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,10 @@
383383
[buildRustPackage: Compiling Rust applications with Cargo](https://nixos.org/manual/nixpkgs/unstable/#compiling-rust-applications-with-cargo)
384384
for more information.
385385

386+
- The `vendorHash` of Go packages built with `buildGoModule` can now be overridden with `overrideAttrs`.
387+
`goModules`, `modRoot`, `vendorHash`, `deleteVendor`, and `proxyVendor` are now passed as derivation attributes.
388+
`goModules` and `vendorHash` are no longer placed under `passthru`.
389+
386390
- `hareHook` has been added as the language framework for Hare. From now on, it,
387391
not the `hare` package, should be added to `nativeBuildInputs` when building
388392
Hare programs.

nixos/modules/config/fonts/fontconfig.nix

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,14 @@ let
180180
mkdir -p $dst
181181
182182
# fonts.conf
183-
ln -s ${pkg.out}/etc/fonts/fonts.conf \
183+
cp ${pkg.out}/etc/fonts/fonts.conf \
184184
$dst/../fonts.conf
185+
186+
# horrible sed hack to add the line that was accidentally removed
187+
# from the default config in #324516
188+
# FIXME: fix that, revert this
189+
sed "5i <include ignore_missing="yes">/etc/fonts/conf.d</include>" -i $dst/../fonts.conf
190+
185191
# TODO: remove this legacy symlink once people stop using packages built before #95358 was merged
186192
mkdir -p $out/etc/fonts/2.11
187193
ln -s /etc/fonts/fonts.conf \

pkgs/applications/accessibility/squeekboard/default.nix

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
, gtk3
1111
, wayland
1212
, wayland-protocols
13+
, wayland-scanner
1314
, libbsd
1415
, libxml2
1516
, libxkbcommon
@@ -44,7 +45,7 @@ stdenv.mkDerivation rec {
4445
ninja
4546
pkg-config
4647
glib
47-
wayland
48+
wayland-scanner
4849
wrapGAppsHook3
4950
rustPlatform.cargoSetupHook
5051
cargo

pkgs/applications/editors/emacs/build-support/elpa.nix

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,29 @@
33
{ lib, stdenv, emacs, texinfo, writeText }:
44

55
let
6-
handledArgs = [ "meta" ];
76
genericBuild = import ./generic.nix { inherit lib stdenv emacs texinfo writeText; };
7+
libBuildHelper = import ./lib-build-helper.nix;
88

99
in
1010

11+
libBuildHelper.extendMkDerivation' genericBuild (finalAttrs:
12+
1113
{ pname
12-
, version
13-
, src
14+
, dontUnpack ? true
1415
, meta ? {}
1516
, ...
1617
}@args:
1718

18-
genericBuild ({
19+
{
20+
21+
elpa2nix = args.elpa2nix or ./elpa2nix.el;
1922

20-
dontUnpack = true;
23+
inherit dontUnpack;
2124

22-
installPhase = ''
25+
installPhase = args.installPhase or ''
2326
runHook preInstall
2427
25-
emacs --batch -Q -l ${./elpa2nix.el} \
28+
emacs --batch -Q -l "$elpa2nix" \
2629
-f elpa2nix-install-package \
2730
"$src" "$out/share/emacs/site-lisp/elpa"
2831
@@ -34,4 +37,4 @@ genericBuild ({
3437
} // meta;
3538
}
3639

37-
// removeAttrs args handledArgs)
40+
)

pkgs/applications/editors/emacs/build-support/generic.nix

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
let
66
inherit (lib) optionalAttrs;
7-
handledArgs = [ "buildInputs" "nativeBuildInputs" "packageRequires" "propagatedUserEnvPkgs" "meta" ]
8-
++ lib.optionals (emacs.withNativeCompilation or false) [ "postInstall" ];
97

108
setupHook = writeText "setup-hook.sh" ''
119
source ${./emacs-funcs.sh}
@@ -21,13 +19,16 @@ let
2119
fi
2220
'';
2321

22+
libBuildHelper = import ./lib-build-helper.nix;
23+
2424
in
2525

26-
{ pname
27-
, version
28-
, buildInputs ? []
26+
libBuildHelper.extendMkDerivation' stdenv.mkDerivation (finalAttrs:
27+
28+
{ buildInputs ? []
2929
, nativeBuildInputs ? []
3030
, packageRequires ? []
31+
, propagatedBuildInputs ? []
3132
, propagatedUserEnvPkgs ? []
3233
, postInstall ? ""
3334
, meta ? {}
@@ -36,10 +37,10 @@ in
3637
, ...
3738
}@args:
3839

39-
stdenv.mkDerivation (finalAttrs: ({
40-
name = "emacs-${pname}-${finalAttrs.version}";
40+
{
41+
name = args.name or "emacs-${finalAttrs.pname}-${finalAttrs.version}";
4142

42-
unpackCmd = ''
43+
unpackCmd = args.unpackCmd or ''
4344
case "$curSrc" in
4445
*.el)
4546
# keep original source filename without the hash
@@ -55,14 +56,13 @@ stdenv.mkDerivation (finalAttrs: ({
5556
esac
5657
'';
5758

58-
buildInputs = packageRequires ++ buildInputs;
59+
inherit packageRequires;
60+
buildInputs = finalAttrs.packageRequires ++ buildInputs;
5961
nativeBuildInputs = [ emacs texinfo ] ++ nativeBuildInputs;
60-
propagatedBuildInputs = packageRequires;
61-
propagatedUserEnvPkgs = packageRequires ++ propagatedUserEnvPkgs;
62-
63-
inherit setupHook;
62+
propagatedBuildInputs = finalAttrs.packageRequires ++ propagatedBuildInputs;
63+
propagatedUserEnvPkgs = finalAttrs.packageRequires ++ propagatedUserEnvPkgs;
6464

65-
doCheck = false;
65+
setupHook = args.setupHook or setupHook;
6666

6767
meta = {
6868
broken = false;
@@ -74,7 +74,7 @@ stdenv.mkDerivation (finalAttrs: ({
7474

7575
// optionalAttrs (emacs.withNativeCompilation or false) {
7676

77-
addEmacsNativeLoadPath = true;
77+
addEmacsNativeLoadPath = args.addEmacsNativeLoadPath or true;
7878

7979
inherit turnCompilationWarningToError ignoreCompilationError;
8080

@@ -97,4 +97,4 @@ stdenv.mkDerivation (finalAttrs: ({
9797
'' + postInstall;
9898
}
9999

100-
// removeAttrs args handledArgs))
100+
)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
extendMkDerivation' =
3+
mkDerivationBase: attrsOverlay: fpargs:
4+
(mkDerivationBase fpargs).overrideAttrs attrsOverlay;
5+
}

0 commit comments

Comments
 (0)