diff --git a/devices/tunyon/default.nix b/devices/tunyon/default.nix new file mode 100644 index 0000000..d4605b7 --- /dev/null +++ b/devices/tunyon/default.nix @@ -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; + }; + }; +} diff --git a/devices/tunyon/impermanence.nix b/devices/tunyon/impermanence.nix new file mode 100644 index 0000000..2c29b9b --- /dev/null +++ b/devices/tunyon/impermanence.nix @@ -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" + ]; + }; + }; +} diff --git a/devices/tunyon/options.nix b/devices/tunyon/options.nix new file mode 100644 index 0000000..eca5e31 --- /dev/null +++ b/devices/tunyon/options.nix @@ -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"; +} diff --git a/flake.nix b/flake.nix index a73332c..e0abc95 100644 --- a/flake.nix +++ b/flake.nix @@ -26,6 +26,10 @@ nixpkgs.follows = "nixpkgs"; }; }; + + impermanence = { + url = "github:nix-community/impermanence"; + }; }; outputs = inputs: import ./outputs.nix inputs; diff --git a/modules/niri/niri.conf.nix b/modules/niri/niri.conf.nix index b81fd83..1024229 100644 --- a/modules/niri/niri.conf.nix +++ b/modules/niri/niri.conf.nix @@ -15,7 +15,7 @@ outputs = { "eDP-1" = { - scale = 1.0; + scale = 1.25; mode = { width = 2736; height = 1824; diff --git a/options.nix b/options.nix index 969eb5d..dfaf287 100644 --- a/options.nix +++ b/options.nix @@ -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"; }; diff --git a/outputs.nix b/outputs.nix index 540d98a..44eedac 100644 --- a/outputs.nix +++ b/outputs.nix @@ -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 + ]; + }; }; }