Skip to content

Commit

Permalink
Merge master into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
FRidh committed Feb 8, 2018
2 parents 30d031b + 50a9d51 commit dc0e21d
Show file tree
Hide file tree
Showing 54 changed files with 1,516 additions and 1,022 deletions.
1 change: 1 addition & 0 deletions lib/maintainers.nix
Expand Up @@ -718,6 +718,7 @@
vandenoever = "Jos van den Oever <jos@vandenoever.info>";
vanschelven = "Klaas van Schelven <klaas@vanschelven.com>";
vanzef = "Ivan Solyankin <vanzef@gmail.com>";
varunpatro = "Varun Patro <varun.kumar.patro@gmail.com>";
vbgl = "Vincent Laporte <Vincent.Laporte@gmail.com>";
vbmithr = "Vincent Bernardoff <vb@luminar.eu.org>";
vcunat = "Vladimír Čunát <vcunat@gmail.com>";
Expand Down
18 changes: 15 additions & 3 deletions nixos/doc/manual/installation/changing-config.xml
Expand Up @@ -70,9 +70,21 @@ $ ./result/bin/run-*-vm
</screen>

The VM does not have any data from your host system, so your existing
user accounts and home directories will not be available. You can
forward ports on the host to the guest. For instance, the following
will forward host port 2222 to guest port 22 (SSH):
user accounts and home directories will not be available unless you
have set <literal>mutableUsers = false</literal>. Another way is to
temporarily add the following to your configuration:

<screen>
users.extraUsers.your-user.initialPassword = "test"
</screen>

<emphasis>Important:</emphasis> delete the $hostname.qcow2 file if you
have started the virtual machine at least once without the right
users, otherwise the changes will not get picked up.

You can forward ports on the host to the guest. For
instance, the following will forward host port 2222 to guest port 22
(SSH):

<screen>
$ QEMU_NET_OPTS="hostfwd=tcp::2222-:22" ./result/bin/run-*-vm
Expand Down
Expand Up @@ -43,11 +43,18 @@ in
sdImage = {
populateBootCommands = let
configTxt = pkgs.writeText "config.txt" ''
# Prevent the firmware from smashing the framebuffer setup done by the mainline kernel
# when attempting to show low-voltage or overtemperature warnings.
avoid_warnings=1
[pi2]
kernel=u-boot-rpi2.bin
[pi3]
kernel=u-boot-rpi3.bin
# U-Boot used to need this to work, regardless of whether UART is actually used or not.
# TODO: check when/if this can be removed.
enable_uart=1
'';
in ''
Expand Down
2 changes: 2 additions & 0 deletions nixos/modules/misc/ids.nix
Expand Up @@ -303,6 +303,7 @@
restya-board = 284;
mighttpd2 = 285;
hass = 286;
monero = 287;

# When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399!

Expand Down Expand Up @@ -574,6 +575,7 @@
restya-board = 284;
mighttpd2 = 285;
hass = 286;
monero = 287;

# When adding a gid, make sure it doesn't match an existing
# uid. Users and groups with the same name should have equal
Expand Down
1 change: 1 addition & 0 deletions nixos/modules/module-list.nix
Expand Up @@ -492,6 +492,7 @@
./services/networking/minidlna.nix
./services/networking/miniupnpd.nix
./services/networking/mosquitto.nix
./services/networking/monero.nix
./services/networking/miredo.nix
./services/networking/mstpd.nix
./services/networking/murmur.nix
Expand Down
21 changes: 20 additions & 1 deletion nixos/modules/services/misc/home-assistant.nix
Expand Up @@ -9,8 +9,27 @@ let

availableComponents = pkgs.home-assistant.availableComponents;

# Given component "parentConfig.platform", returns whether config.parentConfig
# is a list containing a set with set.platform == "platform".
#
# For example, the component sensor.luftdaten is used as follows:
# config.sensor = [ {
# platform = "luftdaten";
# ...
# } ];
useComponentPlatform = component:
let
path = splitString "." component;
parentConfig = attrByPath (init path) null cfg.config;
platform = last path;
in isList parentConfig && any
(item: item.platform or null == platform)
parentConfig;

# Returns whether component is used in config
useComponent = component: hasAttrByPath (splitString "." component) cfg.config;
useComponent = component:
hasAttrByPath (splitString "." component) cfg.config
|| useComponentPlatform component;

# List of components used in config
extraComponents = filter useComponent availableComponents;
Expand Down
238 changes: 238 additions & 0 deletions nixos/modules/services/networking/monero.nix
@@ -0,0 +1,238 @@
{ config, lib, pkgs, ... }:

with lib;

let
cfg = config.services.monero;
dataDir = "/var/lib/monero";

listToConf = option: list:
concatMapStrings (value: "${option}=${value}\n") list;

login = (cfg.rpc.user != null && cfg.rpc.password != null);

configFile = with cfg; pkgs.writeText "monero.conf" ''
log-file=/dev/stdout
data-dir=${dataDir}
${optionalString mining.enable ''
start-mining=${mining.address}
mining-threads=${toString mining.threads}
''}
rpc-bind-ip=${rpc.address}
rpc-bind-port=${toString rpc.port}
${optionalString login ''
rpc-login=${rpc.user}:${rpc.password}
''}
${optionalString rpc.restricted ''
restrict-rpc=1
''}
limit-rate-up=${toString limits.upload}
limit-rate-down=${toString limits.download}
max-concurrency=${toString limits.threads}
block-sync-size=${toString limits.syncSize}
${listToConf "add-peer" extraNodes}
${listToConf "add-priority-node" priorityNodes}
${listToConf "add-exclusive-node" exclusiveNodes}
${extraConfig}
'';

in

{

###### interface

options = {

services.monero = {

enable = mkEnableOption "Monero node daemon.";

mining.enable = mkOption {
type = types.bool;
default = false;
description = ''
Whether to mine moneroj.
'';
};

mining.address = mkOption {
type = types.str;
default = "";
description = ''
Monero address where to send mining rewards.
'';
};

mining.threads = mkOption {
type = types.addCheck types.int (x: x>=0);
default = 0;
description = ''
Number of threads used for mining.
Set to <literal>0</literal> to use all available.
'';
};

rpc.user = mkOption {
type = types.nullOr types.str;
default = null;
description = ''
User name for RPC connections.
'';
};

rpc.password = mkOption {
type = types.str;
default = null;
description = ''
Password for RPC connections.
'';
};

rpc.address = mkOption {
type = types.str;
default = "127.0.0.1";
description = ''
IP address the RPC server will bind to.
'';
};

rpc.port = mkOption {
type = types.int;
default = 18081;
description = ''
Port the RPC server will bind to.
'';
};

rpc.restricted = mkOption {
type = types.bool;
default = false;
description = ''
Whether to restrict RPC to view only commands.
'';
};

limits.upload = mkOption {
type = types.addCheck types.int (x: x>=-1);
default = -1;
description = ''
Limit of the upload rate in kB/s.
Set to <literal>-1</literal> to leave unlimited.
'';
};

limits.download = mkOption {
type = types.addCheck types.int (x: x>=-1);
default = -1;
description = ''
Limit of the download rate in kB/s.
Set to <literal>-1</literal> to leave unlimited.
'';
};

limits.threads = mkOption {
type = types.addCheck types.int (x: x>=0);
default = 0;
description = ''
Maximum number of threads used for a parallel job.
Set to <literal>0</literal> to leave unlimited.
'';
};

limits.syncSize = mkOption {
type = types.addCheck types.int (x: x>=0);
default = 0;
description = ''
Maximum number of blocks to sync at once.
Set to <literal>0</literal> for adaptive.
'';
};

extraNodes = mkOption {
type = types.listOf types.str;
default = [ ];
description = ''
List of additional peer IP addresses to add to the local list.
'';
};

priorityNodes = mkOption {
type = types.listOf types.str;
default = [ ];
description = ''
List of peer IP addresses to connect to and
attempt to keep the connection open.
'';
};

exclusiveNodes = mkOption {
type = types.listOf types.str;
default = [ ];
description = ''
List of peer IP addresses to connect to *only*.
If given the other peer options will be ignored.
'';
};

extraConfig = mkOption {
type = types.lines;
default = "";
description = ''
Extra lines to be added verbatim to monerod configuration.
'';
};

};

};


###### implementation

config = mkIf cfg.enable {

users.extraUsers = singleton {
name = "monero";
uid = config.ids.uids.monero;
description = "Monero daemon user";
home = dataDir;
createHome = true;
};

users.extraGroups = singleton {
name = "monero";
gid = config.ids.gids.monero;
};

systemd.services.monero = {
description = "monero daemon";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];

serviceConfig = {
User = "monero";
Group = "monero";
ExecStart = "${pkgs.monero}/bin/monerod --config-file=${configFile} --non-interactive";
Restart = "always";
SuccessExitStatus = [ 0 1 ];
};
};

assertions = singleton {
assertion = cfg.mining.enable -> cfg.mining.address != "";
message = ''
You need a Monero address to receive mining rewards:
specify one using option monero.mining.address.
'';
};

};

}

27 changes: 26 additions & 1 deletion nixos/modules/tasks/filesystems/zfs.nix
Expand Up @@ -24,7 +24,11 @@ let

kernel = config.boot.kernelPackages;

packages = if config.boot.zfs.enableUnstable then {
packages = if config.boot.zfs.enableLegacyCrypto then {
spl = kernel.splLegacyCrypto;
zfs = kernel.zfsLegacyCrypto;
zfsUser = pkgs.zfsLegacyCrypto;
} else if config.boot.zfs.enableUnstable then {
spl = kernel.splUnstable;
zfs = kernel.zfsUnstable;
zfsUser = pkgs.zfsUnstable;
Expand Down Expand Up @@ -75,6 +79,27 @@ in
'';
};

enableLegacyCrypto = mkOption {
type = types.bool;
default = false;
description = ''
Enabling this option will allow you to continue to use the old format for
encrypted datasets. With the inclusion of stability patches the format of
encrypted datasets has changed. They can still be accessed and mounted but
in read-only mode mounted. It is highly recommended to convert them to
the new format.
This option is only for convenience to people that cannot convert their
datasets to the new format yet and it will be removed in due time.
For migration strategies from old format to this new one, check the Wiki:
https://nixos.wiki/wiki/NixOS_on_ZFS#Encrypted_Dataset_Format_Change
See https://github.com/zfsonlinux/zfs/pull/6864 for more details about
the stability patches.
'';
};

extraPools = mkOption {
type = types.listOf types.str;
default = [];
Expand Down
3 changes: 2 additions & 1 deletion nixos/release-combined.nix
Expand Up @@ -52,7 +52,8 @@ in rec {
(all nixos.dummy)
(all nixos.manual)

(all nixos.iso_minimal)
nixos.iso_minimal.x86_64-linux
nixos.iso_minimal.i686-linux
nixos.iso_graphical.x86_64-linux
nixos.ova.x86_64-linux

Expand Down

0 comments on commit dc0e21d

Please sign in to comment.