aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/default.nix21
-rw-r--r--modules/default.nix2
-rw-r--r--modules/global.nix1
-rw-r--r--modules/services/default.nix34
-rw-r--r--modules/zsh.nix27
-rw-r--r--modules/zsh/default.nix41
-rw-r--r--modules/zsh/themes/stefan.zsh-theme9
-rw-r--r--void/home.nix6
-rwxr-xr-xvoid/services/dbus/log/run3
-rwxr-xr-xvoid/services/dbus/run11
-rwxr-xr-xvoid/services/pipewire/log/run3
-rwxr-xr-xvoid/services/pipewire/run1
12 files changed, 127 insertions, 32 deletions
diff --git a/lib/default.nix b/lib/default.nix
new file mode 100644
index 0000000..1d4ffd2
--- /dev/null
+++ b/lib/default.nix
@@ -0,0 +1,21 @@
+# wip, need to look into nixpkgs.lib.extend
+{
+ # create runit backend specific turnstile service
+ mkExecutableService =
+ {
+ name,
+ command,
+ log,
+ }:
+ let
+ sh = s: "#!/bin/sh\n${s}"
+ in
+ {
+ "${name}" = {
+ run = sh ''exec chpst -e "$TURNSTILE_ENV_DIR" ${command}'';
+ log = lib.sh ''exec vlogger -t ${name}-$(id -u) -p daemon'';
+ # creating syslog but tagging with uid, might want to change this to local logging?
+ # user cant read unless in socklog group and using socklog
+ };
+ }
+}
diff --git a/modules/default.nix b/modules/default.nix
index f924c45..a0510dc 100644
--- a/modules/default.nix
+++ b/modules/default.nix
@@ -4,7 +4,7 @@
./foot.nix
./mako.nix
./neovide.nix
- ./zsh.nix
+ ./zsh
./sway
./neovim
./qutebrowser
diff --git a/modules/global.nix b/modules/global.nix
index 5565476..adedc50 100644
--- a/modules/global.nix
+++ b/modules/global.nix
@@ -31,6 +31,7 @@ in
qutebrowser = {
wrapWithNixGL = cfg.notNixOS;
};
+ zsh.enable = true;
};
nixGL = lib.mkIf cfg.notNixOS {
diff --git a/modules/services/default.nix b/modules/services/default.nix
index 7409c59..b0d9d9a 100644
--- a/modules/services/default.nix
+++ b/modules/services/default.nix
@@ -3,11 +3,16 @@ let
cfg = config.modules.services;
inherit (lib) mkOption types listOf;
- runFile = name: value: {
+ mkService = name: value: {
${"service/" + name + "/run"} = {
text = value.run;
executable = true;
};
+ ${"service/" + name + "/log/run"} = {
+ enable = value.log != "";
+ text = value.log;
+ executable = true;
+ };
};
in
{
@@ -20,6 +25,12 @@ in
default = false;
description = "Whether to enable the user service manager module.";
};
+ coreServices = mkOption {
+ type = types.listOf types.str;
+ description = "List of services to start first";
+ example = [ "dbus" ];
+ default = [];
+ };
services = mkOption {
description = "List of user services to run on login";
type = types.attrsOf (types.submodule {
@@ -27,18 +38,33 @@ in
run = mkOption {
type = types.str;
description = "The 'run' script for the service";
- example = ''
- #!/bin/sh
+ example =
+ ''#!/bin/sh
exec chpst -e "$TURNSTILE_ENV_DIR" foo
'';
};
+ log = mkOption {
+ type = types.nullOr types.str;
+ description = "The log/run script for the service. A pipe is opened from the output of the 'run' process to this script";
+ example =
+ ''#!/bin/sh
+
+ exec vlogger -t dbus-$(id -u) -p daemon
+ '';
+ default = "";
+ };
};
});
};
};
config = lib.mkIf cfg.enable {
- xdg.configFile = (lib.concatMapAttrs runFile cfg.services);
+ xdg.configFile = (lib.concatMapAttrs mkService cfg.services)
+ // {
+ "service/turnstile-ready/conf" = {
+ text = ''core_services="${lib.strings.concatStringsSep " " cfg.coreServices}'';
+ };
+ };
};
}
diff --git a/modules/zsh.nix b/modules/zsh.nix
deleted file mode 100644
index 5085263..0000000
--- a/modules/zsh.nix
+++ /dev/null
@@ -1,27 +0,0 @@
-{ config, lib, pkgs, ... }:
-let
- cfg = config.modules.zsh;
-in
-{
- options.modules.zsh = {
- enable = lib.mkEnableOption "zsh";
- };
-
- config = {
- home.packages = with pkgs; [
- zsh
- oh-my-zsh
- zsh-autosuggestions
- ];
-
- programs.zsh = lib.mkIf cfg.enable {
- enable = true;
- enableCompletion = true;
- autosuggestion.enable = true;
- oh-my-zsh = {
- enable = true;
- theme = "lambda";
- };
- };
- };
-}
diff --git a/modules/zsh/default.nix b/modules/zsh/default.nix
new file mode 100644
index 0000000..b1ed82e
--- /dev/null
+++ b/modules/zsh/default.nix
@@ -0,0 +1,41 @@
+{ config, lib, pkgs, ... }:
+let
+ cfg = config.modules.zsh;
+
+ inherit (lib) mkEnableOption mkOption mkIf types;
+in
+{
+ options.modules.zsh = {
+ enable = mkEnableOption "zsh";
+ theme = mkOption {
+ type = types.str;
+ description = "name of zsh theme to apply";
+ default = "stefan";
+ };
+ };
+
+ config = mkIf cfg.enable {
+ home.packages = with pkgs; [
+ zsh
+ oh-my-zsh
+ zsh-autosuggestions
+ ];
+
+ home.file.".oh-my-zsh/themes" = {
+ source = ./themes;
+ recursive = true;
+ };
+
+ programs.zsh = {
+ enable = true;
+ enableCompletion = true;
+ autosuggestion.enable = true;
+ oh-my-zsh = {
+ enable = true;
+ };
+ initExtra = ''
+ source ~/.oh-my-zsh/themes/${cfg.theme}.zsh-theme
+ '';
+ };
+ };
+}
diff --git a/modules/zsh/themes/stefan.zsh-theme b/modules/zsh/themes/stefan.zsh-theme
new file mode 100644
index 0000000..4d71d9c
--- /dev/null
+++ b/modules/zsh/themes/stefan.zsh-theme
@@ -0,0 +1,9 @@
+function virtualenv_info {
+ [ $VIRTUAL_ENV ] && echo '('`basename $VIRTUAL_ENV`') '
+}
+
+NEWLINE=$'\n'
+PROMPT="%F{magenta}%~% %f% %F{yellow}% ${NEWLINE}λ %b%f%"
+RPROMPT='$(virtualenv_info)% $(git_prompt_info)'
+ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[green]%}"
+ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
diff --git a/void/home.nix b/void/home.nix
index 50fdb4a..482e31c 100644
--- a/void/home.nix
+++ b/void/home.nix
@@ -32,13 +32,19 @@
services = {
enable = true;
+ coreServices = ["dbus"];
services = {
"pipewire" = {
run = "${builtins.readFile ./services/pipewire/run}";
+ log = "${builtins.readFile ./services/pipewire/log/run}";
};
"mpd" = {
run = "${builtins.readFile ./services/mpd/run}";
};
+ "dbus" = {
+ run = "${builtins.readFile ./services/dbus/run}";
+ log = "${builtins.readFile ./services/dbus/log/run}";
+ };
};
};
};
diff --git a/void/services/dbus/log/run b/void/services/dbus/log/run
new file mode 100755
index 0000000..e19b6ec
--- /dev/null
+++ b/void/services/dbus/log/run
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+exec vlogger -t dbus-$(id -u) -p daemon
diff --git a/void/services/dbus/run b/void/services/dbus/run
new file mode 100755
index 0000000..dc7473e
--- /dev/null
+++ b/void/services/dbus/run
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+[ -r ./conf ] && . ./conf
+
+: "${DBUS_SESSION_BUS_ADDRESS:=unix:path=/run/user/$(id -u)/bus}"
+
+if [ -d "$TURNSTILE_ENV_DIR" ]; then
+ echo "$DBUS_SESSION_BUS_ADDRESS" > "$TURNSTILE_ENV_DIR"/DBUS_SESSION_BUS_ADDRESS
+fi
+
+exec chpst -e "$TURNSTILE_ENV_DIR" dbus-daemon --session --nofork --nopidfile --address="$DBUS_SESSION_BUS_ADDRESS" $OPTS
diff --git a/void/services/pipewire/log/run b/void/services/pipewire/log/run
new file mode 100755
index 0000000..223169a
--- /dev/null
+++ b/void/services/pipewire/log/run
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+exec vlogger -t pipewire-$(id -u) -p daemon
diff --git a/void/services/pipewire/run b/void/services/pipewire/run
index 1de4c3b..e3a5513 100755
--- a/void/services/pipewire/run
+++ b/void/services/pipewire/run
@@ -1,3 +1,4 @@
#!/bin/sh
exec chpst -e "$TURNSTILE_ENV_DIR" pipewire
+