Skip to content

Commit

Permalink
Merge remote-tracking branch 'nixos-nixpkgs/nixos-20.09' into nixos-2…
Browse files Browse the repository at this point in the history
…0.09_local
  • Loading branch information
luigy committed May 16, 2021
2 parents 7fe52fa + 17d3dab commit 2c2a831
Show file tree
Hide file tree
Showing 282 changed files with 12,248 additions and 7,358 deletions.
146 changes: 146 additions & 0 deletions .github/labeler.yml
@@ -0,0 +1,146 @@
"6.topic: agda":
- doc/languages-frameworks/agda.section.md
- nixos/tests/agda.nix
- pkgs/build-support/agda/**/*
- pkgs/development/libraries/agda/**/*
- pkgs/top-level/agda-packages.nix

"6.topic: cinnamon":
- pkgs/desktops/cinnamon/**/*

"6.topic: emacs":
- nixos/modules/services/editors/emacs.nix
- nixos/modules/services/editors/emacs.xml
- nixos/tests/emacs-daemon.nix
- pkgs/applications/editors/emacs-modes/**/*
- pkgs/applications/editors/emacs/**/*
- pkgs/build-support/emacs/**/*
- pkgs/top-level/emacs-packages.nix

"6.topic: erlang":
- doc/languages-frameworks/beam.section.md
- pkgs/development/beam-modules/**/*
- pkgs/development/interpreters/elixir/**/*
- pkgs/development/interpreters/erlang/**/*
- pkgs/development/tools/build-managers/rebar/**/*
- pkgs/development/tools/build-managers/rebar3/**/*
- pkgs/development/tools/erlang/**/*
- pkgs/top-level/beam-packages.nix

"6.topic: fetch":
- pkgs/build-support/fetch*/**/*

"6.topic: GNOME":
- doc/languages-frameworks/gnome.section.md
- nixos/modules/services/desktops/gnome3/**/*
- nixos/modules/services/x11/desktop-managers/gnome3.nix
- nixos/tests/gnome3-xorg.nix
- nixos/tests/gnome3.nix
- pkgs/desktops/gnome-3/**/*

"6.topic: golang":
- doc/languages-frameworks/go.section.md
- pkgs/development/compilers/go/**/*
- pkgs/development/go-modules/**/*
- pkgs/development/go-packages/**/*

"6.topic: haskell":
- doc/languages-frameworks/haskell.section.md
- pkgs/development/compilers/ghc/**/*
- pkgs/development/haskell-modules/**/*
- pkgs/development/tools/haskell/**/*
- pkgs/top-level/haskell-packages.nix

"6.topic: kernel":
- pkgs/build-support/kernel/**/*

"6.topic: lua":
- pkgs/development/interpreters/lua-5/**/*
- pkgs/development/interpreters/luajit/**/*
- pkgs/development/lua-modules/**/*
- pkgs/top-level/lua-packages.nix

"6.topic: nixos":
- nixos/**/*

"6.topic: ocaml":
- doc/languages-frameworks/ocaml.section.md
- pkgs/development/compilers/ocaml/**/*
- pkgs/development/compilers/reason/**/*
- pkgs/development/ocaml-modules/**/*
- pkgs/development/tools/ocaml/**/*
- pkgs/top-level/ocaml-packages.nix

"6.topic: pantheon":
- nixos/modules/services/desktops/pantheon/**/*
- nixos/modules/services/x11/desktop-managers/pantheon.nix
- nixos/modules/services/x11/display-managers/lightdm-greeters/pantheon.nix
- nixos/tests/pantheon.nix
- pkgs/desktops/pantheon/**/*

"6.topic: policy discussion":
- .github/**/*

"6.topic: printing":
- nixos/modules/services/printing/cupsd.nix
- pkgs/misc/cups/**/*

"6.topic: python":
- doc/languages-frameworks/python.section.md
- pkgs/development/interpreters/python/**/*
- pkgs/development/python-modules/**/*
- pkgs/top-level/python-packages.nix

"6.topic: qt/kde":
- doc/languages-frameworks/qt.section.md
- nixos/modules/services/x11/desktop-managers/plasma5.nix
- nixos/tests/plasma5.nix
- pkgs/applications/kde/**/*
- pkgs/desktops/plasma-5/**/*
- pkgs/development/libraries/kde-frameworks/**/*
- pkgs/development/libraries/qt-5/**/*

"6.topic: ruby":
- doc/languages-frameworks/ruby.section.md
- pkgs/development/interpreters/ruby/**/*
- pkgs/development/ruby-modules/**/*

"6.topic: rust":
- doc/languages-frameworks/rust.section.md
- pkgs/build-support/rust/**/*
- pkgs/development/compilers/rust/**/*

"6.topic: stdenv":
- pkgs/stdenv/**/*

"6.topic: steam":
- pkgs/games/steam/**/*

"6.topic: systemd":
- pkgs/os-specific/linux/systemd/**/*
- nixos/modules/system/boot/systemd*/**/*

"6.topic: TeX":
- doc/languages-frameworks/texlive.section.md
- pkgs/tools/typesetting/tex/**/*

"6.topic: vim":
- doc/languages-frameworks/vim.section.md
- pkgs/applications/editors/vim/**/*
- pkgs/misc/vim-plugins/**/*

"6.topic: xfce":
- nixos/doc/manual/configuration/xfce.xml
- nixos/modules/services/x11/desktop-managers/xfce.nix
- nixos/tests/xfce.nix
- pkgs/desktops/xfce/**/*

"8.has: changelog":
- nixos/doc/manual/release-notes/**/*

"8.has: documentation":
- doc/**/*
- nixos/doc/**/*

"8.has: module (update)":
- nixos/modules/**/*
14 changes: 14 additions & 0 deletions .github/workflows/labels.yml
@@ -0,0 +1,14 @@
name: "Label PR"

on:
pull_request_target:

jobs:
labels:
runs-on: ubuntu-latest
if: github.repository_owner == 'NixOS'
steps:
- uses: actions/labeler@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
sync-labels: true
5 changes: 5 additions & 0 deletions lib/licenses.nix
Expand Up @@ -115,6 +115,11 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
fullName = ''BSD 4-clause "Original" or "Old" License'';
};

bsdOriginalUC = spdx {
spdxId = "BSD-4-Clause-UC";
fullName = "BSD 4-Clause University of California-Specific";
};

bsdProtection = spdx {
spdxId = "BSD-Protection";
fullName = "BSD Protection License";
Expand Down
16 changes: 16 additions & 0 deletions maintainers/maintainer-list.nix
Expand Up @@ -926,6 +926,16 @@
githubId = 75235;
name = "Michael Walker";
};
bartuka = {
email = "wand@hey.com";
github = "wandersoncferreira";
githubId = 17708295;
name = "Wanderson Ferreira";
keys = [{
longkeyid = "rsa4096/0x56840A614DBE37AE";
fingerprint = "A3E1 C409 B705 50B3 BF41 492B 5684 0A61 4DBE 37AE";
}];
};
basvandijk = {
email = "v.dijk.bas@gmail.com";
github = "basvandijk";
Expand Down Expand Up @@ -7157,6 +7167,12 @@
githubId = 13752145;
name = "Richard Lupton";
};
rmcgibbo = {
email = "rmcgibbo@gmail.com";
github = "rmcgibbo";
githubId = 641278;
name = "Robert T. McGibbon";
};
rnhmjoj = {
email = "rnhmjoj@inventati.org";
github = "rnhmjoj";
Expand Down
22 changes: 21 additions & 1 deletion nixos/doc/manual/development/writing-nixos-tests.xml
Expand Up @@ -186,6 +186,25 @@ start_all()
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<methodname>get_screen_text_variants</methodname>
</term>
<listitem>
<para>
Return a list of different interpretations of what is currently visible
on the machine's screen using optical character recognition. The number
and order of the interpretations is not specified and is subject to
change, but if no exception is raised at least one will be returned.
</para>
<note>
<para>
This requires passing <option>enableOCR</option> to the test attribute
set.
</para>
</note>
</listitem>
</varlistentry>
<varlistentry>
<term>
<methodname>get_screen_text</methodname>
Expand Down Expand Up @@ -350,7 +369,8 @@ start_all()
<para>
Wait until the supplied regular expressions matches the textual contents
of the screen by using optical character recognition (see
<methodname>get_screen_text</methodname>).
<methodname>get_screen_text</methodname> and
<methodname>get_screen_text_variants</methodname>).
</para>
<note>
<para>
Expand Down
79 changes: 48 additions & 31 deletions nixos/lib/test-driver/test-driver.py
@@ -1,7 +1,7 @@
#! /somewhere/python3
from contextlib import contextmanager, _GeneratorContextManager
from queue import Queue, Empty
from typing import Tuple, Any, Callable, Dict, Iterator, Optional, List
from typing import Tuple, Any, Callable, Dict, Iterator, Optional, List, Iterable
from xml.sax.saxutils import XMLGenerator
import queue
import io
Expand Down Expand Up @@ -206,6 +206,37 @@ def nested(self, message: str, attributes: Dict[str, str] = {}) -> Iterator[None
self.xml.endElement("nest")


def _perform_ocr_on_screenshot(
screenshot_path: str, model_ids: Iterable[int]
) -> List[str]:
if shutil.which("tesseract") is None:
raise Exception("OCR requested but enableOCR is false")

magick_args = (
"-filter Catrom -density 72 -resample 300 "
+ "-contrast -normalize -despeckle -type grayscale "
+ "-sharpen 1 -posterize 3 -negate -gamma 100 "
+ "-blur 1x65535"
)

tess_args = f"-c debug_file=/dev/null --psm 11"

cmd = f"convert {magick_args} {screenshot_path} tiff:{screenshot_path}.tiff"
ret = subprocess.run(cmd, shell=True, capture_output=True)
if ret.returncode != 0:
raise Exception(f"TIFF conversion failed with exit code {ret.returncode}")

model_results = []
for model_id in model_ids:
cmd = f"tesseract {screenshot_path}.tiff - {tess_args} --oem {model_id}"
ret = subprocess.run(cmd, shell=True, capture_output=True)
if ret.returncode != 0:
raise Exception(f"OCR failed with exit code {ret.returncode}")
model_results.append(ret.stdout.decode("utf-8"))

return model_results


class Machine:
def __init__(self, args: Dict[str, Any]) -> None:
if "name" in args:
Expand Down Expand Up @@ -639,43 +670,29 @@ def dump_tty_contents(self, tty: str) -> None:
"""
self.execute("fold -w 80 /dev/vcs{} | systemd-cat".format(tty))

def get_screen_text(self) -> str:
if shutil.which("tesseract") is None:
raise Exception("get_screen_text used but enableOCR is false")

magick_args = (
"-filter Catrom -density 72 -resample 300 "
+ "-contrast -normalize -despeckle -type grayscale "
+ "-sharpen 1 -posterize 3 -negate -gamma 100 "
+ "-blur 1x65535"
)

tess_args = "-c debug_file=/dev/null --psm 11 --oem 2"
def _get_screen_text_variants(self, model_ids: Iterable[int]) -> List[str]:
with tempfile.TemporaryDirectory() as tmpdir:
screenshot_path = os.path.join(tmpdir, "ppm")
self.send_monitor_command(f"screendump {screenshot_path}")
return _perform_ocr_on_screenshot(screenshot_path, model_ids)

with self.nested("performing optical character recognition"):
with tempfile.NamedTemporaryFile() as tmpin:
self.send_monitor_command("screendump {}".format(tmpin.name))

cmd = "convert {} {} tiff:- | tesseract - - {}".format(
magick_args, tmpin.name, tess_args
)
ret = subprocess.run(cmd, shell=True, capture_output=True)
if ret.returncode != 0:
raise Exception(
"OCR failed with exit code {}".format(ret.returncode)
)
def get_screen_text_variants(self) -> List[str]:
return self._get_screen_text_variants([0, 1, 2])

return ret.stdout.decode("utf-8")
def get_screen_text(self) -> str:
return self._get_screen_text_variants([2])[0]

def wait_for_text(self, regex: str) -> None:
def screen_matches(last: bool) -> bool:
text = self.get_screen_text()
matches = re.search(regex, text) is not None
variants = self.get_screen_text_variants()
for text in variants:
if re.search(regex, text) is not None:
return True

if last and not matches:
self.log("Last OCR attempt failed. Text was: {}".format(text))
if last:
self.log("Last OCR attempt failed. Text was: {}".format(variants))

return matches
return False

with self.nested("waiting for {} to appear on screen".format(regex)):
retry(screen_matches)
Expand Down
8 changes: 4 additions & 4 deletions nixos/modules/installer/tools/nix-fallback-paths.nix
@@ -1,6 +1,6 @@
{
x86_64-linux = "/nix/store/iwfs2bfcy7lqwhri94p2i6jc87ih55zk-nix-2.3.10";
i686-linux = "/nix/store/a3ccfvy9i5n418d5v0bir330kbcz3vj8-nix-2.3.10";
aarch64-linux = "/nix/store/bh5g6cv7bv35iz853d3xv2sphn51ybmb-nix-2.3.10";
x86_64-darwin = "/nix/store/8c98r6zlwn2d40qm7jnnrr2rdlqviszr-nix-2.3.10";
x86_64-linux = "/nix/store/d1ppfhjhdwcsb4npfzyifv5z8i00fzsk-nix-2.3.11";
i686-linux = "/nix/store/c6ikndcrzwpfn2sb5b9xb1f17p9b8iga-nix-2.3.11";
aarch64-linux = "/nix/store/fb0lfrn0m8s197d264jzd64vhz9c8zbx-nix-2.3.11";
x86_64-darwin = "/nix/store/qvb86ffv08q3r66qbd6nqifz425lyyhf-nix-2.3.11";
}
14 changes: 10 additions & 4 deletions nixos/modules/security/acme.nix
Expand Up @@ -24,7 +24,7 @@ let
Type = "oneshot";
User = "acme";
Group = mkDefault "acme";
UMask = 0023;
UMask = 0022;
StateDirectoryMode = 750;
ProtectSystem = "full";
PrivateTmp = true;
Expand Down Expand Up @@ -274,9 +274,15 @@ let
set -euxo pipefail
${optionalString (data.webroot != null) ''
# Ensure the webroot exists
mkdir -p '${data.webroot}/.well-known/acme-challenge'
chown 'acme:${data.group}' ${data.webroot}/{.well-known,.well-known/acme-challenge}
# Ensure the webroot exists. Fixing group is required in case configuration was changed between runs.
# Lego will fail if the webroot does not exist at all.
(
mkdir -p '${data.webroot}/.well-known/acme-challenge' \
&& chgrp '${data.group}' ${data.webroot}/.well-known/acme-challenge
) || (
echo 'Please ensure ${data.webroot}/.well-known/acme-challenge exists and is writable by acme:${data.group}' \
&& exit 1
)
''}
echo '${domainHash}' > domainhash.txt
Expand Down
1 change: 1 addition & 0 deletions nixos/modules/services/misc/disnix.nix
Expand Up @@ -53,6 +53,7 @@ in

environment.systemPackages = [ pkgs.disnix ] ++ optional cfg.useWebServiceInterface pkgs.DisnixWebService;
environment.variables.PATH = lib.optionals cfg.enableProfilePath (map (profileName: "/nix/var/nix/profiles/disnix/${profileName}/bin" ) cfg.profiles);
environment.variables.DISNIX_REMOTE_CLIENT = lib.optionalString (cfg.enableMultiUser) "disnix-client";

services.dbus.enable = true;
services.dbus.packages = [ pkgs.disnix ];
Expand Down

0 comments on commit 2c2a831

Please sign in to comment.