{ description = "frajtano: an ssh agent multiplexer"; outputs = { self, nixpkgs, systems, }: let inherit (nixpkgs) lib; eachSystem = f: lib.genAttrs (import systems) (system: f { inherit system; pkgs = nixpkgs.legacyPackages.${system}; ownPkgs = self.packages.${system}; }); in { devShells = eachSystem ({ pkgs, ownPkgs, ... }: { default = pkgs.beam.packages.erlang_26.callPackage ./shell.nix { inherit ownPkgs; }; }); packages = eachSystem ({pkgs, ...}: { default = pkgs.beam.packages.erlang_26.callPackage ./default.nix {}; }); homeModules.default = { config, lib, pkgs, ... }: let cfg = config.bluepython508.frajtano; in { options.bluepython508.frajtano = { enable = lib.mkEnableOption "frajtano"; dir = lib.mkOption { description = "directory in which to place the listening socket"; default = "${config.home.homeDirectory}/.ssh/frajtano"; type = lib.types.path; }; initialPeers = lib.mkOption { description = "initially spawned peers - will be passed to /usr/bin/env"; type = with lib.types; listOf (listOf str); default = []; }; }; config = let peers = lib.strings.concatMapStringsSep ", " (args: ''{:spawn, {"${pkgs.coreutils}/bin/env", [${lib.concatMapStringsSep ", " (s: ''~S{${s}}'') args}]}}'') cfg.initialPeers; configFile = pkgs.writeText "config.exs" '' import Config config :frajtano, initial_peers: [${peers}] ''; in lib.mkIf cfg.enable { home.sessionVariables.FRAJTANO_DIR = cfg.dir; home.packages = [self.packages.${pkgs.system}.default]; systemd.user.services.frajtano = { Unit.Description = "frajtano"; Unit.After = ["default.target"]; Service.Type = "notify"; Service.Environment = ["'FRAJTANO_DIR=${cfg.dir}'" "'FRAJTANO_CONFIG=${configFile}'"]; Service.ExecSearchPath = ["${self.packages.${pkgs.system}.default}/bin"]; Service.ExecStart = "frajtano start"; Install.WantedBy = ["default.target"]; }; launchd.agents.frajtano = { enable = true; config = { EnvironmentVariables = { FRAJTANO_DIR = cfg.dir; FRAJTANO_CONFIG = configFile; }; ProgramArguments = ["${self.packages.${pkgs.system}.default}/bin/frajtano" "start"]; RunAtLoad = true; KeepAlive = true; }; }; }; }; }; }