This commit is contained in:
ChaotiCryptidz 2022-01-24 21:18:03 +00:00
parent aff7a41105
commit 07e3d5b586
11 changed files with 96 additions and 27 deletions

View file

@ -3,7 +3,9 @@
"deploy-rs": {
"inputs": {
"flake-compat": "flake-compat",
"nixpkgs": "nixpkgs",
"nixpkgs": [
"nixpkgs"
],
"utils": "utils"
},
"locked": {
@ -38,7 +40,7 @@
},
"home-manager": {
"inputs": {
"nixpkgs": "nixpkgs_2"
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1642882610,
@ -55,22 +57,6 @@
}
},
"nixpkgs": {
"locked": {
"lastModified": 1632086102,
"narHash": "sha256-wVTcf0UclFS+zHtfPToB13jIO7n0U9N50MuRbPjQViE=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "e0ce3c683ae677cf5aab597d645520cddd13392b",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1643000262,
"narHash": "sha256-8hrbufiCcZgicU8UvHaRkruYuzM8z3lJvQkSh9ezMEg=",
@ -84,7 +70,7 @@
"type": "indirect"
}
},
"nixpkgs_3": {
"nixpkgs_2": {
"locked": {
"lastModified": 1642903813,
"narHash": "sha256-0lNfGW8sNfyTrixoQhVG00Drl/ECaf5GbfKAQ1ZDoyE=",
@ -104,7 +90,7 @@
"inputs": {
"deploy-rs": "deploy-rs",
"home-manager": "home-manager",
"nixpkgs": "nixpkgs_3"
"nixpkgs": "nixpkgs_2"
}
},
"utils": {

View file

@ -5,6 +5,7 @@
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
home-manager.url = "github:nix-community/home-manager";
deploy-rs.url = "github:serokell/deploy-rs";
deploy-rs.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { ... }@inputs: import ./outputs.nix inputs;

View file

@ -0,0 +1,3 @@
{ pkgs, inputs, ... }: {
home.packages = with pkgs; [ inputs.deploy-rs.defaultPackage.${pkgs.system} ];
}

View file

@ -7,6 +7,5 @@
tmux
socat
file
inputs.deploy-rs.defaultPackage.${pkgs.system}
];
}

View file

@ -1,5 +1,5 @@
{ tree, ... }: {
# basically everything apart from home.dev.debugging
# basically everything apart from home.all.dev.debugging and home.all.dev.deploy-rs
imports = with tree; [
home.dev.all.archives
home.dev.all.editors

View file

@ -1,4 +1,12 @@
{ pkgs, ... }: {
{ pkgs, lib, ... }: {
environment.systemPackages = with pkgs; [ mpc_cli ];
sound.enable = true;
hardware.pulseaudio = {
systemWide = true;
enable = true;
};
services.mpd = {
enable = true;
network.listenAddress = "0.0.0.0";
@ -23,6 +31,11 @@
always_on "yes"
tags "yes"
}
audio_output {
type "pulse"
name "Out"
server "lappy.tailscale-internal.genderfucked.monster"
}
'';
};

View file

@ -3,7 +3,7 @@
hardware.pulseaudio = {
extraConfig =
"load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1";
"load-module module-native-protocol-tcp auth-anonymous=1 auth-ip-acl=127.0.0.1;100.64.0.0/8";
};
environment.systemPackages = with pkgs; [ mpc_cli ];

52
hosts/raspberry/boot.nix Normal file
View file

@ -0,0 +1,52 @@
{ lib, pkgs, config, ... }: {
boot.loader.grub.enable = false;
boot.loader.generic-extlinux-compatible.enable = true;
boot.consoleLogLevel = lib.mkDefault 7;
# The serial ports listed here are:
# - ttyS0: for Tegra (Jetson TX1)
# - ttyAMA0: for QEMU's -machine virt
boot.kernelParams =
[ "console=tty0" ];
sdImage = {
populateFirmwareCommands = let
configTxt = pkgs.writeText "config.txt" ''
[pi3]
kernel=u-boot-rpi3.bin
[pi4]
kernel=u-boot-rpi4.bin
enable_gic=1
armstub=armstub8-gic.bin
# Otherwise the resolution will be weird in most cases, compared to
# what the pi3 firmware does by default.
disable_overscan=1
[all]
# Boot in 64-bit mode.
arm_64bit=1
# U-Boot needs this to work, regardless of whether UART is actually used or not.
# Look in arch/arm/mach-bcm283x/Kconfig in the U-Boot tree to see if this is still
# a requirement in the future.
enable_uart=1
# 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
'';
in ''
(cd ${pkgs.raspberrypifw}/share/raspberrypi/boot && cp bootcode.bin fixup*.dat start*.elf $NIX_BUILD_TOP/firmware/)
# Add the config
cp ${configTxt} firmware/config.txt
# Add pi3 specific files
cp ${pkgs.ubootRaspberryPi3_64bit}/u-boot.bin firmware/u-boot-rpi3.bin
# Add pi4 specific files
cp ${pkgs.ubootRaspberryPi4_64bit}/u-boot.bin firmware/u-boot-rpi4.bin
cp ${pkgs.raspberrypi-armstubs}/armstub8-gic.bin firmware/armstub8-gic.bin
cp ${pkgs.raspberrypifw}/share/raspberrypi/boot/bcm2711-rpi-4-b.dtb firmware/
'';
populateRootCommands = ''
mkdir -p ./files/boot
${config.boot.loader.generic-extlinux-compatible.populateCmd} -c ${config.system.build.toplevel} -d ./files/boot
'';
};
}

View file

@ -9,10 +9,13 @@
profiles.tailscale
profiles.sshd
# make bluetooth work on pi
hosts.raspberry.services.btattach
profiles.connectivity.bluetooth
profiles.connectivity.ios
(modulesPath + "/installer/sd-card/sd-image-aarch64.nix")
./boot.nix
(modulesPath + "/installer/sd-card/sd-image.nix")
];
home-manager.users.root = {
@ -22,7 +25,8 @@
imports = with tree; [ home.base home.dev.small ];
};
boot.kernelPackages = pkgs.linuxPackages_5_15;
boot.supportedFilesystems = lib.mkForce [ "vfat" ];
boot.kernelPackages = pkgs.linuxPackages_latest;
networking.hostName = "raspberry";
time.timeZone = "Europe/London";

View file

@ -0,0 +1,11 @@
{ pkgs, ... }: {
systemd.services.btattach = {
before = [ "bluetooth.service" ];
after = [ "dev-ttyAMA0.device" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
ExecStart =
"${pkgs.bluez}/bin/btattach -B /dev/ttyS1 -P bcm -S 3000000";
};
};
}

View file

@ -62,7 +62,7 @@ in {
username = "root";
profiles.system = {
user = "root";
path = deploy-rs.lib.x86_64-linux.activate.nixos
path = deploy-rs.lib.aarch64-linux.activate.nixos
self.nixosConfigurations.raspberry;
};
};