From 18efc15b2a2694dac07f89d33bb1243492358a88 Mon Sep 17 00:00:00 2001
From: lassulus <git@lassul.us>
Date: Thu, 26 Jan 2023 16:13:42 +0100
Subject: [PATCH] l aergia.r: init

---
 kartei/lass/aergia.nix            | 39 +++++++++++++++++
 lass/1systems/aergia/config.nix   | 70 +++++++++++++++++++++++++++++++
 lass/1systems/aergia/disk.nix     | 64 ++++++++++++++++++++++++++++
 lass/1systems/aergia/install.sh   |  3 ++
 lass/1systems/aergia/physical.nix | 40 ++++++++++++++++++
 lass/1systems/aergia/source.nix   | 21 ++++++++++
 6 files changed, 237 insertions(+)
 create mode 100644 kartei/lass/aergia.nix
 create mode 100644 lass/1systems/aergia/config.nix
 create mode 100644 lass/1systems/aergia/disk.nix
 create mode 100644 lass/1systems/aergia/install.sh
 create mode 100644 lass/1systems/aergia/physical.nix
 create mode 100644 lass/1systems/aergia/source.nix

diff --git a/kartei/lass/aergia.nix b/kartei/lass/aergia.nix
new file mode 100644
index 000000000..d186f912c
--- /dev/null
+++ b/kartei/lass/aergia.nix
@@ -0,0 +1,39 @@
+{ r6, w6, ... }:
+{
+  nets = {
+    retiolum = {
+      ip4.addr = "10.243.0.1";
+      ip6.addr = r6 "ae12";
+      aliases = [
+        "aergia.r"
+      ];
+      tinc.pubkey = ''
+        -----BEGIN RSA PUBLIC KEY-----
+        MIICCgKCAgEAqLtEUExq0qmXbi3aykdoW1WIneePfmm1SnFxCVcEBecJ1z326cNl
+        EIhYFSzhctwui0vG1dscmNMXHJ0rRQ0QHks1kp/x2MNMlun3Wl8Md9PQrTRGqZOf
+        ltdlNKzn8QbqcQQa9BYMgnFRzhbzzsSO3q5xqncJJ8qSxxWy/boIR9fO+OI/aUfe
+        rVLVHj/i5TTAmov5johqQZOyb7ydEbLiTbaaPSo1H/I/as0iv2jaDRdoVBL5/r+q
+        JvYFfhcdePjpwjRVNohdRwPquyM2ut91e2UyxD5N5eUoQBn+Xr18f6CQlyfJmMrc
+        /oGL+DScrDzFQ/ezCzks3O02dWAmgJsU6odUyNqtdU2x+0lhSqTRH0IXfdkj5n3k
+        K5U340/84e8Bn/1BJQoaGpBZJbK8RHdZd/0r+9+aXcI5tm2YAGaPPYzgLUYg06NZ
+        fMES28iByiCecIPci4vUZ50oOQFGQYaBNA12JC4TRbL/EfLlaax9bRAaUQr7qIXS
+        OBmKrC8eN9QO53T2d2w8Llk5d1rwq0TE3lyJEFLt7sqrHvlBFJ4fpeC+JqZAObqf
+        AJlCvFrqDYXBPzuNC2cZQX9QJ4FlGBpOObGg5KtkY0hPUyBO96OMxIDQ2+Jqc7F0
+        isAUVvn23h6i3m77jRE1AGFyIC/ReMaCH70/83AJQxRpTkzKcF98xU8CAwEAAQ==
+        -----END RSA PUBLIC KEY-----
+      '';
+      tinc.pubkey_ed25519 = "Jb8RJkm+ufh8o0acM31P2BolEUneYFB4xbtyoLQywLG";
+    };
+    wiregrill = {
+      ip6.addr = w6 "ae12";
+      aliases = [
+        "aergia.w"
+      ];
+      wireguard.pubkey = ''
+        h2GFkqW1ThHpDiALrLkJEsR5NU1lXHvwk0Kers1vIxg=
+      '';
+    };
+  };
+  ssh.pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPAGcqlL5fcxT3iCTlOm5rNPGKZmx1SEDWS71d3Tvbs/";
+  syncthing.id = "K5G46ZC-AKEG3WE-MQTG6MB-PC3ZA7O-C2BOKW6-KCXTSEW-RWHKP4B-Q7FCRQ7";
+}
diff --git a/lass/1systems/aergia/config.nix b/lass/1systems/aergia/config.nix
new file mode 100644
index 000000000..a723a6385
--- /dev/null
+++ b/lass/1systems/aergia/config.nix
@@ -0,0 +1,70 @@
+{ config, lib, pkgs, ... }:
+
+{
+  imports = [
+    <stockholm/lass>
+
+    <stockholm/lass/2configs/retiolum.nix>
+    <stockholm/lass/2configs/exim-retiolum.nix>
+    <stockholm/lass/2configs/baseX.nix>
+    <stockholm/lass/2configs/pipewire.nix>
+    <stockholm/lass/2configs/browsers.nix>
+    <stockholm/lass/2configs/programs.nix>
+    <stockholm/lass/2configs/network-manager.nix>
+    <stockholm/lass/2configs/syncthing.nix>
+    <stockholm/lass/2configs/sync/sync.nix>
+    <stockholm/lass/2configs/games.nix>
+    <stockholm/lass/2configs/steam.nix>
+    <stockholm/lass/2configs/wine.nix>
+    <stockholm/lass/2configs/fetchWallpaper.nix>
+    <stockholm/lass/2configs/yellow-mounts/samba.nix>
+    <stockholm/lass/2configs/pass.nix>
+    <stockholm/lass/2configs/mail.nix>
+    <stockholm/lass/2configs/bitcoin.nix>
+    # <stockholm/lass/2configs/xonsh.nix>
+    <stockholm/lass/2configs/review.nix>
+    <stockholm/lass/2configs/dunst.nix>
+    <stockholm/lass/2configs/print.nix>
+    <stockholm/lass/2configs/br.nix>
+  ];
+
+  system.stateVersion = "22.11";
+
+  krebs.build.host = config.krebs.hosts.aergia;
+
+  environment.systemPackages = with pkgs; [
+    brain
+    bank
+    l-gen-secrets
+    generate-secrets
+  ];
+
+  programs.adb.enable = true;
+
+  hardware.bluetooth = {
+    enable = true;
+    powerOnBoot = true;
+  };
+  hardware.pulseaudio.package = pkgs.pulseaudioFull;
+
+  lass.browser.config = {
+    fy = { browser = "chromium";  groups = [ "audio" "video" ]; hidden = true; };
+    qt = { browser = "qutebrowser";  groups = [ "audio" "video" ]; hidden = true; };
+  };
+
+  nix.trustedUsers = [ "root" "lass" ];
+
+  # nix.extraOptions = ''
+  #   extra-experimental-features = nix-command flakes
+  # '';
+
+  services.tor = {
+    enable = true;
+    client.enable = true;
+  };
+
+  documentation.nixos.enable = true;
+  boot.binfmt.emulatedSystems = [
+    "aarch64-linux"
+  ];
+}
diff --git a/lass/1systems/aergia/disk.nix b/lass/1systems/aergia/disk.nix
new file mode 100644
index 000000000..0ae0892ee
--- /dev/null
+++ b/lass/1systems/aergia/disk.nix
@@ -0,0 +1,64 @@
+{ lib, ... }:
+{
+  disk = {
+    main = {
+      type = "disk";
+      device = "/dev/nvme0n1";
+      content = {
+        type = "table";
+        format = "gpt";
+        partitions = [
+          {
+            name = "boot";
+            type = "partition";
+            start = "0";
+            end = "1M";
+            part-type = "primary";
+            flags = ["bios_grub"];
+          }
+          {
+            type = "partition";
+            name = "ESP";
+            start = "1MiB";
+            end = "1GiB";
+            fs-type = "fat32";
+            bootable = true;
+            content = {
+              type = "filesystem";
+              format = "vfat";
+              mountpoint = "/boot";
+            };
+          }
+          {
+            name = "root";
+            type = "partition";
+            start = "1GiB";
+            end = "100%";
+            content = {
+              type = "luks";
+              name = "aergia1";
+              content = {
+                type = "btrfs";
+                extraArgs = "-f"; # Override existing partition
+                subvolumes = {
+                  # Subvolume name is different from mountpoint
+                  "/rootfs" = {
+                    mountpoint = "/";
+                  };
+                  # Mountpoints inferred from subvolume name
+                  "/home" = {
+                    mountOptions = [];
+                  };
+                  "/nix" = {
+                    mountOptions = [];
+                  };
+                };
+              };
+            };
+          }
+        ];
+      };
+    };
+  };
+}
+
diff --git a/lass/1systems/aergia/install.sh b/lass/1systems/aergia/install.sh
new file mode 100644
index 000000000..0e4f0ab4c
--- /dev/null
+++ b/lass/1systems/aergia/install.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+target=$1
diff --git a/lass/1systems/aergia/physical.nix b/lass/1systems/aergia/physical.nix
new file mode 100644
index 000000000..800202396
--- /dev/null
+++ b/lass/1systems/aergia/physical.nix
@@ -0,0 +1,40 @@
+{ config, lib, pkgs, modulesPath, ... }:
+{
+  imports = [
+    ./config.nix
+    (modulesPath + "/installer/scan/not-detected.nix")
+  ];
+  disko.devices = import ./disk.nix;
+
+  networking.hostId = "deadbeef";
+  # boot.loader.efi.canTouchEfiVariables = true;
+  boot.loader.grub = {
+    enable = true;
+    device = "/dev/nvme0n1";
+    efiSupport = true;
+    efiInstallAsRemovable = true;
+  };
+
+
+  # Enables the amd cpu scaling https://www.kernel.org/doc/html/latest/admin-guide/pm/amd-pstate.html
+  # On recent AMD CPUs this can be more energy efficient.
+  boot.kernelModules = [ "kvm-amd" ];
+
+  # hardware.cpu.amd.updateMicrocode = true;
+
+  services.xserver.videoDrivers = [
+    "amdgpu"
+  ];
+
+  boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "usbhid" "usb_storage" "sd_mod" ];
+
+  services.logind.lidSwitch = "ignore";
+  services.logind.lidSwitchDocked = "ignore";
+
+  environment.systemPackages = [
+    pkgs.ryzenadj
+  ];
+
+  # textsize
+  services.xserver.dpi = 200;
+}
diff --git a/lass/1systems/aergia/source.nix b/lass/1systems/aergia/source.nix
new file mode 100644
index 000000000..abbf26c75
--- /dev/null
+++ b/lass/1systems/aergia/source.nix
@@ -0,0 +1,21 @@
+{ lib, pkgs, test, ... }: let
+  npkgs = lib.importJSON ../../../krebs/nixpkgs-unstable.json;
+in {
+  nixpkgs = (if test then lib.mkForce ({ derivation = let
+    rev = npkgs.rev;
+    sha256 = npkgs.sha256;
+  in ''
+    with import (builtins.fetchTarball {
+      url = "https://github.com/nixos/nixpkgs/archive/${rev}.tar.gz";
+      sha256 = "${sha256}";
+    }) {};
+    pkgs.fetchFromGitHub {
+      owner = "nixos";
+      repo = "nixpkgs";
+      rev = "${rev}";
+      sha256 = "${sha256}";
+    }
+  ''; }) else {
+    git.ref = lib.mkForce npkgs.rev;
+  });
+}