Skip to content

Commit

Permalink
Merge branch 'master' into gcc-7
Browse files Browse the repository at this point in the history
  • Loading branch information
shlevy committed Feb 18, 2018
2 parents ba5563b + a968868 commit 32ce701
Show file tree
Hide file tree
Showing 69 changed files with 1,706 additions and 150 deletions.
8 changes: 8 additions & 0 deletions lib/systems/examples.nix
Expand Up @@ -68,6 +68,14 @@ rec {
musl64 = { config = "x86_64-unknown-linux-musl"; };
musl32 = { config = "i686-unknown-linux-musl"; };

riscv = bits: {
config = "riscv${bits}-unknown-linux-gnu";
platform = platforms.riscv-multiplatform bits;
};
riscv64 = riscv "64";
riscv32 = riscv "32";


#
# Darwin
#
Expand Down
6 changes: 6 additions & 0 deletions lib/systems/platforms.nix
Expand Up @@ -541,6 +541,12 @@ rec {
};
};

riscv-multiplatform = bits: {
name = "riscv-multiplatform";
kernelArch = "riscv";
bfdEmulation = "elf${bits}lriscv";
};

selectBySystem = system: {
"i686-linux" = pc32;
"x86_64-linux" = pc64;
Expand Down
1 change: 1 addition & 0 deletions nixos/modules/module-list.nix
Expand Up @@ -694,6 +694,7 @@
./services/x11/xserver.nix
./system/activation/activation-script.nix
./system/activation/top-level.nix
./system/boot/binfmt.nix
./system/boot/coredump.nix
./system/boot/emergency-mode.nix
./system/boot/grow-partition.nix
Expand Down
6 changes: 5 additions & 1 deletion nixos/modules/services/mail/postfix.nix
Expand Up @@ -414,14 +414,18 @@ in
postmasterAlias = mkOption {
type = types.str;
default = "root";
description = "Who should receive postmaster e-mail.";
description = "
Who should receive postmaster e-mail. Multiple values can be added by
separating values with comma.
";
};

rootAlias = mkOption {
type = types.str;
default = "";
description = "
Who should receive root e-mail. Blank for no redirection.
Multiple values can be added by separating values with comma.
";
};

Expand Down
139 changes: 139 additions & 0 deletions nixos/modules/system/boot/binfmt.nix
@@ -0,0 +1,139 @@
{ config, lib, ... }:
let
inherit (lib) mkOption types optionalString;

cfg = config.boot.binfmtMiscRegistrations;

makeBinfmtLine = name: { recognitionType, offset, magicOrExtension
, mask, preserveArgvZero, openBinary
, matchCredentials, fixBinary, ...
}: let
type = if recognitionType == "magic" then "M" else "E";
offset' = toString offset;
mask' = toString mask;
interpreter = "/run/binfmt/${name}";
flags = if !(matchCredentials -> openBinary)
then throw "boot.binfmtMiscRegistrations.${name}: you can't specify openBinary = false when matchCredentials = true."
else optionalString preserveArgvZero "P" +
optionalString (openBinary && !matchCredentials) "O" +
optionalString matchCredentials "C" +
optionalString fixBinary "F";
in ":${name}:${type}:${offset'}:${magicOrExtension}:${mask'}:${interpreter}:${flags}";

binfmtFile = builtins.toFile "binfmt_nixos.conf"
(lib.concatStringsSep "\n" (lib.mapAttrsToList makeBinfmtLine cfg));

activationSnippet = name: { interpreter, ... }:
"ln -sf ${interpreter} /run/binfmt/${name}";
activationScript = ''
mkdir -p -m 0755 /run/binfmt
${lib.concatStringsSep "\n" (lib.mapAttrsToList activationSnippet cfg)}
'';
in {
options = {
boot.binfmtMiscRegistrations = mkOption {
default = {};

description = ''
Extra binary formats to register with the kernel.
See https://www.kernel.org/doc/html/latest/admin-guide/binfmt-misc.html for more details.
'';

type = types.attrsOf (types.submodule ({ config, ... }: {
options = {
recognitionType = mkOption {
default = "magic";
description = "Whether to recognize executables by magic number or extension.";
type = types.enum [ "magic" "extension" ];
};

offset = mkOption {
default = null;
description = "The byte offset of the magic number used for recognition.";
type = types.nullOr types.int;
};

magicOrExtension = mkOption {
description = "The magic number or extension to match on.";
type = types.str;
};

mask = mkOption {
default = null;
description =
"A mask to be ANDed with the byte sequence of the file before matching";
type = types.nullOr types.str;
};

interpreter = mkOption {
description = ''
The interpreter to invoke to run the program.
Note that the actual registration will point to
/run/binfmt/''${name}, so the kernel interpreter length
limit doesn't apply.
'';
type = types.path;
};

preserveArgvZero = mkOption {
default = false;
description = ''
Whether to pass the original argv[0] to the interpreter.
See the description of the 'P' flag in the kernel docs
for more details;
'';
type = types.bool;
};

openBinary = mkOption {
default = config.matchCredentials;
description = ''
Whether to pass the binary to the interpreter as an open
file descriptor, instead of a path.
'';
type = types.bool;
};

matchCredentials = mkOption {
default = false;
description = ''
Whether to launch with the credentials and security
token of the binary, not the interpreter (e.g. setuid
bit).
See the description of the 'C' flag in the kernel docs
for more details.
Implies/requires openBinary = true.
'';
type = types.bool;
};

fixBinary = mkOption {
default = false;
description = ''
Whether to open the interpreter file as soon as the
registration is loaded, rather than waiting for a
relevant file to be invoked.
See the description of the 'F' flag in the kernel docs
for more details.
'';
type = types.bool;
};
};
}));
};
};

config = lib.mkIf (cfg != {}) {
environment.etc."binfmt.d/nixos.conf".source = binfmtFile;
system.activationScripts.binfmt = activationScript;
systemd.additionalUpstreamSystemUnits =
[ "proc-sys-fs-binfmt_misc.automount"
"proc-sys-fs-binfmt_misc.mount"
];
};
}
36 changes: 33 additions & 3 deletions nixos/tests/home-assistant.nix
Expand Up @@ -2,17 +2,27 @@ import ./make-test.nix ({ pkgs, ... }:

let
configDir = "/var/lib/foobar";
apiPassword = "secret";

in {
name = "home-assistant";
meta = with pkgs.stdenv.lib; {
maintainers = with maintainers; [ dotlambda ];
};

nodes = {
hass =
{ config, pkgs, ... }:
{
environment.systemPackages = with pkgs; [
mosquitto
];
services.home-assistant = {
inherit configDir;
enable = true;
package = pkgs.home-assistant.override {
extraPackages = ps: with ps; [ hbmqtt ];
};
config = {
homeassistant = {
name = "Home";
Expand All @@ -22,7 +32,16 @@ in {
elevation = 0;
};
frontend = { };
http = { };
http.api_password = apiPassword;
mqtt = { }; # Use hbmqtt as broker
binary_sensor = [
{
platform = "mqtt";
state_topic = "home-assistant/test";
payload_on = "let_there_be_light";
payload_off = "off";
}
];
};
};
};
Expand All @@ -31,16 +50,27 @@ in {
testScript = ''
startAll;
$hass->waitForUnit("home-assistant.service");
# Since config is specified using a Nix attribute set,
# configuration.yaml is a link to the Nix store
$hass->succeed("test -L ${configDir}/configuration.yaml");
# Check that Home Assistant's web interface and API can be reached
$hass->waitForOpenPort(8123);
$hass->succeed("curl --fail http://localhost:8123/states");
$hass->succeed("curl --fail http://localhost:8123/api/ | grep 'API running'");
$hass->succeed("curl --fail -H 'x-ha-access: ${apiPassword}' http://localhost:8123/api/ | grep -qF 'API running'");
# Toggle a binary sensor using MQTT
$hass->succeed("curl http://localhost:8123/api/states/binary_sensor.mqtt_binary_sensor -H 'x-ha-access: ${apiPassword}' | grep -qF '\"state\": \"off\"'");
$hass->waitUntilSucceeds("mosquitto_pub -V mqttv311 -t home-assistant/test -u homeassistant -P '${apiPassword}' -m let_there_be_light");
$hass->succeed("curl http://localhost:8123/api/states/binary_sensor.mqtt_binary_sensor -H 'x-ha-access: ${apiPassword}' | grep -qF '\"state\": \"on\"'");
# Check that no errors were logged
$hass->fail("cat ${configDir}/home-assistant.log | grep -qF ERROR");
# Print log to ease debugging
my $log = $hass->succeed("cat ${configDir}/home-assistant.log");
print "\n### home-assistant.log ###\n";
print "$log\n";
'';
})
7 changes: 3 additions & 4 deletions pkgs/applications/misc/octoprint/default.nix
Expand Up @@ -54,14 +54,13 @@ let

in pythonPackages.buildPythonApplication rec {
name = "OctoPrint-${version}";
version = "1.3.5";
# 1.3.5, 2017-10-16, 77753ca02602d3a798d6b0a22535e6fd69ff448a
version = "1.3.6";

src = fetchFromGitHub {
owner = "foosel";
repo = "OctoPrint";
rev = version;
sha256 = "13krv9i6gm4jn4cb327q4qma4xwwashjnc0dia8vlnbjbbvkrni4";
sha256 = "0pgpkjw5zjnks5bky51gjaksq8mhrzkl52kpgf799hl35pd08xr3";
};

# We need old Tornado
Expand All @@ -70,7 +69,7 @@ in pythonPackages.buildPythonApplication rec {
semantic-version flask_principal werkzeug flaskbabel tornado
psutil pyserial flask_login netaddr markdown sockjs-tornado
pylru pyyaml sarge feedparser netifaces click websocket_client
scandir chainmap future dateutil futures wrapt
scandir chainmap future dateutil futures wrapt monotonic emoji
];

buildInputs = with pythonPackages; [ nose mock ddt ];
Expand Down
5 changes: 4 additions & 1 deletion pkgs/applications/misc/redshift/default.nix
Expand Up @@ -41,7 +41,10 @@ stdenv.mkDerivation rec {
pythonPath = [ pygobject3 pyxdg ];

preConfigure = "./bootstrap";
postFixup = "wrapPythonPrograms";
postFixup = ''
wrapPythonPrograms
rm "$out/share/icons/hicolor/icon-theme.cache"
'';

enableParallelBuilding = true;

Expand Down
18 changes: 14 additions & 4 deletions pkgs/applications/networking/browsers/palemoon/default.nix
Expand Up @@ -10,14 +10,14 @@

stdenv.mkDerivation rec {
name = "palemoon-${version}";
version = "27.6.2";
version = "27.7.2";

src = fetchFromGitHub {
name = "palemoon-src";
owner = "MoonchildProductions";
repo = "Pale-Moon";
rev = version + "_Release";
sha256 = "0ickxrwl36iyqj3v9qq6hnfl2y652f2ppwi949pfh4f6shm9x0ri";
sha256 = "19ki6gp6bhcvhjnclalviiyp93mqsgc22xjl0gm9x5y4sxdb5wlq";
};

desktopItem = makeDesktopItem {
Expand Down Expand Up @@ -101,10 +101,20 @@ stdenv.mkDerivation rec {

meta = with stdenv.lib; {
description = "A web browser";
longDescription = ''
Pale Moon is an Open Source, Goanna-based web browser focusing on
efficiency and customization.
Pale Moon offers you a browsing experience in a browser completely built
from its own, independently developed source that has been forked off from
Firefox/Mozilla code a number of years ago, with carefully selected
features and optimizations to improve the browser's stability and user
experience, while offering full customization and a growing collection of
extensions and themes to make the browser truly your own.
'';
homepage = https://www.palemoon.org/;
license = licenses.mpl20;
maintainers = with maintainers; [ rnhmjoj ];
maintainers = with maintainers; [ rnhmjoj AndersonTorres ];
platforms = platforms.linux;
};

}
Expand Up @@ -28,6 +28,7 @@ in stdenv.mkDerivation rec {
pythonPath = with python3Packages; [ pygobject3 pycairo ];

preFixup = ''
rm "$out/share/icons/hicolor/icon-theme.cache"
buildPythonPath "$out $pythonPath"
gappsWrapperArgs+=(--prefix PYTHONPATH : "$program_PYTHONPATH")
'';
Expand Down
6 changes: 3 additions & 3 deletions pkgs/applications/virtualization/qemu/default.nix
Expand Up @@ -18,8 +18,8 @@

with stdenv.lib;
let
version = "2.11.0";
sha256 = "1jvzw6rdhimn583dz6an8xiw07n3ycvxmj3jpv1s312scv3k9w64";
version = "2.11.1";
sha256 = "1jrcff0szyjxc3vywyiclwdzk0xgq4cxvjbvmcfyjcpdrq9j5pyr";
audio = optionalString (hasSuffix "linux" stdenv.system) "alsa,"
+ optionalString pulseSupport "pa,"
+ optionalString sdlSupport "sdl,";
Expand Down Expand Up @@ -61,7 +61,7 @@ stdenv.mkDerivation rec {

enableParallelBuilding = true;

patches = [ ./no-etc-install.patch ]
patches = [ ./no-etc-install.patch ./statfs-flags.patch ]
++ optional nixosTestRunner ./force-uid0-on-9p.patch
++ optional pulseSupport ./fix-hda-recording.patch;

Expand Down
20 changes: 20 additions & 0 deletions pkgs/applications/virtualization/qemu/riscv.nix
@@ -0,0 +1,20 @@
{ qemu, fetchFromGitHub, lib }: let
src = fetchFromGitHub {
owner = "riscv";
repo = "riscv-qemu";
rev = "af435b709d4a5de3ec2e59ff4dcd05b0b295a730";
sha256 = "1kqcsn8yfdg3zyd991i4v5dxznd1l4a4hjry9304lvsm3sz2wllw";
fetchSubmodules = true;
};
version = "2.11.50";
revCount = "58771";
shortRev = "af435b709d";
targets = [ "riscv32-linux-user" "riscv32-softmmu"
"riscv64-linux-user" "riscv64-softmmu"
];
in lib.overrideDerivation qemu (orig: {
name = "${(builtins.parseDrvName qemu.name).name}-${version}pre${revCount}_${shortRev}";
inherit src;
configureFlags = orig.configureFlags ++ [ "--target-list=${lib.concatStringsSep "," targets}" ];
postInstall = null;
})

0 comments on commit 32ce701

Please sign in to comment.