From 71dbe6ef932693f48df00f9c2d3d38091f68efc3 Mon Sep 17 00:00:00 2001 From: Sameer Rahmani Date: Tue, 16 Apr 2024 22:34:30 +0100 Subject: [PATCH] Break up the git feature in its own module --- nix/fg42/lib.nix | 19 +++++++++++++++++++ nix/modules/default.nix | 1 + nix/modules/git/default.nix | 7 +++++-- nix/modules/unit/default.nix | 1 - 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/nix/fg42/lib.nix b/nix/fg42/lib.nix index fedaef6..5dbbca0 100644 --- a/nix/fg42/lib.nix +++ b/nix/fg42/lib.nix @@ -16,12 +16,31 @@ { pkgs, ... }: final: prev: rec { + /* + Create a value to be accessable on the Elisp side as a variable. + */ defVar = name: defaultValue: docstring: { inherit name defaultValue docstring; }; + /* + Create a value to be accessable on the Elisp side as a constant. + */ defConst = defVar; + /* Creates an Option attribute set for a boolean value option i.e an + option to be toggled on or off. The option is enabled by default: + + Example: + mkAndEnableOption "foo" + => { _type = "option"; default = true; description = "Whether to enable foo."; example = true; type = { ... }; } + */ + mkAndEnableOption = name: prev.mkOption { + default = true; + example = true; + description = "Whether to enable ${name}."; + type = prev.types.bool; + }; makeFG42Drv = { pname, version, ... }@args: (pkgs.emacsPackages.trivialBuild args).overrideAttrs (old: { diff --git a/nix/modules/default.nix b/nix/modules/default.nix index e6d4b5b..eb5d9f3 100644 --- a/nix/modules/default.nix +++ b/nix/modules/default.nix @@ -24,6 +24,7 @@ let modules = [ ./editor ./elisp + ./git ]; pkgsModule = { config, ... }: { diff --git a/nix/modules/git/default.nix b/nix/modules/git/default.nix index 849559e..d6b357d 100644 --- a/nix/modules/git/default.nix +++ b/nix/modules/git/default.nix @@ -22,7 +22,8 @@ { lib, config, pkgs, makeFG42Drv, ... }: with lib; let - cfg = config.fg42.features; + cfg = config.fg42.features.git; + deps = (with pkgs.emacsPackages; [ magit @@ -38,7 +39,7 @@ let }; in { - options.fg42.features.git = mkEnableOption "git"; + options.fg42.features.git.enable = mkAndEnableOption "git"; config = mkIf cfg.enable { fg42.elispPackages = [ drv ] ++ deps; @@ -46,5 +47,7 @@ in fg42.paths = (with pkgs;[ git ]); + + fg42.requires = [ drv.pname ]; }; } diff --git a/nix/modules/unit/default.nix b/nix/modules/unit/default.nix index 85a6a3c..8d98b23 100644 --- a/nix/modules/unit/default.nix +++ b/nix/modules/unit/default.nix @@ -104,7 +104,6 @@ in fg42.requires = mkOption { type = types.listOf types.str; - readOnly = true; description = '' A list of Emacs packages to preload in compile time.