initial tunyon config

This commit is contained in:
twoneis 2024-07-20 20:45:30 +02:00
parent e774e9b9cd
commit 7bb5c421f6
7 changed files with 187 additions and 5 deletions

108
devices/tunyon/default.nix Normal file
View file

@ -0,0 +1,108 @@
{ lib, pkgs, ... }: let
disks = {
boot = "";
crypt = "";
root = "";
};
in{
imports = [
./options.nix
./impermanece
];
nixpkgs = {
hostPlatform = "x86_64-linux";
};
networking = {
hostName = "tunyon";
};
boot = {
initrd = {
availableKernelModules = [ "nvme" "xhci_pci" "thunderbolt" ];
luks.devices.root.device = "/dev/disk/by-uuid/${disks.crypt}";
postDeviceCommands = lib.mkAfter ''
mkdir /btrfs_tmp
mount /dev/disk/by-uuid/${disks.root} /btrfs_tmp
if [[ -e /btrfs_tmp/root ]]; then
mkdir -p /btrfs_tmp/old_roots
timestamp=$(date --date="@$(stat -c %Y /btrfs_tmp/root)" "+%Y-%m-%-d_%H:%M:%S")
mv /btrfs_tmp/root "/btrfs_tmp/old_roots/$timestamp"
fi
delete_subvolume_recursively() {
IFS=$'\n'
for i in $(btrfs subvolume list -o "$1" | cut -f 9- -d ' '); do
delete_subvolume_recursively "/btrfs_tmp/$i"
done
btrfs subvolume delete "$1"
}
for i in $(find /btrfs_tmp/old_roots/ -maxdepth 1 -mtime +30); do
delete_subvolume_recursively "$i"
done
btrfs subvolume create /btrfs_tmp/root
umount /btrfs_tmp
'';
};
kernelModules = [ "kvm-amd" ];
kernelPackages = pkgs.linuxPackages_zen;
loader = {
systemd-boot = {
enable = true;
};
efi.canTouchEfiVariables = true;
};
};
fileSystems = {
"/boot" = {
device = "/dev/disk/by-uuid/${disks.boot}";
fsType = "vfat";
};
"/" = {
device = "/dev/disk/by-uuid/${disks.root}";
fsType = "btrfs";
options = [ "subvol=root" "compress=zstd" "noatime" ];
};
"/nix" = {
device = "/dev/disk/by-uuid/${disks.root}";
fsType = "btrfs";
options = [ "subvol=nix" "compress=zstd" "noatime" ];
neededForBoot = true;
};
"/persist" = {
device = "/dev/disk/by-uuid/${disks.root}";
fsType = "btrfs";
options = [ "subvol=persist" "compress=zstd" "noatime" ];
neededForBoot = true;
};
"/swap" = {
device = "/dev/disk/by-uuid/${disks.root}";
fsType = "btrfs";
options = [ "subvol=swap" "noatime" ];
};
};
swapDevices = [ { device = "/swap/swapfile"; } ];
services = {
upower.enable = true;
fwupd.enable = true;
power-profiles-daemon.enable = true;
};
hardware = {
enableRedistributableFirmware = true;
enableAllFirmware = true;
cpu.amd.updateMicrocode = true;
graphics = {
enable = true;
enable32Bit = true;
};
};
}

View file

@ -0,0 +1,27 @@
{ config, ... }: {
environment.persistence."/persist" = {
enable = true;
directories = [
"/var/log"
"/var/lib/bluetooth"
"/var/lib/nixos"
"/var/lib/iwd"
];
files = [
"/etc/machine-id"
"/etc/passwd"
"/etc/shadow"
];
users.${config.username}= {
directories = [
"Documents"
"Pictures"
"Videos"
"code"
{ directory = ".local/share/keyrings"; mode = "0700"; }
".local/share/direnv"
];
};
};
}

View file

@ -0,0 +1,16 @@
{ ... }: {
user = true;
withNiri = true;
withGnome = false;
withVM = false;
withContainers = false;
withGames = true;
hwmonPath = "/sys/class/hwmon/hwmon1/temp1_input";
stateVersion = "24.05";
hmStateVersion = "24.11";
}

View file

@ -26,6 +26,10 @@
nixpkgs.follows = "nixpkgs";
};
};
impermanence = {
url = "github:nix-community/impermanence";
};
};
outputs = inputs: import ./outputs.nix inputs;

View file

@ -15,7 +15,7 @@
outputs = {
"eDP-1" = {
scale = 1.0;
scale = 1.25;
mode = {
width = 2736;
height = 1824;

View file

@ -10,20 +10,26 @@
withGames = mkEnableOption "Enable games";
username = mkOption {
type = types.str;
default = "twoneis";
example = "anna";
};
hwmonPath = mkOption {
type = with types; nullOr str;
type = types.nullOr types.str;
default = null;
example = "/sys/class/hwmon/hwmon1/temp1_input";
};
stateVersion = mkOption {
type = with types; nullOr str;
type = types.nullOr types.str;
default = null;
example = "24.05";
};
hmStateVersion = mkOption {
type = with types; nullOr str;
type = types.nullOr types.str;
default = null;
example = "24.11";
};

View file

@ -1,4 +1,4 @@
{ nixpkgs, lix, home-manager, niri, ... }@inputs: {
{ nixpkgs, lix, home-manager, niri, impermanence, ... }@inputs: {
nixosConfigurations = {
# AMD Ryzen 5600X
# Nvidia GeForce GTX 1060 (6GB)
@ -57,5 +57,26 @@
lix.nixosModules.default
];
};
# Framework Laptop 13
# AMD Ryzen 5 7640U
# AMD Radeon 760M
# 16GB RAM
tunyon = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = {
inherit inputs;
};
modules = [
./devices/tunyon
./modules
./options.nix
./colors.nix
niri.nixosModules.niri
home-manager.nixosModules.home-manager
lix.nixosModules.default
impermanence.nixosModules.impermanence
];
};
};
}