diff options
Diffstat (limited to 'nixos/modules')
-rw-r--r-- | nixos/modules/module-list.nix | 1 | ||||
-rw-r--r-- | nixos/modules/rename.nix | 4 | ||||
-rw-r--r-- | nixos/modules/services/hardware/xow.nix | 20 | ||||
-rw-r--r-- | nixos/modules/services/misc/klipper.nix | 90 |
4 files changed, 71 insertions, 44 deletions
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index d961e2f683bd5..616f357663cac 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -475,7 +475,6 @@ ./services/hardware/thermald.nix ./services/hardware/undervolt.nix ./services/hardware/vdr.nix - ./services/hardware/xow.nix ./services/home-automation/home-assistant.nix ./services/home-automation/zigbee2mqtt.nix ./services/logging/SystemdJournal2Gelf.nix diff --git a/nixos/modules/rename.nix b/nixos/modules/rename.nix index 22fcb72e9ff40..f86aa2fa5c1bf 100644 --- a/nixos/modules/rename.nix +++ b/nixos/modules/rename.nix @@ -30,6 +30,10 @@ with lib; udev rules from libu2f-host to the system. Udev gained native support to handle FIDO security tokens, so this isn't necessary anymore. '') + (mkRemovedOptionModule [ "hardware" "xow" ] '' + The xow package was removed from nixpkgs. Upstream has deprecated + the project and users are urged to switch to xone. + '') (mkRemovedOptionModule [ "networking" "vpnc" ] "Use environment.etc.\"vpnc/service.conf\" instead.") (mkRemovedOptionModule [ "networking" "wicd" ] "The corresponding package was removed from nixpkgs.") (mkRemovedOptionModule [ "programs" "tilp2" ] "The corresponding package was removed from nixpkgs.") diff --git a/nixos/modules/services/hardware/xow.nix b/nixos/modules/services/hardware/xow.nix deleted file mode 100644 index 311181176bd83..0000000000000 --- a/nixos/modules/services/hardware/xow.nix +++ /dev/null @@ -1,20 +0,0 @@ -{ config, pkgs, lib, ... }: - -let - cfg = config.services.hardware.xow; -in { - options.services.hardware.xow = { - enable = lib.mkEnableOption "xow as a systemd service"; - }; - - config = lib.mkIf cfg.enable { - hardware.uinput.enable = true; - - boot.extraModprobeConfig = lib.readFile "${pkgs.xow}/lib/modprobe.d/xow-blacklist.conf"; - - systemd.packages = [ pkgs.xow ]; - systemd.services.xow.wantedBy = [ "multi-user.target" ]; - - services.udev.packages = [ pkgs.xow ]; - }; -} diff --git a/nixos/modules/services/misc/klipper.nix b/nixos/modules/services/misc/klipper.nix index 7b3780b5cc9ff..fee7779141cdd 100644 --- a/nixos/modules/services/misc/klipper.nix +++ b/nixos/modules/services/misc/klipper.nix @@ -5,9 +5,9 @@ let format = pkgs.formats.ini { # https://github.com/NixOS/nixpkgs/pull/121613#issuecomment-885241996 listToValue = l: - if builtins.length l == 1 then generators.mkValueStringDefault {} (head l) + if builtins.length l == 1 then generators.mkValueStringDefault { } (head l) else lib.concatMapStrings (s: "\n ${generators.mkValueStringDefault {} s}") l; - mkKeyValue = generators.mkKeyValueDefault {} ":"; + mkKeyValue = generators.mkKeyValueDefault { } ":"; }; in { @@ -69,6 +69,24 @@ in for supported values. ''; }; + + firmwares = mkOption { + description = "Firmwares klipper should manage"; + default = { }; + type = with types; attrsOf + (submodule { + options = { + enable = mkEnableOption '' + building of firmware and addition of klipper-flash tools for manual flashing. + This will add `klipper-flash-$mcu` scripts to your environment which can be called to flash the firmware. + ''; + configFile = mkOption { + type = path; + description = "Path to firmware config which is generated using `klipper-genconf`"; + }; + }; + }); + }; }; }; @@ -83,6 +101,10 @@ in assertion = cfg.user != null -> cfg.group != null; message = "Option klipper.group is not set when a user is specified."; } + { + assertion = foldl (a: b: a && b) true (mapAttrsToList (mcu: _: mcu != null -> (hasAttrByPath [ "${mcu}" "serial" ] cfg.settings)) cfg.firmwares); + message = "Option klipper.settings.$mcu.serial must be set when klipper.firmware.$mcu is specified"; + } ]; environment.etc."klipper.cfg".source = format.generate "klipper.cfg" cfg.settings; @@ -92,26 +114,48 @@ in group = config.services.octoprint.group; }; - systemd.services.klipper = let - klippyArgs = "--input-tty=${cfg.inputTTY}" - + optionalString (cfg.apiSocket != null) " --api-server=${cfg.apiSocket}"; - in { - description = "Klipper 3D Printer Firmware"; - wantedBy = [ "multi-user.target" ]; - after = [ "network.target" ]; - - serviceConfig = { - ExecStart = "${cfg.package}/lib/klipper/klippy.py ${klippyArgs} /etc/klipper.cfg"; - RuntimeDirectory = "klipper"; - SupplementaryGroups = [ "dialout" ]; - WorkingDirectory = "${cfg.package}/lib"; - } // (if cfg.user != null then { - Group = cfg.group; - User = cfg.user; - } else { - DynamicUser = true; - User = "klipper"; - }); - }; + systemd.services.klipper = + let + klippyArgs = "--input-tty=${cfg.inputTTY}" + + optionalString (cfg.apiSocket != null) " --api-server=${cfg.apiSocket}"; + in + { + description = "Klipper 3D Printer Firmware"; + wantedBy = [ "multi-user.target" ]; + after = [ "network.target" ]; + + serviceConfig = { + ExecStart = "${cfg.package}/lib/klipper/klippy.py ${klippyArgs} /etc/klipper.cfg"; + RuntimeDirectory = "klipper"; + SupplementaryGroups = [ "dialout" ]; + WorkingDirectory = "${cfg.package}/lib"; + } // (if cfg.user != null then { + Group = cfg.group; + User = cfg.user; + } else { + DynamicUser = true; + User = "klipper"; + }); + }; + + environment.systemPackages = + with pkgs; + let + firmwares = filterAttrs (n: v: v!= null) (mapAttrs + (mcu: { enable, configFile }: if enable then pkgs.klipper-firmware.override { + mcu = lib.strings.sanitizeDerivationName mcu; + firmwareConfig = configFile; + } else null) + cfg.firmwares); + firmwareFlasher = mapAttrsToList + (mcu: firmware: pkgs.klipper-flash.override { + mcu = lib.strings.sanitizeDerivationName mcu; + klipper-firmware = firmware; + flashDevice = cfg.settings."${mcu}".serial; + firmwareConfig = cfg.firmwares."${mcu}".configFile; + }) + firmwares; + in + [ klipper-genconf ] ++ firmwareFlasher ++ attrValues firmwares; }; } |