diff options
| author | Arpit Chakladar <arpitchakladar+git@gmail.com> | 2026-08-29 03:45:10 +0530 |
|---|---|---|
| committer | Arpit Chakladar <arpitchakladar+git@gmail.com> | 2026-08-29 03:50:33 +0530 |
| commit | 1a39cf221e3f647df0767c88d89a54e3813e7019 (patch) | |
| tree | b3df1afb0bcc0942a364f267f993ed1a9bfb9434 /modules/system | |
| parent | e9e375f5f5263964fe89479a2610081000959774 (diff) | |
| download | home-manager-config-1a39cf221e3f647df0767c88d89a54e3813e7019.tar.gz home-manager-config-1a39cf221e3f647df0767c88d89a54e3813e7019.zip | |
refactor: adding explicit options to enable scripts
- some scripts that are not critical to the functioning of other
options, can be enabled/disabled
Diffstat (limited to 'modules/system')
| -rw-r--r-- | modules/system/deep-clean/default.nix | 28 | ||||
| -rw-r--r-- | modules/system/nix-update/default.nix | 58 |
2 files changed, 64 insertions, 22 deletions
diff --git a/modules/system/deep-clean/default.nix b/modules/system/deep-clean/default.nix index af75382..02022fe 100644 --- a/modules/system/deep-clean/default.nix +++ b/modules/system/deep-clean/default.nix @@ -6,13 +6,25 @@ ... }: let - inherit ((import ../../lib/script.nix { inherit lib pkgs; })) mkScriptModule; + deepCleanScript = pkgs.writeShellApplication { + name = "deep-clean"; + runtimeInputs = [ pkgs.bash ]; + text = builtins.readFile ./deep-clean.sh; + }; in -mkScriptModule { - scope = [ "system" ]; - name = "deep-clean"; - path = ./deep-clean.sh; - description = "Deep clean script for Nix systems\nRemoves old generations, garbage, and optimizes store\nWARNING: Do NOT run with sudo - run as normal user"; - deps = [ pkgs.bash ]; - inherit config; +{ + options.system.deep-clean = { + enable = lib.mkEnableOption "Enables the deep-clean script."; + + package = lib.mkOption { + type = lib.types.package; + readOnly = true; + default = deepCleanScript; + description = "The deep-clean script package."; + }; + }; + + config = lib.mkIf config.system.deep-clean.enable { + home.packages = [ config.system.deep-clean.package ]; + }; } diff --git a/modules/system/nix-update/default.nix b/modules/system/nix-update/default.nix index 13c15f6..4d00c77 100644 --- a/modules/system/nix-update/default.nix +++ b/modules/system/nix-update/default.nix @@ -6,19 +6,49 @@ ... }: let - inherit ((import ../../lib/script.nix { inherit lib pkgs; })) mkScriptModule; + nixUpdateScript = pkgs.writeShellApplication { + name = "nix-update"; + runtimeInputs = [ + pkgs.git + pkgs.nix + config.programs.home-manager.package + pkgs.bash + ]; + text = builtins.readFile ./nix-update.sh; + }; + + nixUpdateCompletion = + pkgs.runCommand "nix-update-completion" + { + nativeBuildInputs = [ pkgs.installShellFiles ]; + } + '' + mkdir -p $out/share/zsh/site-functions + installShellCompletion --zsh --name _nix-update ${pkgs.writeText "nix-update.zsh" (builtins.readFile ./nix-update.zsh)} + ''; + + nixUpdateScriptPkg = pkgs.symlinkJoin { + name = "nix-update"; + paths = [ + nixUpdateScript + nixUpdateCompletion + ]; + meta = nixUpdateScript.meta or { }; + }; in -mkScriptModule { - scope = [ "system" ]; - name = "nix-update"; - path = ./nix-update.sh; - description = "Update NixOS and/or Home Manager flake configuration\nRuns nix flake update and rebuilds the system"; - deps = [ - pkgs.git - pkgs.nix - config.programs.home-manager.package - pkgs.bash - ]; - completion.zsh = builtins.readFile ./nix-update.zsh; - inherit config; +{ + options.system.nix-update = { + enable = lib.mkEnableOption "Update NixOS and/or Home Manager flake configuration"; + + package = lib.mkOption { + type = lib.types.package; + readOnly = true; + default = nixUpdateScriptPkg; + description = "The nix-update script package."; + }; + }; + + config = lib.mkIf config.system.nix-update.enable { + home.packages = [ config.system.nix-update.package ]; + }; } |
