Compare commits
No commits in common. "50fbfdf4850f06a6dc0c189f81b39f431f1fe880" and "b418c9c89286a19ccbcb79ee9062ab777b6a3b35" have entirely different histories.
50fbfdf485
...
b418c9c892
40
README.org
40
README.org
|
@ -16,43 +16,3 @@
|
||||||
- Curated articles: information.nix
|
- Curated articles: information.nix
|
||||||
|
|
||||||
All the modules are imported in *configuration.nix*
|
All the modules are imported in *configuration.nix*
|
||||||
|
|
||||||
** Installation
|
|
||||||
|
|
||||||
1. Download the sdcard image
|
|
||||||
2. Connect a keyboard to the Raspberry Pi and set the password
|
|
||||||
|
|
||||||
#+begin_src shell
|
|
||||||
passwd
|
|
||||||
sudo su
|
|
||||||
passwd
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
The default user is nixos
|
|
||||||
|
|
||||||
3. Move the repo to the server and the agenix key
|
|
||||||
|
|
||||||
#+begin_src shell
|
|
||||||
scp -R Projects/zion zion:/home/nixos/system
|
|
||||||
scp .ssh/zion root@zion:/etc/ssh/id_ed25519
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
4. Increase the size of tmpfs
|
|
||||||
|
|
||||||
#+begin_src shell
|
|
||||||
sudo mount -o remount,size=4G /run/user/0
|
|
||||||
sudo mount -o remount,size=2G /run/user/1000
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
5. Rebuild the system using Flakes
|
|
||||||
|
|
||||||
#+begin_src shell
|
|
||||||
nix-shell -p git
|
|
||||||
sudo nixos-rebuild switch --flake /home/nixos/system#zion --impure
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
6. Restore the SQL databases
|
|
||||||
|
|
||||||
#+begin_src shell
|
|
||||||
psql -U postgres -f /vault/backups/zion/databases/all.sql
|
|
||||||
#+end_src
|
|
||||||
|
|
19
flake.nix
19
flake.nix
|
@ -3,29 +3,24 @@
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "nixpkgs/nixos-unstable";
|
nixpkgs.url = "nixpkgs/nixos-unstable";
|
||||||
agenix = {
|
agenix.url = "github:ryantm/agenix";
|
||||||
url = "github:ryantm/agenix";
|
agenix.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
|
||||||
};
|
|
||||||
nixos-hardware.url = "github:NixOS/nixos-hardware";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { self, nixpkgs, agenix, nixos-hardware, ... }@inputs:
|
outputs = { self, nixpkgs, agenix, ... }@inputs:
|
||||||
let
|
let
|
||||||
system = "aarch64-linux";
|
system = "aarch64-linux";
|
||||||
|
|
||||||
pkgs = import pkgs { inherit system; };
|
pkgs = import pkgs {
|
||||||
|
inherit system;
|
||||||
|
};
|
||||||
|
|
||||||
lib = nixpkgs.lib;
|
lib = nixpkgs.lib;
|
||||||
|
|
||||||
in {
|
in {
|
||||||
nixosConfigurations.zion = lib.nixosSystem {
|
nixosConfigurations.zion = lib.nixosSystem {
|
||||||
inherit system;
|
inherit system;
|
||||||
modules = [
|
modules = [ (import ./configuration.nix) agenix.nixosModules.age ];
|
||||||
(import ./configuration.nix)
|
|
||||||
agenix.nixosModules.age
|
|
||||||
nixos-hardware.nixosModules.raspberry-pi-4
|
|
||||||
];
|
|
||||||
specialArgs = { inherit inputs; };
|
specialArgs = { inherit inputs; };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -15,25 +15,37 @@ with pkgs;
|
||||||
];
|
];
|
||||||
|
|
||||||
# Enable SATA-HAT GPIO features
|
# Enable SATA-HAT GPIO features
|
||||||
boot.loader = {
|
boot.loader.grub.enable = false;
|
||||||
grub.enable = false;
|
|
||||||
generic-extlinux-compatible.enable = lib.mkForce false;
|
|
||||||
};
|
|
||||||
boot.loader.raspberryPi = {
|
boot.loader.raspberryPi = {
|
||||||
enable = true;
|
enable = true;
|
||||||
version = 4;
|
version = 4;
|
||||||
firmwareConfig = ''
|
firmwareConfig = ''
|
||||||
iomem=relaxed
|
iomem=relaxed
|
||||||
strict-devmem=0
|
strict-devmem=0
|
||||||
|
dtoverlay=pwm-2chan,pin=12,func=4,pin2=13,func2=4
|
||||||
dtoverlay=w1-gpio
|
dtoverlay=w1-gpio
|
||||||
|
dtparam=i2c1=on
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
boot.kernelModules = [ "pwm_bcm2835" "w1-gpio" "w1-therm" ];
|
|
||||||
# Load PWM hardware timers
|
# Load PWM hardware timers
|
||||||
hardware.raspberry-pi."4".pwm0.enable = true;
|
boot.kernelModules = [ "pwm_bcm2835" "w1-gpio" "w1-therm" ];
|
||||||
|
hardware.deviceTree = {
|
||||||
|
enable = true;
|
||||||
|
filter = "*-rpi-*.dtb";
|
||||||
|
overlays = [
|
||||||
|
{
|
||||||
|
name = "pwm-2chan";
|
||||||
|
dtboFile = "${device-tree_rpi.overlays}/pwm-2chan.dtbo";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
name = "w1-gpio";
|
||||||
|
dtboFile = "${device-tree_rpi.overlays}/w1-gpio.dtbo";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
# Enable I2C
|
# Enable I2C
|
||||||
hardware.raspberry-pi."4".i2c1.enable = true;
|
hardware.i2c.enable = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,14 +30,23 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
# Enable SATA HAT
|
# Enable SATA HAT
|
||||||
systemd.services.sata-hat = {
|
systemd.services.sata-hat = let
|
||||||
|
overlay-directory =
|
||||||
|
"/boot/nixos/4mamyanz1hlc4wz3c427qjh6rabngwvj-linux-5.10.17-1.20210303-dtbs/overlays/";
|
||||||
|
in {
|
||||||
description = "Enable software support for SATA Hat";
|
description = "Enable software support for SATA Hat";
|
||||||
wantedBy = [ "zfs-import.target" ];
|
wantedBy = [ "zfs-import.target" ];
|
||||||
script = ''
|
script = ''
|
||||||
${pkgs.bash}/bin/bash -c "/home/coolneng/system/scripts/SATA-hat.sh on"
|
${pkgs.bash}/bin/bash -c "/etc/nixos/scripts/SATA-hat.sh on"
|
||||||
|
'';
|
||||||
|
preStart = ''
|
||||||
|
${pkgs.libraspberrypi}/bin/dtoverlay -d ${overlay-directory} pwm-2chan pin=12 func=4 pin2=13 func2=4
|
||||||
|
${pkgs.libraspberrypi}/bin/dtoverlay -d ${overlay-directory} w1-gpio
|
||||||
'';
|
'';
|
||||||
preStop = ''
|
preStop = ''
|
||||||
${pkgs.bash}/bin/bash -c "/home/coolneng/system/scripts/SATA-hat.sh off"
|
${pkgs.libraspberrypi}/bin/dtoverlay -r -d ${overlay-directory} pwm-2chan
|
||||||
|
${pkgs.libraspberrypi}/bin/dtoverlay -r -d ${overlay-directory} w1-gpio
|
||||||
|
${pkgs.bash}/bin/bash -c "/etc/nixos/scripts/SATA-hat.sh off"
|
||||||
'';
|
'';
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = "oneshot";
|
Type = "oneshot";
|
||||||
|
|
Loading…
Reference in New Issue