From 1c9816a0883955158d971036fe3040a1304454bb Mon Sep 17 00:00:00 2001 From: makefu Date: Mon, 17 Jun 2019 08:01:42 +0200 Subject: [PATCH] ma firecracker: add config for rk3399 --- 1systems/firecracker/config.nix | 25 +++++++++++++++ 1systems/firecracker/hardware-config.nix | 30 ++++++++++++++++++ 1systems/firecracker/source.nix | 4 +++ 1systems/sdcard/config.nix | 40 ++++++++++++++++++++++++ 1systems/sdcard/kernel.nix | 15 +++++++++ 1systems/sdcard/source.nix | 3 ++ 6 files changed, 117 insertions(+) create mode 100644 1systems/firecracker/config.nix create mode 100644 1systems/firecracker/hardware-config.nix create mode 100644 1systems/firecracker/source.nix create mode 100644 1systems/sdcard/config.nix create mode 100644 1systems/sdcard/kernel.nix create mode 100644 1systems/sdcard/source.nix diff --git a/1systems/firecracker/config.nix b/1systems/firecracker/config.nix new file mode 100644 index 0000000..87f5002 --- /dev/null +++ b/1systems/firecracker/config.nix @@ -0,0 +1,25 @@ +{ config, lib, pkgs, ... }: +let + primaryInterface = "eth0"; +in { + imports = [ + + ./hardware-config.nix + # + { environment.systemPackages = with pkgs;[ rsync screen curl git ];} + + # +# configure your hw: +# + ]; + krebs = { + enable = true; + tinc.retiolum.enable = true; + build.host = config.krebs.hosts.firecracker; + }; + networking.firewall.trustedInterfaces = [ primaryInterface ]; + documentation.info.enable = false; + documentation.man.enable = false; + services.nixosManual.enable = false; + sound.enable = false; +} diff --git a/1systems/firecracker/hardware-config.nix b/1systems/firecracker/hardware-config.nix new file mode 100644 index 0000000..b821a33 --- /dev/null +++ b/1systems/firecracker/hardware-config.nix @@ -0,0 +1,30 @@ +{ pkgs, lib, ... }: +{ + boot.kernelParams = lib.mkForce ["console=ttyS2,1500000n8" "earlycon=uart8250,mmio32,0xff1a0000" "earlyprintk"]; + boot.loader.grub.enable = false; + boot.loader.generic-extlinux-compatible.enable = true; + boot.loader.generic-extlinux-compatible.configurationLimit = 1; + boot.loader.generationsDir.enable = lib.mkDefault false; + boot.supportedFilesystems = lib.mkForce [ "vfat" ]; + + boot.tmpOnTmpfs = lib.mkForce false; + boot.cleanTmpDir = true; + hardware.enableRedistributableFirmware = true; + + ## wifi not working, will be fixed with https://github.com/NixOS/nixpkgs/pull/53747 + boot.kernelPackages = pkgs.linuxPackages_latest; + networking.wireless.enable = true; + # File systems configuration for using the installer's partition layout + swapDevices = [ { device = "/var/swap"; size = 4096; } ]; + fileSystems = { + "/boot" = { + device = "/dev/disk/by-label/NIXOS_BOOT"; + fsType = "vfat"; + }; + "/" = { + device = "/dev/disk/by-label/NIXOS_SD"; + fsType = "ext4"; + }; + }; + +} diff --git a/1systems/firecracker/source.nix b/1systems/firecracker/source.nix new file mode 100644 index 0000000..22c4003 --- /dev/null +++ b/1systems/firecracker/source.nix @@ -0,0 +1,4 @@ +{ + name="cake"; + full = true; +} diff --git a/1systems/sdcard/config.nix b/1systems/sdcard/config.nix new file mode 100644 index 0000000..4e3c22a --- /dev/null +++ b/1systems/sdcard/config.nix @@ -0,0 +1,40 @@ +{ config, pkgs, lib, ... }: +let + kernel = pkgs.callPackage ./kernel.nix { + kernelPatches = with pkgs.kernelPatches; [ + # kernelPatches.bridge_stp_helper + # kernelPatches.modinst_arg_list_too_long + ]; + }; +in +{ + imports = [ + + # + ]; + # TODO: NIX_PATH and nix.nixPath are being set by default.nix right now + # cd ~/stockholm ; nix build config.system.build.sdImage -I nixos-config=makefu/1systems/sdcard/config.nix -f /home/makefu/nixpkgs/nixos + + boot.kernelParams = ["console=ttyS2,1500000" "earlycon=uart8250,mmio32,0xff1a0000"]; + # boot.kernelPackages = pkgs.linuxPackages_latest; + boot.kernelPackages = pkgs.linuxPackagesFor kernel; + boot.supportedFilesystems = lib.mkForce [ "vfat" "f2fs" "xfs" "ntfs" "cifs" ]; + + # krebs.hidden-ssh.enable = true; + environment.systemPackages = with pkgs; [ + aria2 + ddrescue + ]; + environment.extraInit = '' + EDITOR=vim + ''; + # iso-specific + services.openssh = { + enable = true; + hostKeys = [ + { bits = 8192; type = "ed25519"; path = "/etc/ssh/ssh_host_ed25519_key"; } + ]; + }; + # enable ssh in the iso boot process + systemd.services.sshd.wantedBy = lib.mkForce [ "multi-user.target" ]; +} diff --git a/1systems/sdcard/kernel.nix b/1systems/sdcard/kernel.nix new file mode 100644 index 0000000..df5e7ad --- /dev/null +++ b/1systems/sdcard/kernel.nix @@ -0,0 +1,15 @@ +{ fetchFromGitLab, buildLinux, ... } @ args: +buildLinux (args // rec { + version = "4.4.55"; + modDirVersion = "4.4.55"; + extraMeta.branch = "4.4"; + defconfig = "firefly_linux_defconfig"; + + src = fetchFromGitLab { + owner = "TeeFirefly"; + repo = "linux-kernel"; + rev = "firefly_0821_release"; + sha256 = "1fwj9cm5ysz286znrr3fyrhfn903m84i7py4rv3y3h9avxb3zl1r"; + }; + extraMeta.platforms = [ "aarch64-linux" ]; +} // (args.argsOverride or {})) diff --git a/1systems/sdcard/source.nix b/1systems/sdcard/source.nix new file mode 100644 index 0000000..6bef8ad --- /dev/null +++ b/1systems/sdcard/source.nix @@ -0,0 +1,3 @@ +{ + name="iso"; +}