2019-05-30 11:30:01 +00:00
|
|
|
{ config, pkgs, ... }:
|
|
|
|
|
|
|
|
{
|
|
|
|
imports = [
|
|
|
|
./basic-tools.nix
|
|
|
|
];
|
|
|
|
|
|
|
|
boot.loader.grub.enable = false;
|
|
|
|
|
|
|
|
boot.loader.raspberryPi = {
|
|
|
|
enable = true;
|
|
|
|
version = 3;
|
|
|
|
uboot.enable = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
# boot.kernelPackages = pkgs.linuxPackages_latest;
|
|
|
|
# boot.kernelPackages = pkgs.linuxPackages_4_18;
|
|
|
|
# boot.kernelPackages = pkgs.linuxPackages_latest;
|
|
|
|
boot.kernelPackages = pkgs.linuxPackages_rpi;
|
|
|
|
|
|
|
|
boot.kernelParams = [
|
|
|
|
"cma=32M" # for virtual console, see https://nixos.wiki/wiki/NixOS_on_ARM
|
|
|
|
"console=tty0"
|
|
|
|
];
|
|
|
|
|
|
|
|
hardware.enableRedistributableFirmware = true;
|
|
|
|
# hardware.firmware = with pkgs; [
|
|
|
|
# (stdenv.mkDerivation {
|
|
|
|
# name = "broadcom-rpi3bplus-extra";
|
|
|
|
# src = fetchurl {
|
|
|
|
# url = "https://raw.githubusercontent.com/RPi-Distro/firmware-nonfree/b518de4/brcm/brcmfmac43455-sdio.txt";
|
|
|
|
# sha256 = "0r4bvwkm3fx60bbpwd83zbjganjnffiq1jkaj0h20bwdj9ysawg9";
|
|
|
|
# };
|
|
|
|
# phases = [ "installPhase" ];
|
|
|
|
# installPhase = ''
|
|
|
|
# mkdir -p $out/lib/firmware/brcm
|
|
|
|
# cp $src $out/lib/firmware/brcm/brcmfmac43455-sdio.txt
|
|
|
|
# '';
|
|
|
|
# })
|
|
|
|
# ];
|
|
|
|
# networking.wireless.enable = true;
|
|
|
|
# networking.networkmanager.enable = true;
|
|
|
|
# networking.wireless.iwd.enable = true;
|
|
|
|
|
|
|
|
fileSystems = {
|
|
|
|
# "/boot" = {
|
|
|
|
# device = "/dev/disk/by-label/NIXOS_BOOT";
|
|
|
|
# fsType = "vfat";
|
|
|
|
# };
|
|
|
|
"/" = {
|
|
|
|
device = "/dev/disk/by-label/NIXOS_SD";
|
|
|
|
fsType = "ext4";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
networking.hostName = "murex";
|
|
|
|
#networking.hostId = "34a820f1";
|
|
|
|
|
|
|
|
time.timeZone = "Europe/Vienna";
|
|
|
|
|
|
|
|
environment.systemPackages = with pkgs; [
|
|
|
|
raspberrypi-tools
|
|
|
|
];
|
|
|
|
|
|
|
|
users.extraUsers.gebner = {
|
|
|
|
isNormalUser = true;
|
2019-05-30 14:51:30 +00:00
|
|
|
extraGroups = [ "wheel" "networkmanager" "audio" "dialout" ];
|
2019-05-30 11:30:01 +00:00
|
|
|
shell = pkgs.fish;
|
|
|
|
# password = if config.virtualisation != null then "" else null;
|
|
|
|
};
|
|
|
|
|
|
|
|
services.openssh = {
|
|
|
|
enable = true;
|
|
|
|
passwordAuthentication = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
documentation.nixos.enable = false;
|
|
|
|
|
|
|
|
services.octoprint = {
|
|
|
|
enable = true;
|
2019-05-30 12:43:03 +00:00
|
|
|
plugins = plugins: with pkgs; with python2Packages;
|
|
|
|
let rpi-gpio = buildPythonPackage rec {
|
|
|
|
pname = "RPi.GPIO";
|
|
|
|
version = "0.6.5";
|
|
|
|
src = fetchPypi {
|
|
|
|
inherit pname version;
|
|
|
|
sha256 = "a4210ad63bfe844e43995286de0d3950dfacfa0f3799bb9392770ac54a7d2e47";
|
|
|
|
};
|
|
|
|
}; in
|
|
|
|
[
|
2019-05-30 14:25:22 +00:00
|
|
|
# bundles binary which is not built for aarch64 :-(
|
|
|
|
# (buildPythonPackage rec {
|
|
|
|
# pname = "OctoPrint-PrintTimeGenius";
|
|
|
|
# version = "1.3";
|
|
|
|
# src = fetchFromGitHub {
|
|
|
|
# owner = "eyal0";
|
|
|
|
# repo = pname;
|
|
|
|
# rev = version;
|
|
|
|
# sha256 = "1jfiih8vpd1x5yk2yq9sgi0rbjh2ipasj39vs2dmfm3va2fhy75l";
|
|
|
|
# };
|
|
|
|
# propagatedBuildInputs = [ octoprint ];
|
|
|
|
# })
|
2019-05-30 12:43:03 +00:00
|
|
|
(buildPythonPackage rec {
|
|
|
|
pname = "OctoPrint-TouchUI";
|
|
|
|
version = "0.3.13";
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "BillyBlaze";
|
|
|
|
repo = pname;
|
|
|
|
rev = version;
|
|
|
|
sha256 = "0qk12ysabdzy6cna3l4f8v3qcnppppwxxsjx2i0xn1nd0cv6yzwh";
|
|
|
|
};
|
|
|
|
propagatedBuildInputs = [ octoprint ];
|
|
|
|
})
|
|
|
|
(buildPythonPackage rec {
|
|
|
|
pname = "OctoPrint-Cost";
|
|
|
|
version = "master";
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "jasiek";
|
|
|
|
repo = pname;
|
|
|
|
rev = "d1dc75aa64df332d54a237864a116c63cb9e6cf5";
|
|
|
|
sha256 = "0xkz1ygb5jspl1iy841lrv3fwm92ay09m6rw9g4vchwldqbgpjf3";
|
|
|
|
};
|
|
|
|
propagatedBuildInputs = [ octoprint ];
|
|
|
|
})
|
|
|
|
(buildPythonPackage rec {
|
|
|
|
pname = "OctoPrint-PSUControl";
|
|
|
|
version = "0.1.8";
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "kantlivelong";
|
|
|
|
repo = pname;
|
|
|
|
rev = version;
|
|
|
|
sha256 = "0aj38d7b7d5pzmzq841pip18cpg18wy2vrxq2nd13875597y54b8";
|
|
|
|
};
|
|
|
|
propagatedBuildInputs = [ octoprint rpi-gpio ];
|
|
|
|
})
|
|
|
|
];
|
2019-05-30 11:30:01 +00:00
|
|
|
};
|
2019-05-30 14:51:30 +00:00
|
|
|
systemd.services.setupGpioForRelais = rec {
|
|
|
|
wantedBy = [ "octoprint.service" ];
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "oneshot";
|
|
|
|
RemainAfterExit = "yes";
|
|
|
|
};
|
|
|
|
script = ''
|
|
|
|
if echo 17 > /sys/class/gpio/export; then
|
|
|
|
echo high > /sys/class/gpio/gpio17/direction
|
|
|
|
fi
|
2019-05-30 15:53:25 +00:00
|
|
|
chown octoprint:dialout /sys/class/gpio/gpio17/value
|
2019-05-30 14:51:30 +00:00
|
|
|
'';
|
|
|
|
};
|
2019-05-30 11:30:01 +00:00
|
|
|
users.users.${config.services.octoprint.user}.extraGroups = [
|
|
|
|
"dialout" # ttyUSB access
|
|
|
|
];
|
|
|
|
|
2019-05-31 17:21:58 +00:00
|
|
|
systemd.services.ethKernelPanicFix = rec {
|
|
|
|
wantedBy = [ "networking.target" ];
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "oneshot";
|
|
|
|
RemainAfterExit = "yes";
|
|
|
|
};
|
|
|
|
# https://github.com/raspberrypi/linux/issues/2449
|
|
|
|
script = ''
|
|
|
|
${pkgs.ethtool}/bin/ethtool -K eth0 tx-tcp-segmentation off tx-tcp6-segmentation off
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2019-05-30 11:30:01 +00:00
|
|
|
services.mjpg-streamer.enable = true;
|
|
|
|
|
|
|
|
networking.firewall = {
|
|
|
|
enable = true;
|
|
|
|
allowedTCPPorts = [
|
|
|
|
# config.services.octoprint.port
|
|
|
|
# 5050 # mjpg-streamer
|
|
|
|
80
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
services.nginx = {
|
|
|
|
enable = true;
|
|
|
|
recommendedTlsSettings = true;
|
|
|
|
recommendedOptimisation = true;
|
|
|
|
recommendedGzipSettings = true;
|
|
|
|
recommendedProxySettings = true;
|
|
|
|
|
|
|
|
virtualHosts."murex.mtlaa.gebner.org" = {
|
|
|
|
locations."/" = {
|
2019-05-30 12:43:03 +00:00
|
|
|
proxyPass = "http://localhost:${toString config.services.octoprint.port}";
|
2019-05-30 11:30:01 +00:00
|
|
|
proxyWebsockets = true;
|
|
|
|
};
|
|
|
|
locations."/webcam/".proxyPass = "http://localhost:5050/?action=stream";
|
2019-05-30 15:52:58 +00:00
|
|
|
locations."/webcampic/".proxyPass = "http://localhost:5050/?action=snapshot";
|
2019-05-30 11:30:01 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
system.stateVersion = "19.03";
|
|
|
|
}
|