From 667cb52ab1583401742e4bcdc79321c3fcbfa2c0 Mon Sep 17 00:00:00 2001 From: Arpit Chakladar Date: Wed, 22 Apr 2026 19:07:39 +0530 Subject: created a utils library for the home manager config --- utils/default.nix | 3 +++ utils/scripts.nix | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 utils/default.nix create mode 100644 utils/scripts.nix (limited to 'utils') diff --git a/utils/default.nix b/utils/default.nix new file mode 100644 index 0000000..b4dac37 --- /dev/null +++ b/utils/default.nix @@ -0,0 +1,3 @@ +{ + scripts = import ./scripts.nix; +} diff --git a/utils/scripts.nix b/utils/scripts.nix new file mode 100644 index 0000000..87639c6 --- /dev/null +++ b/utils/scripts.nix @@ -0,0 +1,33 @@ +{ + lib, + pkgs, + config, +}: + +{ + # We define mkScript as a function that takes the context it needs + mkScript = + name: path: env: + let + # Logic inside the helper + defaultShell = + if (config.tools.zsh.enable or false) then + (lib.getExe config.programs.zsh.package) + else + "/usr/bin/env sh"; + + envVars = lib.concatStringsSep "\n" ( + lib.mapAttrsToList (n: v: "export ${n}=\"${toString v}\"") env + ); + in + pkgs.writeTextFile { + inherit name; + executable = true; + destination = "/bin/${name}"; + text = '' + #!${defaultShell} + ${envVars} + ${builtins.readFile path} + ''; + }; +} -- cgit v1.2.3