diff --git a/hosts/kled/configuration.nix b/hosts/kled/configuration.nix new file mode 100644 index 0000000..4388874 --- /dev/null +++ b/hosts/kled/configuration.nix @@ -0,0 +1,60 @@ +{ + pkgs, + lib, + inputs, + perSystem, + ... +}: { + imports = with inputs; [ + self.nixosModules.desktop + self.nixosModules.shared + ./disk.nix + ./hardware + ./misc + ]; + + desktop.dms.enable = true; + + services.displayManager.autoLogin = { + enable = true; + user = "user"; + }; + + boot.kernelPackages = lib.mkForce pkgs.linuxPackages_6_12; + + environment.systemPackages = [perSystem.cros.cros-ectool]; + + swapDevices = [ + { + device = "/swap/swapfile"; + size = 4 * 1024; + priority = 100; + } + { + device = "/swap/hibernate"; + size = 16 * 1024; + priority = 1; + } + ]; + + unexplrd = { + host = { + id = "31150fae"; + name = "kled"; + stateVersion = "25.11"; + }; + + config = { + laptop.homeRowMods = true; + powerSave = true; + useIwd = true; + vaapi = "intel-media-driver"; + locale = "uk_UA.UTF-8"; + timeZone = "Europe/Kyiv"; + }; + stylix = { + enable = true; + theme = "ashes"; + }; + }; +} diff --git a/hosts/kled/disk.nix b/hosts/kled/disk.nix new file mode 100644 index 0000000..5a3e540 --- /dev/null +++ b/hosts/kled/disk.nix @@ -0,0 +1,45 @@ +{ + config, + # inputs, + ... +}: let + disk = "/dev/disk/by-partuuid/33394714-d94d-4085-b020-3fe5d02e3494"; + luksName = "luks-${config.networking.hostId}"; +in rec { + boot.initrd.luks.devices."${luksName}".device = disk; + + fileSystems = { + "/boot" = { + device = "/dev/disk/by-partuuid/7f1bd772-f3ac-4075-94a7-e1729994c7fc"; + fsType = "vfat"; + options = ["fmask=0077" "dmask=0077"]; + }; + + "/tmp" = { + device = "none"; + fsType = "tmpfs"; + options = ["rw" "nosuid" "nodev"]; + }; + + "/" = { + device = "/dev/mapper/${luksName}"; + fsType = "btrfs"; + options = ["subvol=@nixos-root"]; + }; + + "/nix" = { + inherit (fileSystems."/") device fsType; + options = ["subvol=@nix" "noatime"]; + }; + + "/storage" = { + inherit (fileSystems."/") device fsType; + options = ["subvol=@storage"]; + }; + + "/home" = { + inherit (fileSystems."/") device fsType; + options = ["subvol=@home"]; + }; + }; +} diff --git a/hosts/kled/hardware/default.nix b/hosts/kled/hardware/default.nix new file mode 100644 index 0000000..05c884c --- /dev/null +++ b/hosts/kled/hardware/default.nix @@ -0,0 +1,11 @@ +{ + imports = [ + ./laptop + ]; + services = { + logind = { + lidSwitch = "ignore"; + powerKey = "suspend"; + }; + }; +} diff --git a/hosts/kled/hardware/laptop/chromebook.nix b/hosts/kled/hardware/laptop/chromebook.nix new file mode 100644 index 0000000..e2b34ce --- /dev/null +++ b/hosts/kled/hardware/laptop/chromebook.nix @@ -0,0 +1,165 @@ +{ + pkgs, + lib, + perSystem, + ... +}: let + ectool = "${perSystem.cros.cros-ectool}/bin/ectool"; +in { + systemd.tmpfiles.rules = [ + "w /sys/devices/system/cpu/cpufreq/policy*/energy_performance_preference - - - - balance_performance +" + "w /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor - - - - performance" + ]; + systemd.services.ectool-thermalset = { + enable = true; + serviceConfig.Type = "oneshot"; + script = '' + ${ectool} thermalset 0 0 361 371 333 353 + ${ectool} thermalset 1 0 361 371 333 353 + ''; + }; + + services.kanata.enable = lib.mkForce false; + services.keyd = { + enable = true; + keyboards.internal = { + ids = [ + "k:0001:0001" + "k:18d1:5044" + "k:18d1:5052" + "k:0000:0000" + "k:18d1:5050" + "k:18d1:504c" + "k:18d1:503c" + "k:18d1:5030" + "k:18d1:503d" + "k:18d1:505b" + "k:18d1:5057" + "k:18d1:502b" + "k:18d1:5061" + ]; + settings = { + main = let + # finger = mod; + pinky = "alt"; + ring = "meta"; + middle = "control"; + index = "shift"; + # timeouts + idle = "200"; + hold = "150"; + # function takes finger and letter + homeRowMod = f: l: "lettermod(${f}, ${l}, ${idle}, ${hold})"; + in { + "a" = homeRowMod pinky "a"; + "s" = homeRowMod ring "s"; + "d" = homeRowMod middle "d"; + "f" = homeRowMod index "f"; + "j" = homeRowMod index "j"; + "k" = homeRowMod middle "k"; + "l" = homeRowMod ring "l"; + ";" = homeRowMod pinky ";"; + f1 = "back"; + f2 = "forward"; + f3 = "refresh"; + f4 = "f11"; + f5 = "scale"; + f6 = "brightnessdown"; + f7 = "brightnessup"; + f8 = "mute"; + f9 = "volumedown"; + f10 = "volumeup"; + f13 = "coffee"; # lock key reports as XF86Tools + back = "back"; + forward = "forward"; + refresh = "refresh"; + zoom = "f11"; + scale = "scale"; + brightnessdown = "brightnessdown"; + brightnessup = "brightnessup"; + mute = "mute"; + volumedown = "volumedown"; + volumeup = "volumeup"; + }; + meta = { + f1 = "f1"; + f2 = "f2"; + f3 = "f3"; + f4 = "f4"; + f5 = "f5"; + f6 = "f6"; + f7 = "f7"; + f8 = "f8"; + f9 = "f9"; + f10 = "f10"; + f13 = "f12"; + back = "f1"; + forward = "f2"; + refresh = "f3"; + zoom = "f4"; + scale = "f5"; + brightnessdown = "f6"; + brightnessup = "f7"; + mute = "f8"; + volumedown = "f9"; + volumeup = "f10"; + }; + alt = { + backspace = "delete"; + meta = "capslock"; + brightnessdown = "kbdillumdown"; + brightnessup = "kbdillumup"; + f5 = "print"; + f6 = "kbdillumdown"; + f7 = "kbdillumup"; + scale = "print"; + }; + controlalt.backspace = "C-A-delete"; + }; + }; + }; + + hardware.sensor.iio.enable = true; + hardware.enableRedistributableFirmware = true; + + security.wrappers.ectool = lib.mkDefault { + setuid = true; + owner = "root"; + group = "root"; + source = ectool; + }; + + boot.extraModprobeConfig = '' + options snd_intel_dspcfg dsp_driver=3 + ''; + environment = { + systemPackages = [pkgs.sof-firmware]; + sessionVariables.ALSA_CONFIG_UCM2 = lib.mkDefault "${perSystem.cros.alsa-ucm-conf-cros}/share/alsa/ucm2"; + etc = { + "wireplumber/conf.d/51-increase-headroom.lua".text = '' + monitor.alsa.rules = [ + { + matches = [ + { + node.name = "~alsa_output.*" + } + ] + actions = { + update-props = { + api.alsa.headroom = 2048 + } + } + } + ] + ''; + }; + }; + + # system.replaceDependencies.replacements = [ + # { + # original = pkgs.alsa-ucm-conf; + # replacement = perSystem.cros.alsa-ucm-conf-cros; + # } + # ]; +} diff --git a/hosts/kled/hardware/laptop/default.nix b/hosts/kled/hardware/laptop/default.nix new file mode 100644 index 0000000..45ee703 --- /dev/null +++ b/hosts/kled/hardware/laptop/default.nix @@ -0,0 +1,5 @@ +{ + imports = [ + ./chromebook.nix + ]; +} diff --git a/hosts/kled/misc/default.nix b/hosts/kled/misc/default.nix new file mode 100644 index 0000000..cc8d3bd --- /dev/null +++ b/hosts/kled/misc/default.nix @@ -0,0 +1,5 @@ +{ + imports = [ + ./distributed-build.nix + ]; +} diff --git a/hosts/kled/misc/distributed-build.nix b/hosts/kled/misc/distributed-build.nix new file mode 100644 index 0000000..4c8ed8e --- /dev/null +++ b/hosts/kled/misc/distributed-build.nix @@ -0,0 +1,28 @@ +{ + config, + inputs, + ... +}: let + inherit (builtins) readFile; + inherit (config.networking) hostName; + inherit (config.sops) secrets; + inherit (inputs) mysecrets; + pubHost = readFile "${mysecrets}/ssh/ssh_host_ed25519_dunamis.base64"; +in { + nix = { + distributedBuilds = true; + buildMachines = [ + { + hostName = "dunamis"; + maxJobs = 3; + protocol = "ssh-ng"; + publicHostKey = pubHost; + speedFactor = 2; + sshKey = secrets."ssh-${hostName}-user".path; + sshUser = "nix-ssh"; + supportedFeatures = ["benchmark" "big-parallel" "kvm" "nixos-test"]; + system = "x86_64-linux"; + } + ]; + }; +} diff --git a/hosts/kled/users/user/home-configuration.nix b/hosts/kled/users/user/home-configuration.nix new file mode 100644 index 0000000..2a691c1 --- /dev/null +++ b/hosts/kled/users/user/home-configuration.nix @@ -0,0 +1 @@ +{flake, ...}: {imports = [flake.modules.users.user];}