From 24618092b001cf4ff0ac64a09918260a0f663400 Mon Sep 17 00:00:00 2001 From: "Gustavo \"Guz\" L. de Mello" Date: Mon, 8 Apr 2024 17:47:42 -0300 Subject: [PATCH] refactor: move cli.nix to nih/default.nix --- modules/nixos/programs/nih/cli.nix | 40 -------------------------- modules/nixos/programs/nih/default.nix | 32 ++++++++++++++++++--- 2 files changed, 28 insertions(+), 44 deletions(-) delete mode 100644 modules/nixos/programs/nih/cli.nix diff --git a/modules/nixos/programs/nih/cli.nix b/modules/nixos/programs/nih/cli.nix deleted file mode 100644 index bfd5bd5..0000000 --- a/modules/nixos/programs/nih/cli.nix +++ /dev/null @@ -1,40 +0,0 @@ -{ - config, - lib, - pkgs, - ... -}: let - cfg = config.programs.nih; - cli = pkgs.writeShellScriptBin "nih" '' - # Since alias= doesn't work in bash scripts - function alejandra() { ${pkgs.alejandra}/bin/alejandra "$@"; } - function git() { ${pkgs.git}/bin/git "$@"; } - function gum() { ${pkgs.gum}/bin/gum "$@"; } - function lazygit() { ${pkgs.lazygit}/bin/lazygit "$@"; } - function notify-send() { - (${pkgs.libnotify}/bin/notify-send "$@" &>/dev/null || echo "") - } - function mktemp() { ${pkgs.mktemp}/bin/mktemp "$@"; } - - flake_dir="${toString cfg.flakeDir}"; - host="${toString cfg.host}"; - - - ${builtins.readFile ./cli.sh} - ''; -in { - imports = []; - options.nih = with lib; - with lib.types; { - cli = mkOption { - type = bool; - default = cfg.enable; - }; - }; - config = with lib; - mkIf cfg.enable { - environment.systemPackages = [ - cli - ]; - }; -} diff --git a/modules/nixos/programs/nih/default.nix b/modules/nixos/programs/nih/default.nix index c0f49db..beeeb2a 100644 --- a/modules/nixos/programs/nih/default.nix +++ b/modules/nixos/programs/nih/default.nix @@ -5,10 +5,25 @@ ... }: let cfg = config.programs.nih; + cli = pkgs.writeShellScriptBin "nih" '' + # Since alias= doesn't work in bash scripts + function alejandra() { ${pkgs.alejandra}/bin/alejandra "$@"; } + function git() { ${pkgs.git}/bin/git "$@"; } + function gum() { ${pkgs.gum}/bin/gum "$@"; } + function lazygit() { ${pkgs.lazygit}/bin/lazygit "$@"; } + function notify-send() { + (${pkgs.libnotify}/bin/notify-send "$@" &>/dev/null || echo "") + } + function mktemp() { ${pkgs.mktemp}/bin/mktemp "$@"; } + + flake_dir="${toString cfg.flakeDir}"; + host="${toString cfg.host}"; + + + ${builtins.readFile ./cli.sh} + ''; in { - imports = [ - ./cli.nix - ]; + imports = []; options.programs.nih = with lib; with lib.types; { enable = mkEnableOption ""; @@ -18,6 +33,15 @@ in { flakeDir = mkOption { type = str; }; + cli = mkOption { + type = bool; + default = cfg.enable; + }; }; - config = with lib; mkIf cfg.enable {}; + config = with lib; + mkIf cfg.enable { + environment.systemPackages = [ + cli + ]; + }; }