diff options
| author | Arpit Chakladar <arpitchakladar@proton.me> | 2026-04-22 19:07:39 +0530 |
|---|---|---|
| committer | Arpit Chakladar <arpitchakladar@proton.me> | 2026-04-22 19:07:39 +0530 |
| commit | 667cb52ab1583401742e4bcdc79321c3fcbfa2c0 (patch) | |
| tree | d02325e80008fd5fd5f1680ae07c562c6bb94246 /utils/scripts.nix | |
| parent | f0244e9a7c7fa5a6a708d41f1d3f928daa7989f8 (diff) | |
| download | home-manager-config-667cb52ab1583401742e4bcdc79321c3fcbfa2c0.tar.gz home-manager-config-667cb52ab1583401742e4bcdc79321c3fcbfa2c0.zip | |
created a utils library for the home manager config
Diffstat (limited to 'utils/scripts.nix')
| -rw-r--r-- | utils/scripts.nix | 33 |
1 files changed, 33 insertions, 0 deletions
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} + ''; + }; +} |
