89 lines
2.8 KiB
Nix
89 lines
2.8 KiB
Nix
{
|
|
description = "frajtano: an ssh agent multiplexer";
|
|
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
|
|
|
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;
|
|
};
|
|
initialBackingAgents = lib.mkOption {
|
|
description = "initially spawned backing_agents - will be passed to /usr/bin/env";
|
|
type = with lib.types; listOf (listOf str);
|
|
default = [];
|
|
};
|
|
};
|
|
|
|
config = let
|
|
backing_agents = lib.strings.concatMapStringsSep ", " (args: ''{:spawn, {"${pkgs.coreutils}/bin/env", [${lib.concatMapStringsSep ", " (s: ''~S{${s}}'') args}]}}'') cfg.initialBackingAgents;
|
|
configFile = pkgs.writeText "config.exs" ''
|
|
import Config
|
|
config :frajtano, initial_backing_agents: [${backing_agents}]
|
|
'';
|
|
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;
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
}
|