From 71eb5dcbf924fa78a58f0277a2c4ec62a7772d30 Mon Sep 17 00:00:00 2001 From: Profpatsch Date: Fri, 16 Sep 2016 15:41:47 +0200 Subject: machines/katara: extract lib & add xmpp-client Some stuff is needed in multiple files, like the home directory. Extracted out into lib.nix. xmpp-client uses that to create a wrapper for splicing the password into the config at program invocation. --- machines/profpatsch/base.nix | 18 +++--------------- machines/profpatsch/katara.nix | 5 +++-- machines/profpatsch/lib.nix | 17 +++++++++++++++++ machines/profpatsch/pkgs.nix | 5 +++-- machines/profpatsch/xmpp-client.nix | 10 ++++++++++ 5 files changed, 36 insertions(+), 19 deletions(-) create mode 100644 machines/profpatsch/lib.nix create mode 100644 machines/profpatsch/xmpp-client.nix diff --git a/machines/profpatsch/base.nix b/machines/profpatsch/base.nix index c3bd1e73..19b3aa09 100644 --- a/machines/profpatsch/base.nix +++ b/machines/profpatsch/base.nix @@ -1,22 +1,10 @@ # A base configuration that still assumes a workstation { pkgs, lib, ... }: let - myPkgs = import ./pkgs.nix { inherit pkgs lib; }; - fish = pkgs.fish; - - authKeys = ["ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDJhthfk38lzDvoI7lPqRneI0yBpZEhLDGRBpcXzpPSu+V0YlgrDix5fHhBl+EKfw4aeQNvQNuAky3pDtX+BDK1b7idbz9ZMCExy2a1kBKDVJz/onLSQxiiZMuHlAljVj9iU4uoTOxX3vB85Ok9aZtMP1rByRIWR9e81/km4HdfZTCjFVRLWfvo0s29H7l0fnbG9bb2E6kydlvjnXJnZFXX+KUM16X11lK53ilPdPJdm87VtxeSKZ7GOiBz6q7FHzEd2Zc3CnzgupQiXGSblXrlN22IY3IWfm5S/8RTeQbMLVoH0TncgCeenXH7FU/sXD79ypqQV/WaVVDYMOirsnh/ philip@nyx"]; - - philip = rec { - name = "philip"; - extraGroups = [ "wheel" "networkmanager" ]; - uid = 1000; - createHome = true; - home = "/home/philip"; - passwordFile = "${home}/.config/passwd"; - shell = "${lib.getBin fish}/bin/fish"; - openssh.authorizedKeys.keys = authKeys; - }; + myPkgs = import ./pkgs.nix { inherit pkgs lib myLib; }; + myLib = import ./lib.nix { inherit pkgs lib; }; + philip = myLib.philip; in { diff --git a/machines/profpatsch/katara.nix b/machines/profpatsch/katara.nix index 68ad7b08..83dd4c93 100644 --- a/machines/profpatsch/katara.nix +++ b/machines/profpatsch/katara.nix @@ -1,7 +1,8 @@ { config, pkgs, unfreeAndNonDistributablePkgs, lib, ... }: let - myPkgs = import ./pkgs.nix { inherit pkgs lib; }; + myLib = import ./lib.nix { inherit pkgs lib; }; + myPkgs = import ./pkgs.nix { inherit pkgs lib myLib; }; in { @@ -127,7 +128,6 @@ in { myPkgs.mpv # you are my sun and my stars. and you play my stuff. newsbeuter # RSS/Atom feed reader pass # standard unix password manager - myPkgs.poezio # CLI XMPP client poppler_utils # pdfto* ranger # CLI file browser remind # calender & reminder program @@ -135,6 +135,7 @@ in { myPkgs.sent # suckless presentation tool pkgs.vuizvui.show-qr-code # display a QR code youtube-dl # download videos + myPkgs.xmpp-client # CLI XMPP Client zathura # pdf viewer ]; mailPkgs = [ diff --git a/machines/profpatsch/lib.nix b/machines/profpatsch/lib.nix new file mode 100644 index 00000000..745fc156 --- /dev/null +++ b/machines/profpatsch/lib.nix @@ -0,0 +1,17 @@ +{ lib, pkgs }: +rec { + fish = pkgs.fish; + + authKeys = ["ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDJhthfk38lzDvoI7lPqRneI0yBpZEhLDGRBpcXzpPSu+V0YlgrDix5fHhBl+EKfw4aeQNvQNuAky3pDtX+BDK1b7idbz9ZMCExy2a1kBKDVJz/onLSQxiiZMuHlAljVj9iU4uoTOxX3vB85Ok9aZtMP1rByRIWR9e81/km4HdfZTCjFVRLWfvo0s29H7l0fnbG9bb2E6kydlvjnXJnZFXX+KUM16X11lK53ilPdPJdm87VtxeSKZ7GOiBz6q7FHzEd2Zc3CnzgupQiXGSblXrlN22IY3IWfm5S/8RTeQbMLVoH0TncgCeenXH7FU/sXD79ypqQV/WaVVDYMOirsnh/ philip@nyx"]; + + philip = rec { + name = "philip"; + extraGroups = [ "wheel" "networkmanager" ]; + uid = 1000; + createHome = true; + home = "/home/philip"; + passwordFile = "${home}/.config/passwd"; + shell = "${lib.getBin fish}/bin/fish"; + openssh.authorizedKeys.keys = authKeys; + }; +} diff --git a/machines/profpatsch/pkgs.nix b/machines/profpatsch/pkgs.nix index a4d3e9af..3e96479b 100644 --- a/machines/profpatsch/pkgs.nix +++ b/machines/profpatsch/pkgs.nix @@ -1,4 +1,4 @@ -{ pkgs, lib }: +{ pkgs, lib, myLib }: with pkgs; let @@ -64,6 +64,7 @@ let sha256 = "03006xzs250knzcyr6j564kn9jf2a6cp3mxkpqsqmmyp6v28w90z"; })}/overrides.nix") {}; + xmpp-client = pkgs.callPackage (import ./xmpp-client.nix myLib.philip.home "irc/xmppOla.wtf") { inherit (pkgs) xmpp-client; }; in -{ inherit taffybar offlineimap sent mpv beets poezio vim fast-init; } +{ inherit taffybar offlineimap sent mpv beets poezio vim fast-init xmpp-client; } diff --git a/machines/profpatsch/xmpp-client.nix b/machines/profpatsch/xmpp-client.nix new file mode 100644 index 00000000..56d8b287 --- /dev/null +++ b/machines/profpatsch/xmpp-client.nix @@ -0,0 +1,10 @@ +home: passwordentry: +{ lib, writeScriptBin, xmpp-client, pass }: + +writeScriptBin "xmpp-client" '' + #!/usr/bin/env bash + PASS=$(${lib.getBin pass}/bin/pass "${passwordentry}" | head -n1) + ${lib.getBin xmpp-client}/bin/xmpp-client \ + --config-file <(sed "s/@PASS@/$PASS/" ${home}/.config/xmpp-client/config) +'' + -- cgit 1.4.1