From 588dddb07d900e9aa864c3417225f8ca53562a1a Mon Sep 17 00:00:00 2001 From: "Gustavo \"Guz\" L de Mello" Date: Sun, 24 Aug 2025 14:27:30 -0300 Subject: [PATCH] feat: job context --- configuration.nix | 4 ++++ flake.nix | 2 ++ home/worm/default.nix | 5 +++-- modules/nixos/context.nix | 17 +++++++++++++++++ 4 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 modules/nixos/context.nix diff --git a/configuration.nix b/configuration.nix index 1ed7da9..5a2d2c7 100644 --- a/configuration.nix +++ b/configuration.nix @@ -7,6 +7,10 @@ ./secrets.nix ]; + context = { + job = false; + }; + # GnuPG keyring programs.gnupg.agent = { enable = true; diff --git a/flake.nix b/flake.nix index 8bdfbeb..0bf223e 100644 --- a/flake.nix +++ b/flake.nix @@ -94,6 +94,7 @@ ++ [ ./hosts/battleship/configuration.nix inputs.stylix.nixosModules.stylix + ./modules/nixos/context.nix ./home/guz/configuration.nix ]; }; @@ -111,6 +112,7 @@ ++ [ ./hosts/figther/configuration.nix inputs.stylix.nixosModules.stylix + ./modules/nixos/context.nix ./home/guz-lite/configuration.nix ]; }; diff --git a/home/worm/default.nix b/home/worm/default.nix index 96268c5..2b0e285 100644 --- a/home/worm/default.nix +++ b/home/worm/default.nix @@ -1,5 +1,6 @@ { self, + lib, pkgs, osConfig, ... @@ -12,10 +13,10 @@ ]; devkit.enable = true; - devkit.git.wrapper = pkgs.writeShellScriptBin "git-envs" '' + devkit.git.wrapper = lib.mkIf (osConfig.context.job) (pkgs.writeShellScriptBin "git-envs" '' source ${osConfig.sops.secrets."guz/git-envs".path} "$@" - ''; + ''); # The *state version* indicates which default # settings are in effect and will therefore help avoid breaking diff --git a/modules/nixos/context.nix b/modules/nixos/context.nix new file mode 100644 index 0000000..a9ac8c4 --- /dev/null +++ b/modules/nixos/context.nix @@ -0,0 +1,17 @@ +{lib, ...}: +with lib; { + options.context = mkOption { + type = with types; let + primitive = oneOf [ + bool + int + str + path + (attrsOf primitive) + (listOf primitive) + ]; + in + attrsOf primitive; + default = {}; + }; +}