From d92cd0eb9416d634ce3202e4053869b0865c6de6 Mon Sep 17 00:00:00 2001 From: makefu Date: Fri, 9 Jun 2023 14:58:43 +0200 Subject: [PATCH] init flake-x --- 1systems/flake-x/config.nix | 256 +++++++++++++++++++++++++ 1systems/flake-x/source.nix | 12 ++ 1systems/flake-x/x13/battery.nix | 6 + 1systems/flake-x/x13/default.nix | 46 +++++ 1systems/flake-x/x13/disk.nix | 67 +++++++ 1systems/flake-x/x13/input.nix | 48 +++++ 1systems/flake-x/x13/toggle_brightness | 8 + 1systems/flake-x/x13/zfs.nix | 34 ++++ 1systems/flake-x/x230/default.nix | 19 ++ 9 files changed, 496 insertions(+) create mode 100644 1systems/flake-x/config.nix create mode 100644 1systems/flake-x/source.nix create mode 100644 1systems/flake-x/x13/battery.nix create mode 100644 1systems/flake-x/x13/default.nix create mode 100644 1systems/flake-x/x13/disk.nix create mode 100644 1systems/flake-x/x13/input.nix create mode 100644 1systems/flake-x/x13/toggle_brightness create mode 100644 1systems/flake-x/x13/zfs.nix create mode 100644 1systems/flake-x/x230/default.nix diff --git a/1systems/flake-x/config.nix b/1systems/flake-x/config.nix new file mode 100644 index 0000000..5b7535b --- /dev/null +++ b/1systems/flake-x/config.nix @@ -0,0 +1,256 @@ +{ config, pkgs, lib, ... }: +{ + imports = + [ + + # ./x13 + # ./x230 + + ## Common Hardware Components + # + ## + ## + # + ## + ## + ## + # + ## + # + # + # + # + ## + + ## base + # + # + # + # + # + # + # + + # + # + # + # + # + #{ programs.adb.enable = true; } + #{ + # services.openssh.hostKeys = [ + # { bits = 4096; path = (toString ); type = "rsa";} + # ]; + #} + ##{ + ## imports = [ + ## + ## ]; + ## services.pipewire.config.pipewire-pulse = { + ## "pulse.properties"."server.address" = [ "unix:native" "tcp:4713" ]; + ## }; + ## networking.firewall.allowedTCPPorts = [ 4713 ]; + + ##} + + ##{ + ## users.users.makefu.packages = with pkgs;[ mpc_cli ncmpcpp ]; + ## services.ympd.enable = true; + ## services.mpd = { + ## enable = true; + ## extraConfig = '' + ## log_level "default" + ## auto_update "yes" + + ## audio_output { + ## type "httpd" + ## name "lassulus radio" + ## encoder "vorbis" # optional + ## port "8000" + ## quality "5.0" # do not define if bitrate is defined + ## # bitrate "128" # do not define if quality is defined + ## format "44100:16:2" + ## always_on "yes" # prevent MPD from disconnecting all listeners when playback is stopped. + ## tags "yes" # httpd supports sending tags to listening streams. + ## } + ## ''; + ## }; + ##} + + ## { systemd.services.docker.wantedBy = lib.mkForce []; } + ## + ## + ## + ##{ + ## netboot_server = { + ## network.wan = "wlp3s0"; + ## network.lan = "enp0s25"; + ## }; + ##} + + ## Restore: + ## systemctl cat borgbackup-job-state + ## export BORG_PASSCOMMAND BORG_REPO BORG_RSH + ## borg list "$BORG_REPO" + ## mount newroot somewhere && cd somewhere + ## borg extract "$BORG_REPO::x-state-2019-04-17T01:41:51" --progress # < extract to cwd + # + + ## + # + # + + ## Debugging + ## + ## + + ## Testing + ##{ + ## services.nginx = { + ## enable = true; + ## recommendedProxySettings = true; + ## virtualHosts.local = { + ## default = true; + ## locations."/".proxyPass= "http://localhost:4567"; + ## }; + ## }; + ## services.gollum = { + ## enable = true; + ## extraConfig = '' + ## Gollum::Hook.register(:post_commit, :hook_id) do |committer, sha1| + ## File.open('/tmp/lol', 'w') { |file| file.write(self.to_s) } + ## end + ## ''; + ## }; + ##} + ## + ## + ## + + ## + ## + ## + ## + ## + ## + ## + ## + + ## Krebs + # + ## + ## + # + # + ## + + + ## applications + # + # + # + ## + ## + + ## Virtualization + ## + # + # + ##{ + ## networking.firewall.allowedTCPPorts = [ 8080 ]; + ## networking.nat = { + ## enable = true; + ## externalInterface = "wlp3s0"; + ## internalInterfaces = [ "vboxnet0" ]; + ## }; + ##} + ## Services + # + # + ## + ## + # + ## + ## { nixpkgs.overlays = [ (self: super: super.prefer-remote-fetch self super) ]; } + + ## + # + + + + ## Security + ## + + ## temporary + ## { services.redis.enable = true; } + ## citadel exporter + ## { services.mongodb.enable = true; } + ## { services.elasticsearch.enable = true; } + ## + ## + ## + ## + ## + ## + ## + ## + # + +# { +# networking.wireguard.interfaces.wg0 = { +# ips = [ "10.244.0.2/24" ]; +# privateKeyFile = (toString ) + "/wireguard.key"; +# allowedIPsAsRoutes = true; +# peers = [ +# { +# # gum +# endpoint = "${config.krebs.hosts.gum.nets.internet.ip4.addr}:51820"; +# allowedIPs = [ "10.244.0.0/24" ]; +# publicKey = "yAKvxTvcEVdn+MeKsmptZkR3XSEue+wSyLxwcjBYxxo="; +# } +# #{ +# # # vbob +# # allowedIPs = [ "10.244.0.3/32" ]; +# # publicKey = "Lju7EsCu1OWXhkhdNR7c/uiN60nr0TUPHQ+s8ULPQTw="; +# #} +# ]; +# }; +# } + ]; + + + nixpkgs.config.allowUnfree = true; + nixpkgs.config.oraclejdk.accept_license = true; + + environment.systemPackages = [ xxx ]; + + # configure pulseAudio to provide a HDMI sink as well + networking.firewall.enable = true; + networking.firewall.allowedUDPPorts = [ 665 26061 1514 ]; + networking.firewall.trustedInterfaces = [ "vboxnet0" "enp0s25" ]; + + # krebs.build.host = config.krebs.hosts.x; + + #krebs.tinc.retiolum.connectTo = lib.mkForce [ "gum" ]; + #krebs.tinc.retiolum.extraConfig = "AutoConnect = no"; + + # environment.variables = { GOROOT = [ "${pkgs.go.out}/share/go" ]; }; + #state = [ + # "/home/makefu/stockholm" + # "/home/makefu/.ssh/" + # "/home/makefu/.zsh_history" + # "/home/makefu/.bash_history" + # "/home/makefu/bin" + # "/home/makefu/.gnupg" + # "/home/makefu/.imapfilter" + # "/home/makefu/.mutt" + # "/home/makefu/docs" + # "/home/makefu/notes" + # "/home/makefu/.password-store" + # "/home/makefu/.secrets-pass" + # "/home/makefu/.config/syncthing" + #]; + + # services.syncthing.user = lib.mkForce "makefu"; + # services.syncthing.dataDir = lib.mkForce "/home/makefu/.config/syncthing/"; +} diff --git a/1systems/flake-x/source.nix b/1systems/flake-x/source.nix new file mode 100644 index 0000000..ecb1d99 --- /dev/null +++ b/1systems/flake-x/source.nix @@ -0,0 +1,12 @@ +{ + name="x"; + full = true; + python = true; + hw = true; + # unstable = true; + mic92 = true; + clever_kexec = true; + home-manager = true; + nix-ld = true; + # torrent = true; +} diff --git a/1systems/flake-x/x13/battery.nix b/1systems/flake-x/x13/battery.nix new file mode 100644 index 0000000..3e28292 --- /dev/null +++ b/1systems/flake-x/x13/battery.nix @@ -0,0 +1,6 @@ +{ pkgs, ... }: +{ + powerManagement.powertop.enable = true; + services.power-profiles-daemon.enable = true; + users.users.makefu.packages = [ pkgs.gnome.gnome-power-manager ]; +} diff --git a/1systems/flake-x/x13/default.nix b/1systems/flake-x/x13/default.nix new file mode 100644 index 0000000..27ea0c9 --- /dev/null +++ b/1systems/flake-x/x13/default.nix @@ -0,0 +1,46 @@ +{ pkgs, lib, ... }: +# new zfs deployment +{ + imports = [ + ./zfs.nix + ./input.nix + ./battery.nix + + # close enough + # + + # + ]; + boot.zfs.requestEncryptionCredentials = true; + networking.hostId = "f8b8e0a2"; + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + # services.xserver.enable = lib.mkForce false; + + services.xserver.videoDrivers = [ "amdgpu" ]; + boot.initrd.kernelModules = [ "amdgpu" ]; + hardware.opengl.driSupport = true; + hardware.opengl.extraPackages = [ pkgs.amdvlk pkgs.rocm-opencl-icd pkgs.rocm-opencl-runtime ]; + # For 32 bit applications + hardware.opengl.driSupport32Bit = true; + hardware.opengl.extraPackages32 = with pkgs; [ + driversi686Linux.amdvlk + ]; + # is required for amd graphics support ( xorg wont boot otherwise ) + #boot.kernelPackages = pkgs.linuxPackages_latest; + boot.kernelPackages = lib.mkForce pkgs.linuxPackages; + + services.fwupd.enable = true; + + programs.light.enable = true; + + users.groups.video = {}; + users.groups.render = {}; + users.users.makefu.extraGroups = [ "video" "render" ]; + + boot.extraModprobeConfig = '' + options thinkpad_acpi fan_control=1 + ''; +} + diff --git a/1systems/flake-x/x13/disk.nix b/1systems/flake-x/x13/disk.nix new file mode 100644 index 0000000..7ce77bd --- /dev/null +++ b/1systems/flake-x/x13/disk.nix @@ -0,0 +1,67 @@ +{ disk ? "/dev/sda", ... }: { + disko.devices = { + disk = { + nvme = { + type = "disk"; + device = disk; + content = { + type = "table"; + format = "gpt"; + partitions = [ + { + name = "ESP"; + start = "0"; + end = "512MiB"; + fs-type = "fat32"; + bootable = true; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + }; + } + { + name = "zfs"; + start = "512MiB"; + end = "100%"; + content = { + type = "zfs"; + pool = "tank"; + }; + } + ]; + }; + }; + }; + zpool = { + tank = { + type = "zpool"; + rootFsOptions = { + compression = "lz4"; + #reservation = "5G"; + "com.sun:auto-snapshot" = "false"; + }; + mountpoint = null; + postCreateHook = "zfs snapshot tank@blank"; + + datasets = { + + root = { + type = "zfs_fs"; + mountpoint = "/"; + options = { + encryption = "aes-256-gcm"; + keyformat = "passphrase"; + "com.sun:auto-snapshot" = "true"; + }; + #keylocation = "file:///tmp/secret.key"; + }; + "root/home" = { + type = "zfs_fs"; + mountpoint = "/home"; + }; + }; + }; + }; + }; +} diff --git a/1systems/flake-x/x13/input.nix b/1systems/flake-x/x13/input.nix new file mode 100644 index 0000000..93816ce --- /dev/null +++ b/1systems/flake-x/x13/input.nix @@ -0,0 +1,48 @@ +{ pkgs, lib, ... }: +{ + # current issues: + # 1. for pressing insert hold shift+fn+Fin + + # scroll by holding middle mouse + #services.xserver.displayManager.sessionCommands ='' + # xinput set-int-prop "ETPS/2 Elantech TrackPoint" "Evdev Wheel Emulation" 8 1 + # xinput set-int-prop "ETPS/2 Elantech TrackPoint" "Evdev Wheel Emulation Button" 8 2 + # xinput set-prop "ETPS/2 Elantech TrackPoint" "Evdev Wheel Emulation Axes" 6 7 4 5 + # # configure timeout of pressing and holding middle button + # # xinput set-int-prop "ETPS/2 Elantech TrackPoint" "Evdev Wheel Emulation Timeout" 8 200 + # xinput disable 'ETPS/2 Elantech Touchpad' + #''; + + services.xserver.libinput.enable = true; + boot.kernelParams = [ + #"psmouse.proto=imps" + #"psmouse.proto=bare" + #"psmouse.resetafter=0" + "psmouse.synaptics_intertouch=1" # echo 1 > /sys/devices/platform/i8042/serio1/reg_07 + ]; + + programs.light.enable = true; + services.actkbd = { + enable = true; + bindings = [ + { keys = [ 225 ]; events = [ "key" ]; command = "${pkgs.light}/bin/light -A 10"; } # fn - F5 + { keys = [ 224 ]; events = [ "key" ]; command = "${pkgs.light}/bin/light -U 10"; } # fn - F6 + # fn - 4 => suspend + # fn - d => lcdshadow + #{ keys = [ 227 ]; events = [ "key" ]; command = builtins.toString ( # fn - F7 + # pkgs.writers.writeDash "toggle_touchpad" '' + # PATH=${lib.makeBinPath [ pkgs.xorg.xinput pkgs.gnugrep ]} + # DISPLAY=:0 + # export DISPLAY PATH + + # device=$(xinput list --name-only | grep Touchpad) + # if [ "$(xinput list-props "$device" | grep -P ".*Device Enabled.*\K.(?=$)" -o)" -eq 1 ];then + # xinput disable "$device" + # else + # xinput enable "$device" + # fi + # ''); + #} + ]; + }; +} diff --git a/1systems/flake-x/x13/toggle_brightness b/1systems/flake-x/x13/toggle_brightness new file mode 100644 index 0000000..dc1436c --- /dev/null +++ b/1systems/flake-x/x13/toggle_brightness @@ -0,0 +1,8 @@ +#!/bin/sh +proc=/proc/acpi/ibm/lcdshadow +status=$(awk '/status:/{print $2}' "$proc") +if [ "$status" -eq 0 ];then + echo 1 > "$proc" +else + echo 0 > "$proc" +fi diff --git a/1systems/flake-x/x13/zfs.nix b/1systems/flake-x/x13/zfs.nix new file mode 100644 index 0000000..ba341ef --- /dev/null +++ b/1systems/flake-x/x13/zfs.nix @@ -0,0 +1,34 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = + [ (modulesPath + "/installer/scan/not-detected.nix") + ]; + + boot.initrd.availableKernelModules = [ "nvme" "ehci_pci" "xhci_pci" "rtsx_pci_sdmmc" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-amd" ]; + boot.extraModulePackages = [ ]; + + boot.zfs.enableUnstable = true; # required for 21.05 + fileSystems."/" = + { device = "zroot/root/nixos"; + fsType = "zfs"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/20BF-2755"; + fsType = "vfat"; + }; + + fileSystems."/home" = + { device = "zroot/root/home"; + fsType = "zfs"; + }; + + swapDevices = [ ]; + services.zfs.autoScrub.enable = true; +} diff --git a/1systems/flake-x/x230/default.nix b/1systems/flake-x/x230/default.nix new file mode 100644 index 0000000..c2a635c --- /dev/null +++ b/1systems/flake-x/x230/default.nix @@ -0,0 +1,19 @@ +{ + imports = [ + # + bluetooth + + + + + + # hard dependency because otherwise the device will not be unlocked + { + boot.initrd.luks.devices.luksroot = + { + device = "/dev/sda2"; + allowDiscards = true; + }; + } + { makefu.server.primary-itf = "wlp3s0"; } + ]; +}