aboutsummaryrefslogtreecommitdiff
path: root/nixos/modules
diff options
context:
space:
mode:
Diffstat (limited to 'nixos/modules')
-rw-r--r--nixos/modules/turris-board.nix68
-rw-r--r--nixos/modules/turris-defaults.nix84
2 files changed, 87 insertions, 65 deletions
diff --git a/nixos/modules/turris-board.nix b/nixos/modules/turris-board.nix
index 4b8aa0d..02b6dae 100644
--- a/nixos/modules/turris-board.nix
+++ b/nixos/modules/turris-board.nix
@@ -9,12 +9,6 @@ with lib;
type = types.enum [ "omnia" "mox" ];
description = "The unique Turris board identifier.";
};
-
- turris.device = mkOption {
- type = types.str;
- example = "/dev/mmcblk0";
- description = "The device used to boot the Turris system.";
- };
};
config = {
@@ -23,73 +17,17 @@ with lib;
message = "Turris board has to be specified";
}];
- # We do not need Grub as U-Boot supports boot using extlinux like file
- boot.loader.grub.enable = false;
- boot.loader.generic-extlinux-compatible.enable = true;
- # Use early print to the serial console
- boot.kernelParams = [
- "earlyprintk" "console=ttyMV0,115200" "earlycon=ar3700_uart,0xd0012000"
- "boot.shell_on_fail"
- ];
-
- # Use the latest kernel
- boot.kernelPackages = pkgs.linuxPackages_latest;
-
- # The supported deployment is on BTRFS
- boot.supportedFilesystems = [ "btrfs" ];
-
- # Cover nix memory consumption peaks by compressing the RAM
- zramSwap = {
- enable = true;
- memoryPercent = 100;
- };
- # Nix is really memory hungry so we have to sometimes also use swap device.
- # We expect that to be the second partition on the root device.
- swapDevices = [{
- device = config.turris.device + "p2";
- priority = 0;
- }];
-
- fileSystems = {
- # Root filesystem is expected to be on:
- # Mox: SD card
- # Omnia: internam MMC storage
- "/" = {
- device = config.turris.device + "p1";
- fsType = "btrfs";
- };
- };
-
- # The default hostname
- # TODO set this only if not already set
- networking.hostName = "nixturris";
-
# Enable flakes for nix as we are using that instead of legacy setup
nix = {
package = pkgs.nixFlakes;
extraOptions = "experimental-features = nix-command flakes";
};
- # Allow root access over SSH
- # TODO allow disable as it is nice only for initial setup
- services.openssh = {
- enable = true;
- passwordAuthentication = true;
- permitRootLogin = "yes";
- };
-
- # Set default editor
- # TODO probably switch to nano later on
- programs.vim.defaultEditor = true;
-
- # The additional administration packages
environment.systemPackages = with pkgs; [
+ # As we override the nix package we have to override nixos-rebuild as well
(pkgs.nixos-rebuild.override { nix = config.nix.package.out; })
- git # This is required to access the repository
- htop
+ # The Git is required to access this repository
+ git
];
-
- # No need for installer tools in standard system
- system.disableInstallerTools = true;
};
}
diff --git a/nixos/modules/turris-defaults.nix b/nixos/modules/turris-defaults.nix
new file mode 100644
index 0000000..cdf5fbe
--- /dev/null
+++ b/nixos/modules/turris-defaults.nix
@@ -0,0 +1,84 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+
+ cnf = config.turris.defaults;
+
+in {
+
+ options = {
+ turris.defaults = {
+ enable = mkOption {
+ type = types.bool;
+ default = true;
+ description = "Use default Turris configuration";
+ };
+ rootLabel = mkOption {
+ type = types.str;
+ default = "NixTurris";
+ description = "GPT partition label the root system is stored on";
+ };
+ swapLabel = mkOption {
+ type = types.str;
+ default = "NixTurrisSwap";
+ description = "GPT partition label for available swap parition";
+ };
+ };
+ };
+
+ config = mkIf cnf.enable {
+ # We do not need Grub as U-Boot supports boot using extlinux like file
+ boot.loader.grub.enable = false;
+ boot.loader.generic-extlinux-compatible.enable = true;
+ # Use early print to the serial console
+ boot.kernelParams = [
+ "earlyprintk" "console=ttyMV0,115200" "earlycon=ar3700_uart,0xd0012000"
+ "boot.shell_on_fail"
+ ];
+
+ # Use the latest kernel
+ boot.kernelPackages = pkgs.linuxPackages_latest;
+
+ # The supported deployment is on BTRFS
+ boot.supportedFilesystems = [ "btrfs" ];
+
+ # Cover nix memory consumption peaks by compressing the RAM
+ zramSwap = {
+ enable = true;
+ memoryPercent = 80;
+ };
+ # Nix is really memory hungry so we have to sometimes also use swap device.
+ swapDevices = [{
+ device = "/dev/disk/by-partlabel/" + cnf.swapLabel;
+ priority = 0;
+ }];
+
+ fileSystems = {
+ "/" = {
+ device = "/dev/disk/by-partlabel/" + cnf.rootLabel;
+ fsType = "btrfs";
+ };
+ };
+
+ # The default hostname
+ networking.hostName = mkDefault "nixturris";
+
+ # Set default editor
+ # TODO probably switch to nano later on
+ programs.vim.defaultEditor = mkDefault true;
+
+ # The additional administration packages
+ environment.systemPackages = with pkgs; [
+ htop
+ ] ++ optionals (config.turris.board == "mox") [
+ libatsha204
+ ] ++ optionals (config.turris.board == "omnia") [
+ libatsha204
+ ];
+
+ # No need for installer tools in standard system
+ system.disableInstallerTools = true;
+ };
+}