diff options
Diffstat (limited to 'nixos/modules')
| -rw-r--r-- | nixos/modules/compile.nix | 8 | ||||
| -rw-r--r-- | nixos/modules/desktop.nix | 59 | ||||
| -rw-r--r-- | nixos/modules/develop.nix | 86 | ||||
| -rw-r--r-- | nixos/modules/devmin.nix | 37 | ||||
| -rw-r--r-- | nixos/modules/hosts.nix | 1 | ||||
| -rw-r--r-- | nixos/modules/monitoring.nix | 6 | ||||
| -rw-r--r-- | nixos/modules/openwrtone.nix | 2 | ||||
| -rw-r--r-- | nixos/modules/router.nix | 2 | ||||
| -rw-r--r-- | nixos/modules/rpi.nix | 6 | ||||
| -rw-r--r-- | nixos/modules/wifi-spt.nix | 2 | ||||
| -rw-r--r-- | nixos/modules/wifi-zd.nix | 177 |
11 files changed, 240 insertions, 146 deletions
diff --git a/nixos/modules/compile.nix b/nixos/modules/compile.nix index 3c90345..332a095 100644 --- a/nixos/modules/compile.nix +++ b/nixos/modules/compile.nix @@ -20,7 +20,10 @@ in { cores = 0; }; - boot.binfmt.emulatedSystems = ["armv7l-linux" "aarch64-linux" "riscv32-linux"]; + boot.binfmt = { + emulatedSystems = ["armv7l-linux" "aarch64-linux" "riscv32-linux"]; + preferStaticEmulators = true; + }; environment.systemPackages = with pkgs; [ # Tools @@ -28,9 +31,6 @@ in { bash #uroot qemu - - # Python - python3Packages.pip ]; }; } diff --git a/nixos/modules/desktop.nix b/nixos/modules/desktop.nix index 63eba7d..a321577 100644 --- a/nixos/modules/desktop.nix +++ b/nixos/modules/desktop.nix @@ -37,6 +37,8 @@ in { wrapperFeatures.gtk = true; extraPackages = with pkgs; [ + appimage-run + dconf-editor glib gsettings-desktop-schemas @@ -59,7 +61,7 @@ in { wl-mirror slurp grim - wf-recorder + #wf-recorder wl-clipboard wl-color-picker swayidle @@ -114,7 +116,6 @@ in { yt-dlp spotify - nordic nordzy-cursor-theme nordzy-icon-theme adwaita-icon-theme @@ -161,7 +162,6 @@ in { gst_all_1.gst-plugins-ugly gst_all_1.gst-plugins-rs gst_all_1.gst-libav - gst_all_1.gst-vaapi # Writing typst @@ -170,10 +170,10 @@ in { vale # CAD - freecad + #freecad kicad sweethome3d.application - #qelectrotech + qelectrotech super-slicer ] ++ (optionals cnf.laptop [ @@ -189,9 +189,9 @@ in { nativeMessagingHosts.packages = with pkgs; [browserpass]; }; - nix-ld = { + fuse = { enable = true; - libraries = with pkgs; [libXpm]; + userAllowOther = true; }; usbkey = { @@ -254,7 +254,7 @@ in { xserver.xkb.options = "grp:alt_shift_toggle,caps:escape"; # Gnome crypto services (GnuPG) - dbus.packages = [pkgs.gcr]; + dbus.packages = [pkgs.gcr_4]; pipewire = { enable = true; @@ -289,8 +289,33 @@ in { }; saned.enable = true; avahi.enable = true; + samba = { + enable = false; + openFirewall = true; + settings = { + global = { + "workgroup" = "WORKGROUP"; + "server string" = "smbnix"; + "netbios name" = "smbnix"; + "security" = "user"; + "hosts allow" = "0.0.0.0/0"; + "guest account" = "nobody"; + "map to guest" = "bad user"; + }; + public = { + "path" = "/mnt/public"; + "browseable" = "yes"; + "read only" = "no"; + "guest ok" = "yes"; + "create mask" = "0644"; + "directory mask" = "0755"; + "force user" = "cynerd"; + "force group" = "cynerd"; + }; + }; + }; samba-wsdd = { - enable = true; + enable = false; discovery = true; }; #davfs2.enable = true; TODO!!! @@ -369,13 +394,13 @@ in { }; # Support running app images - boot.binfmt.registrations.appimage = { - wrapInterpreterInShell = false; - interpreter = "${pkgs.appimage-run}/bin/appimage-run"; - recognitionType = "magic"; - offset = 0; - mask = ''\xff\xff\xff\xff\x00\x00\x00\x00\xff\xff\xff''; - magicOrExtension = ''\x7fELF....AI\x02''; - }; + #boot.binfmt.registrations.appimage = { + # wrapInterpreterInShell = false; + # interpreter = "${pkgs.appimage-run}/bin/appimage-run"; + # recognitionType = "magic"; + # offset = 0; + # mask = ''\xff\xff\xff\xff\x00\x00\x00\x00\xff\xff\xff''; + # magicOrExtension = ''\x7fELF....AI\x02''; + #}; }; } diff --git a/nixos/modules/develop.nix b/nixos/modules/develop.nix index 69c58bc..8b413a9 100644 --- a/nixos/modules/develop.nix +++ b/nixos/modules/develop.nix @@ -15,10 +15,13 @@ in { }; config = mkIf config.cynerd.develop { - cynerd.compile = true; - environment.enableDebugInfo = true; + cynerd = { + devmin = true; + compile = true; + }; environment.systemPackages = with pkgs; [ # Tools + git-lfs gitlint tig gitg @@ -33,6 +36,7 @@ in { vim-language-server vale can-utils + unixtools.xxd # Required for neovim plugins editorconfig-checker @@ -64,12 +68,14 @@ in { # C clang-tools + bear #massif-visualizer elf-size-analyze # Python (python3.withPackages (pypkgs: with pypkgs; [ + pip ipython python-lsp-server @@ -141,6 +147,9 @@ in { virt-manager cdrtools + # Docker + docker-credential-helpers + # U-Boot ubootTools tftp-hpa @@ -181,6 +190,43 @@ in { # package = pkgs.wireshark; #}; + programs.nix-ld = { + enable = true; + libraries = with pkgs; [ + alsa-lib + at-spi2-atk + cairo + cups + dbus + expat + gdk-pixbuf + glib + gtk3 + libGL + libXpm + libdrm + libgbm + libgcrypt + libsoup_3 + libudev0-shim + libusb1 + libx11 + libxcb + libxcomposite + libxdamage + libxext + libxfixes + libxkbcommon + libxrandr + nspr + nss + openssl + pango + udev + webkitgtk_4_1 + ]; + }; + documentation = { nixos = { enable = true; @@ -190,19 +236,18 @@ in { doc.enable = true; }; - services = { - udev.extraRules = '' - SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3748", MODE:="0660", GROUP="develop", SYMLINK+="stlinkv2_%n" - SUBSYSTEMS=="usb", ATTRS{idVendor}=="a600", ATTRS{idProduct}=="a003", MODE:="0660", GROUP="develop", SYMLINK+="aix_forte_%n" - SUBSYSTEMS=="usb", ATTRS{idVendor}=="1366", ATTRS{idProduct}=="0105", MODE:="0660", GROUP="develop", SYMLINK+="jlink_%n" - SUBSYSTEMS=="usb", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2111", MODE:="0660", GROUP="develop", SYMLINK+="cmsip_dap_%n" - SUBSYSTEMS=="usb", ATTRS{idVendor}=="1ab1", ATTRS{idProduct}=="0e11", MODE:="0660", GROUP="develop" - SUBSYSTEMS=="usb", ATTRS{idVendor}=="303a", ATTRS{idProduct}=="1001", MODE:="0660", GROUP="develop", TAG+="uaccess" - SUBSYSTEMS=="usb", ATTRS{idVendor}=="303a", ATTRS{idProduct}=="1002", MODE:="0660", GROUP="develop", TAG+="uaccess" - ''; - - guix.enable = true; - }; + services.guix.enable = true; + #environment.etc."guix/machines.scm".text = '' + # (list (build-machine + # (name "czellembsrv.elektroline.cz") + # (systems (list "x86_64-linux" "i686-linux")) + # (host-key "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICQZIwdzBo5CvMjS0M9tKYG2ikqPmSgSKRa/UPAoyhBC root@embsrv") + # (user "kkoci") + # (private-key "/home/cynerd/.ssh/elektroline-emb") + # (parallel-builds 16) + # (speed 2.0) + # )) + #''; virtualisation = { containers.enable = true; @@ -212,15 +257,20 @@ in { storageDriver = "btrfs"; }; lxc.enable = true; - libvirtd.enable = true; + libvirtd = { + enable = true; + qemu = { + swtpm.enable = true; + vhostUserPackages = with pkgs; [virtiofsd]; + }; + }; spiceUSBRedirection.enable = true; }; + networking.firewall.trustedInterfaces = ["virbr0"]; - users.groups.develop = {}; users.users.cynerd.extraGroups = [ "docker" "lxd" - "develop" "libvirtd" ]; }; diff --git a/nixos/modules/devmin.nix b/nixos/modules/devmin.nix new file mode 100644 index 0000000..767cf2c --- /dev/null +++ b/nixos/modules/devmin.nix @@ -0,0 +1,37 @@ +{ + config, + lib, + ... +}: let + inherit (lib) mkOption mkIf types; +in { + options = { + cynerd.devmin = mkOption { + type = types.bool; + default = false; + description = "If machine is about to be used for remote development."; + }; + }; + + config = mkIf config.cynerd.devmin { + environment.enableDebugInfo = true; + + users.groups.develop = {}; + users.users.cynerd.extraGroups = [ + "develop" + ]; + + services.udev.extraRules = '' + SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3748", MODE:="0660", GROUP="develop", SYMLINK+="stlinkv2_%n" + SUBSYSTEMS=="usb", ATTRS{idVendor}=="a600", ATTRS{idProduct}=="a003", MODE:="0660", GROUP="develop", SYMLINK+="aix_forte_%n" + SUBSYSTEMS=="usb", ATTRS{idVendor}=="1366", ATTRS{idProduct}=="0105", MODE:="0660", GROUP="develop", SYMLINK+="jlink_%n" + SUBSYSTEMS=="usb", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2111", MODE:="0660", GROUP="develop", SYMLINK+="cmsip_dap_%n" + SUBSYSTEMS=="usb", ATTRS{idVendor}=="0451", ATTRS{idProduct}=="bef3", MODE:="0660", GROUP="develop", SYMLINK+="xds110_%n" + SUBSYSTEMS=="usb", ATTRS{idVendor}=="1cbe", ATTRS{idProduct}=="00ff", MODE:="0660", GROUP="develop", SYMLINK+="xds110_update_%n" + SUBSYSTEMS=="usb", ATTRS{idVendor}=="0451", ATTRS{idProduct}=="16a2", MODE:="0660", GROUP="develop", SYMLINK+="ccdebugger_%n" + SUBSYSTEMS=="usb", ATTRS{idVendor}=="1ab1", ATTRS{idProduct}=="0e11", MODE:="0660", GROUP="develop" + SUBSYSTEMS=="usb", ATTRS{idVendor}=="303a", ATTRS{idProduct}=="1001", MODE:="0660", GROUP="develop", TAG+="uaccess" + SUBSYSTEMS=="usb", ATTRS{idVendor}=="303a", ATTRS{idProduct}=="1002", MODE:="0660", GROUP="develop", TAG+="uaccess" + ''; + }; +} diff --git a/nixos/modules/hosts.nix b/nixos/modules/hosts.nix index 0263d1c..0aafb12 100644 --- a/nixos/modules/hosts.nix +++ b/nixos/modules/hosts.nix @@ -32,6 +32,7 @@ in { # Network "mox" = "10.8.0.1"; "one0" = "10.8.0.2"; + "one0nix" = "10.8.0.3"; "camera1" = "10.8.0.21"; "camera2" = "10.8.0.22"; # Local diff --git a/nixos/modules/monitoring.nix b/nixos/modules/monitoring.nix index 481854c..96761b9 100644 --- a/nixos/modules/monitoring.nix +++ b/nixos/modules/monitoring.nix @@ -32,6 +32,12 @@ in { config = mkMerge [ (mkIf cnf.enable { + # Glances + services.glances = { + enable = true; + openFirewall = true; + }; + # Telegraf configuration services.telegraf = { enable = true; diff --git a/nixos/modules/openwrtone.nix b/nixos/modules/openwrtone.nix index c70dcbc..b4ffe06 100644 --- a/nixos/modules/openwrtone.nix +++ b/nixos/modules/openwrtone.nix @@ -56,7 +56,7 @@ in { }; # Use OpenWrt One specific kernel. It fixes SError with patch. - kernelPackages = mkDefault (pkgs.linuxPackagesFor pkgs.linux_7_0); + kernelPackages = mkDefault (pkgs.linuxPackagesFor pkgs.linux_7_2); kernelParams = [ "fw_devlink=permissive" "clk_ignore_unused" diff --git a/nixos/modules/router.nix b/nixos/modules/router.nix index 1c8f4cc..b01c94a 100644 --- a/nixos/modules/router.nix +++ b/nixos/modules/router.nix @@ -180,7 +180,7 @@ in { enable = true; settings.Resolve = { FallbackDNS = ["1.1.1.1" "8.8.8.8"]; - DNSStubListenerExtra=[cnf.lanIP "192.168.1.1"]; + DNSStubListenerExtra = [cnf.lanIP "192.168.1.1"]; # TODO possibly enforce DNSSEC again }; }; diff --git a/nixos/modules/rpi.nix b/nixos/modules/rpi.nix index e4e10fe..08a2e91 100644 --- a/nixos/modules/rpi.nix +++ b/nixos/modules/rpi.nix @@ -68,9 +68,9 @@ in { }; }; - services.journald.extraConfig = '' - SystemMaxUse=512M - ''; + services.journald.settings.Journal = { + SystemMaxUse = "512M"; + }; system.build.firmware = pkgs.callPackage ({stdenvNoCC}: stdenvNoCC.mkDerivation { diff --git a/nixos/modules/wifi-spt.nix b/nixos/modules/wifi-spt.nix index bec093e..dc1de09 100644 --- a/nixos/modules/wifi-spt.nix +++ b/nixos/modules/wifi-spt.nix @@ -21,7 +21,7 @@ wpaPasswordFile = "/run/secrets/hostapd-TurrisRules.pass"; }; settings = mkIf is2g { - ieee80211w = 0; + ieee80211w = mkForce 0; wpa_key_mgmt = mkForce "WPA-PSK"; # force use without sha256 }; }; diff --git a/nixos/modules/wifi-zd.nix b/nixos/modules/wifi-zd.nix index 107fdf4..c275fc3 100644 --- a/nixos/modules/wifi-zd.nix +++ b/nixos/modules/wifi-zd.nix @@ -3,70 +3,10 @@ lib, ... }: let - inherit (lib) mkOption mkEnableOption types mkIf mkForce mkMerge hostapd elemAt; + inherit (lib) mkOption mkEnableOption types mkIf mkForce elemAt; cnf = config.cynerd.wifiAP.zd; - wifi-networks = name: let - is2g = cnf."${name}".channel <= 14; - in { - "${cnf."${name}".interface}" = { - bssid = elemAt cnf."${name}".bssids 0; - ssid = "UNas${ - if is2g - then "" - else "5" - }"; - authentication = { - mode = "wpa2-sha256"; - wpaPasswordFile = "/run/secrets/hostapd-UNas.pass"; - }; - settings = mkIf is2g { - ieee80211w = 0; - wpa_key_mgmt = mkForce "WPA-PSK"; # force use without sha256 - }; - }; - "${cnf."${name}".interface}.guest" = { - bssid = elemAt cnf."${name}".bssids 1; - ssid = "Koci"; - authentication = { - mode = "wpa2-sha256"; - wpaPasswordFile = "/run/secrets/hostapd-Koci.pass"; - }; - }; - }; - - net-networks = name: { - "lan-${cnf."${name}".interface}" = { - matchConfig = { - Name = cnf."${name}".interface; - WLANInterfaceType = "ap"; - }; - networkConfig.Bridge = "brlan"; - bridgeVLANs = [ - { - EgressUntagged = 1; - PVID = 1; - } - ]; - }; - "lan-${cnf."${name}".interface}-guest" = { - matchConfig.Name = "${cnf."${name}".interface}.guest"; - networkConfig.Bridge = "brlan"; - bridgeVLANs = [ - { - EgressUntagged = 2; - PVID = 2; - } - ]; - }; - }; - - wOptions = card: channelDefault: { - interface = mkOption { - type = with types; nullOr str; - default = null; - description = "Specify interface for ${card}"; - }; + wOptions = { bssids = mkOption { type = with types; listOf str; default = []; @@ -74,16 +14,15 @@ }; channel = mkOption { type = types.ints.positive; - default = channelDefault; - description = "Channel to be used for ${card}"; + description = "Channel to be used"; }; }; in { options = { cynerd.wifiAP.zd = { - enable = mkEnableOption "Enable Wi-Fi Access Point support"; - ar9287 = wOptions "Qualcom Atheros AR9287" 7; - qca988x = wOptions "Qualcom Atheros QCA988x" 36; + enable = mkEnableOption "Enable Wi-Fi Access Point support (OpenWrt One)"; + wlan0 = wOptions; + wlan1 = wOptions; }; }; @@ -94,44 +33,80 @@ in { ''; services.hostapd = { enable = true; - radios = mkMerge [ - (mkIf (cnf.ar9287.interface != null) { - "${cnf.ar9287.interface}" = { - inherit (cnf.ar9287) channel; - countryCode = "CZ"; - wifi4 = { - enable = true; - inherit (hostapd.qualcomAtherosAR9287.wifi4) capabilities; - }; - networks = wifi-networks "ar9287"; + radios = { + "wlan0" = { + inherit (cnf.wlan0) channel; + countryCode = "CZ"; + wifi4 = { + enable = true; + capabilities = [ + "HT40" + "SHORT-GI-20" + "SHORT-GI-40" + "TX-STBC" + "RX-STBC1" + "MAX-AMSDU-7935" + ]; }; - }) - (mkIf (cnf.qca988x.interface != null) { - "${cnf.qca988x.interface}" = let - is2g = cnf.qca988x.channel <= 14; - in { - inherit (cnf.qca988x) channel; - countryCode = "CZ"; - band = - if is2g - then "2g" - else "5g"; - wifi4 = { - enable = true; - inherit (hostapd.qualcomAtherosQCA988x.wifi4) capabilities; + networks = { + "wlan0" = { + bssid = elemAt cnf.wlan0.bssids 0; + ssid = "UNas"; + authentication = { + mode = "wpa2-sha256"; + wpaPasswordFile = "/run/secrets/hostapd-UNas.pass"; + }; + }; + "wlan0.guest" = { + bssid = elemAt cnf.wlan0.bssids 1; + ssid = "Koci"; + authentication = { + mode = "wpa2-sha256"; + wpaPasswordFile = "/run/secrets/hostapd-Koci.pass"; + }; }; - wifi5 = { - enable = !is2g; - inherit (hostapd.qualcomAtherosQCA988x.wifi5) capabilities; + "wlan0.iotd" = { + bssid = elemAt cnf.wlan0.bssids 2; + ssid = "IOTD"; + authentication = { + mode = "wpa2-sha256"; + wpaPasswordFile = "/run/secrets/hostapd-IOTD.pass"; + }; + settings = { + ieee80211w = mkForce 0; + wpa_key_mgmt = mkForce "WPA-PSK"; # force use without sha256 + }; }; - networks = wifi-networks "qca988x"; }; - }) - ]; + }; + #"wlan1" = { + #}; + }; + }; + systemd.network.networks = { + "lan-wlan0" = { + matchConfig = { + Name = "wlan0 wlan0.iotd"; + WLANInterfaceType = "ap"; + }; + networkConfig.Bridge = "brlan"; + bridgeVLANs = [ + { + EgressUntagged = 1; + PVID = 1; + } + ]; + }; + "lan-wlan0-guest" = { + matchConfig.Name = "wlan0.guest"; + networkConfig.Bridge = "brlan"; + bridgeVLANs = [ + { + EgressUntagged = 2; + PVID = 2; + } + ]; + }; }; - systemd.network.networks = mkMerge [ - (mkIf (cnf.ar9287.interface != null) (net-networks "ar9287")) - (mkIf (cnf.qca988x.interface != null) (net-networks "qca988x")) - ]; }; } |
