42 lines
1.4 KiB
Nix
42 lines
1.4 KiB
Nix
{ config, lib, pkgs, python3Full, ... }:
|
|
let
|
|
cfg = config.local.packages.linuxcnc;
|
|
inherit (builtins) filter map pathExists listToAttrs;
|
|
linuxcncWithEC = pkgs.linuxcnc.overrideAttrs (oldAttrs: {
|
|
buildInputs = oldAttrs.buildInputs ++ [ pkgs.linuxcnc-ethercat pkgs.hal-cia402 ];
|
|
postInstall = oldAttrs.postInstall + ''
|
|
ln -s ${pkgs.linuxcnc-ethercat}/bin/* $out/bin/
|
|
ln -s ${pkgs.linuxcnc-ethercat}/lib/linuxcnc/modules/* $out/lib/linuxcnc/modules/
|
|
ln -s ${pkgs.linuxcnc-ethercat}/share/linuxcnc-ethercat $out/share/
|
|
|
|
ln -s ${pkgs.hal-cia402}/lib/linuxcnc/modules/* $out/lib/linuxcnc/modules/
|
|
'';
|
|
});
|
|
|
|
pythonPkg = (python3Full.withPackages (ps: [
|
|
ps.pyserial # for camera feedback into linuxcnc
|
|
]));
|
|
|
|
linuxcncEnv = pkgs.buildEnv {
|
|
name = "linuxcnc-env";
|
|
paths = with pkgs; [ linuxcncWithEC hal-cia402 linuxcnc-ethercat pythonPkg ];
|
|
};
|
|
|
|
in {
|
|
options.local.packages.linuxcnc.enable = lib.mkEnableOption "Enable linuxcnc";
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
environment.systemPackages = with pkgs; [ linuxcncEnv ];
|
|
|
|
security.wrappers = listToAttrs (map (f: {
|
|
name = f;
|
|
value = {
|
|
setuid = true;
|
|
owner = "root";
|
|
group = "root";
|
|
source = "${linuxcncWithEC}/bin/${f}-nosetuid";
|
|
};
|
|
}) (filter (f: pathExists "${linuxcncWithEC}/bin/${f}-nosetuid") linuxcncWithEC.setuidApps));
|
|
};
|
|
}
|