Skip to content

Commit

Permalink
Merge staging-next into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Mar 9, 2023
2 parents f41a4ab + 1861620 commit 8cfd131
Show file tree
Hide file tree
Showing 85 changed files with 1,946 additions and 262 deletions.
34 changes: 29 additions & 5 deletions lib/modules.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ let
isBool
isFunction
isList
isPath
isString
length
mapAttrs
Expand All @@ -45,6 +46,9 @@ let
showOption
unknownModule
;
inherit (lib.strings)
isConvertibleWithToString
;

showDeclPrefix = loc: decl: prefix:
" - option(s) with prefix `${showOption (loc ++ [prefix])}' in module `${decl._file}'";
Expand Down Expand Up @@ -403,7 +407,7 @@ rec {
key = module.key;
module = module;
modules = collectedImports.modules;
disabled = module.disabledModules ++ collectedImports.disabled;
disabled = (if module.disabledModules != [] then [{ file = module._file; disabled = module.disabledModules; }] else []) ++ collectedImports.disabled;
}) initialModules);

# filterModules :: String -> { disabled, modules } -> [ Module ]
Expand All @@ -412,10 +416,30 @@ rec {
# modules recursively. It returns the final list of unique-by-key modules
filterModules = modulesPath: { disabled, modules }:
let
moduleKey = m: if isString m && (builtins.substring 0 1 m != "/")
then toString modulesPath + "/" + m
else toString m;
disabledKeys = map moduleKey disabled;
moduleKey = file: m:
if isString m
then
if builtins.substring 0 1 m == "/"
then m
else toString modulesPath + "/" + m

else if isConvertibleWithToString m
then
if m?key && m.key != toString m
then
throw "Module `${file}` contains a disabledModules item that is an attribute set that can be converted to a string (${toString m}) but also has a `.key` attribute (${m.key}) with a different value. This makes it ambiguous which module should be disabled."
else
toString m

else if m?key
then
m.key

else if isAttrs m
then throw "Module `${file}` contains a disabledModules item that is an attribute set, presumably a module, that does not have a `key` attribute. This means that the module system doesn't have any means to identify the module that should be disabled. Make sure that you've put the correct value in disabledModules: a string path relative to modulesPath, a path value, or an attribute set with a `key` attribute."
else throw "Each disabledModules item must be a path, string, or a attribute set with a key attribute, or a value supported by toString. However, one of the disabledModules items in `${toString file}` is none of that, but is of type ${builtins.typeOf m}.";

disabledKeys = concatMap ({ file, disabled }: map (moduleKey file) disabled) disabled;
keyFilter = filter (attrs: ! elem attrs.key disabledKeys);
in map (attrs: attrs.module) (builtins.genericClosure {
startSet = keyFilter modules;
Expand Down
12 changes: 12 additions & 0 deletions lib/tests/modules.sh
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,14 @@ checkConfigError "The option .*enable.* does not exist. Definition values:\n\s*-
checkConfigError "attribute .*enable.* in selection path .*config.enable.* not found" "$@" ./disable-define-enable.nix ./disable-declare-enable.nix
checkConfigError "attribute .*enable.* in selection path .*config.enable.* not found" "$@" ./disable-enable-modules.nix

checkConfigOutput '^true$' 'config.positive.enable' ./disable-module-with-key.nix
checkConfigOutput '^false$' 'config.negative.enable' ./disable-module-with-key.nix
checkConfigError 'Module ..*disable-module-bad-key.nix. contains a disabledModules item that is an attribute set, presumably a module, that does not have a .key. attribute. .*' 'config.enable' ./disable-module-bad-key.nix

# Not sure if we want to keep supporting module keys that aren't strings, paths or v?key, but we shouldn't remove support accidentally.
checkConfigOutput '^true$' 'config.positive.enable' ./disable-module-with-toString-key.nix
checkConfigOutput '^false$' 'config.negative.enable' ./disable-module-with-toString-key.nix

# Check _module.args.
set -- config.enable ./declare-enable.nix ./define-enable-with-custom-arg.nix
checkConfigError 'while evaluating the module argument .*custom.* in .*define-enable-with-custom-arg.nix.*:' "$@"
Expand Down Expand Up @@ -358,6 +366,10 @@ checkConfigOutput '^"The option `a\.b. defined in `.*/doRename-warnings\.nix. ha
config.result \
./doRename-warnings.nix

# Anonymous modules get deduplicated by key
checkConfigOutput '^"pear"$' config.once.raw ./merge-module-with-key.nix
checkConfigOutput '^"pear\\npear"$' config.twice.raw ./merge-module-with-key.nix

cat <<EOF
====== module tests ======
$pass Pass
Expand Down
16 changes: 16 additions & 0 deletions lib/tests/modules/disable-module-bad-key.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{ lib, ... }:
let
inherit (lib) mkOption types;

moduleWithKey = { config, ... }: {
config = {
enable = true;
};
};
in
{
imports = [
./declare-enable.nix
];
disabledModules = [ { } ];
}
34 changes: 34 additions & 0 deletions lib/tests/modules/disable-module-with-key.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{ lib, ... }:
let
inherit (lib) mkOption types;

moduleWithKey = {
key = "disable-module-with-key.nix#moduleWithKey";
config = {
enable = true;
};
};
in
{
options = {
positive = mkOption {
type = types.submodule {
imports = [
./declare-enable.nix
moduleWithKey
];
};
default = {};
};
negative = mkOption {
type = types.submodule {
imports = [
./declare-enable.nix
moduleWithKey
];
disabledModules = [ moduleWithKey ];
};
default = {};
};
};
}
34 changes: 34 additions & 0 deletions lib/tests/modules/disable-module-with-toString-key.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{ lib, ... }:
let
inherit (lib) mkOption types;

moduleWithKey = {
key = 123;
config = {
enable = true;
};
};
in
{
options = {
positive = mkOption {
type = types.submodule {
imports = [
./declare-enable.nix
moduleWithKey
];
};
default = {};
};
negative = mkOption {
type = types.submodule {
imports = [
./declare-enable.nix
moduleWithKey
];
disabledModules = [ 123 ];
};
default = {};
};
};
}
49 changes: 49 additions & 0 deletions lib/tests/modules/merge-module-with-key.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{ lib, ... }:
let
inherit (lib) mkOption types;

moduleWithoutKey = {
config = {
raw = "pear";
};
};

moduleWithKey = {
key = __curPos.file + "#moduleWithKey";
config = {
raw = "pear";
};
};

decl = {
options = {
raw = mkOption {
type = types.lines;
};
};
};
in
{
options = {
once = mkOption {
type = types.submodule {
imports = [
decl
moduleWithKey
moduleWithKey
];
};
default = {};
};
twice = mkOption {
type = types.submodule {
imports = [
decl
moduleWithoutKey
moduleWithoutKey
];
};
default = {};
};
};
}
3 changes: 2 additions & 1 deletion maintainers/maintainer-list.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8948,7 +8948,8 @@
githubId = 13547699;
name = "Corin Hoad";
keys = [{
fingerprint = "BA3A 5886 AE6D 526E 20B4 57D6 6A37 DF94 8318 8492";
# fingerprint = "BA3A 5886 AE6D 526E 20B4 57D6 6A37 DF94 8318 8492"; # old key, superseded
fingerprint = "6E69 6A19 4BD8 BFAE 7362 ACDB 6437 4619 95CA 7F16";
}];
};
lux = {
Expand Down
11 changes: 9 additions & 2 deletions nixos/doc/manual/development/replace-modules.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@ the system on a stable release.

`disabledModules` is a top level attribute like `imports`, `options` and
`config`. It contains a list of modules that will be disabled. This can
either be the full path to the module or a string with the filename
relative to the modules path (eg. \<nixpkgs/nixos/modules> for nixos).
either be:
- the full path to the module,
- or a string with the filename relative to the modules path (eg. \<nixpkgs/nixos/modules> for nixos),
- or an attribute set containing a specific `key` attribute.

The latter allows some modules to be disabled, despite them being distributed
via attributes instead of file paths. The `key` should be globally unique, so
it is recommended to include a file path in it, or rely on a framework to do it
for you.

This example will replace the existing postgresql module with the
version defined in the nixos-unstable channel while keeping the rest of
Expand Down
12 changes: 6 additions & 6 deletions pkgs/applications/editors/vscode/vscodium.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ let
archive_fmt = if stdenv.isDarwin then "zip" else "tar.gz";

sha256 = {
x86_64-linux = "1qayw19mb7f0gcgcvl57gpacrqsyx2jvc6s63vzbx8jmf5qnk71a";
x86_64-darwin = "02z9026kp66lx6pll46xx790jj7c7wh2ca7xim373x90k8hm4kwz";
aarch64-linux = "1izqhzvv46p05k1z2yg380ddwmar4w2pbrd0dyvkdysvp166y931";
aarch64-darwin = "1zcr653ssck4nc3vf04l6bilnjdsiqscw62g1wzbyk6s50133cx8";
armv7l-linux = "0n914rcfn2m9zsbnkd82cmw88qbpssv6jk3g8ig3wqlircbgrw0h";
x86_64-linux = "11w2gzhp0vlpygk93cksxhkimc9y8w862gn9450xkzi1jsps5lj4";
x86_64-darwin = "0ya17adx2vbi800ws5sfqq03lrjjk6kbclrfrc2zfij2ha05xl8z";
aarch64-linux = "15kzjs1ha5x2hcq28nkbb0rim1v694jj6p9sz226rai3bmq9airg";
aarch64-darwin = "1cggppblr42jzpcz3g8052w5y1b9392iizpvg6y7001kw66ndp3n";
armv7l-linux = "01qqhhl5ffvba1pk4jj3q7sbahq7cvy81wvmgng1cmaj5b8m8dgp";
}.${system} or throwSystem;

sourceRoot = if stdenv.isDarwin then "" else ".";
Expand All @@ -29,7 +29,7 @@ in

# Please backport all compatible updates to the stable release.
# This is important for the extension ecosystem.
version = "1.75.0.23033";
version = "1.76.0.23062";
pname = "vscodium";

executableName = "codium";
Expand Down
4 changes: 2 additions & 2 deletions pkgs/applications/misc/mkgmap/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ let
in
stdenv.mkDerivation rec {
pname = "mkgmap";
version = "4906";
version = "4907";

src = fetchsvn {
url = "https://svn.mkgmap.org.uk/mkgmap/mkgmap/trunk";
rev = version;
sha256 = "sha256-N1VU5XOENCQiUnDCFpotx+8Pr3VFuWLu1ABcbm0feOM=";
sha256 = "sha256-2DwIH6GNsK2XwaVxzPvN1qt4XRSi5fCQDwltBCBg4gI=";
};

patches = [
Expand Down
14 changes: 12 additions & 2 deletions pkgs/applications/misc/organicmaps/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@
, zlib
, icu
, freetype
, pugixml
, nix-update-script
}:

mkDerivation rec {
pname = "organicmaps";
version = "2023.01.25-3";
version = "2023.03.05-5";

src = fetchFromGitHub {
owner = "organicmaps";
repo = "organicmaps";
rev = "${version}-android";
sha256 = "sha256-4nlD/GFOoBOCXVWtC7i6SUquEbob5++GyagZOTznygU=";
sha256 = "sha256-PfudozmrL8jNS/99nxSn0B3E53W34m4/ZN0y2ucB2WI=";
fetchSubmodules = true;
};

Expand Down Expand Up @@ -55,13 +57,21 @@ mkDerivation rec {
zlib
icu
freetype
pugixml
];

# Yes, this is PRE configure. The configure phase uses cmake
preConfigure = ''
bash ./configure.sh
'';

passthru = {
updateScript = nix-update-script {
attrPath = pname;
extraArgs = [ "-vr" "(.*)-android" ];
};
};

meta = with lib; {
# darwin: "invalid application of 'sizeof' to a function type"
broken = (stdenv.isLinux && stdenv.isAarch64) || stdenv.isDarwin;
Expand Down
16 changes: 13 additions & 3 deletions pkgs/applications/networking/browsers/microsoft-edge/browser.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
{ stdenv
, fetchurl
, lib
, makeWrapper

, binutils-unwrapped
, xz
Expand Down Expand Up @@ -62,6 +63,10 @@ stdenv.mkDerivation rec {
inherit sha256;
};

nativeBuildInputs = [
makeWrapper
];

unpackCmd = "${binutils-unwrapped}/bin/ar p $src data.tar.xz | ${xz}/bin/xz -dc | ${gnutar}/bin/tar -xf -";
sourceRoot = ".";

Expand Down Expand Up @@ -170,16 +175,21 @@ stdenv.mkDerivation rec {
--replace /opt/microsoft/${shortName} $out/opt/microsoft/${shortName}
substituteInPlace $out/opt/microsoft/${shortName}/xdg-mime \
--replace "''${XDG_DATA_DIRS:-/usr/local/share:/usr/share}" "''${XDG_DATA_DIRS:-/run/current-system/sw/share}" \
--replace "\''${XDG_DATA_DIRS:-/usr/local/share:/usr/share}" "\''${XDG_DATA_DIRS:-/run/current-system/sw/share}" \
--replace "xdg_system_dirs=/usr/local/share/:/usr/share/" "xdg_system_dirs=/run/current-system/sw/share/" \
--replace /usr/bin/file ${file}/bin/file
substituteInPlace $out/opt/microsoft/${shortName}/default-app-block \
--replace /opt/microsoft/${shortName} $out/opt/microsoft/${shortName}
substituteInPlace $out/opt/microsoft/${shortName}/xdg-settings \
--replace "''${XDG_DATA_DIRS:-/usr/local/share:/usr/share}" "''${XDG_DATA_DIRS:-/run/current-system/sw/share}" \
--replace "''${XDG_CONFIG_DIRS:-/etc/xdg}" "''${XDG_CONFIG_DIRS:-/run/current-system/sw/etc/xdg}"
--replace "\''${XDG_DATA_DIRS:-/usr/local/share:/usr/share}" "\''${XDG_DATA_DIRS:-/run/current-system/sw/share}" \
--replace "\''${XDG_CONFIG_DIRS:-/etc/xdg}" "\''${XDG_CONFIG_DIRS:-/run/current-system/sw/etc/xdg}"
'';

postFixup = ''
wrapProgram "$out/bin/${longName}" \
--prefix XDG_DATA_DIRS : "${gtk3}/share/gsettings-schemas/${gtk3.pname}-${gtk3.version}"
'';

meta = with lib; {
Expand Down
Loading

0 comments on commit 8cfd131

Please sign in to comment.