diff options
author | aszlig <aszlig@redmoonstudios.org> | 2015-03-18 02:46:15 +0100 |
---|---|---|
committer | aszlig <aszlig@redmoonstudios.org> | 2015-03-18 02:46:15 +0100 |
commit | e91c0b0c2269a8ab0158863dc1c074daf46001f7 (patch) | |
tree | cfb21b6e78bc61de7b653a71db5af06a61951a72 /modules/git/default.nix | |
parent | 147ee83ee25b0c5d4a0600b12e31d6c994a5a9ca (diff) |
modules: Move own stuff into modules/user/aszlig.
Some modules might be generic enough to be included in modules/ directly, but for now, let's just get them out of the way. Signed-off-by: aszlig <aszlig@redmoonstudios.org>
Diffstat (limited to 'modules/git/default.nix')
-rw-r--r-- | modules/git/default.nix | 72 |
1 files changed, 0 insertions, 72 deletions
diff --git a/modules/git/default.nix b/modules/git/default.nix deleted file mode 100644 index 65aefb45..00000000 --- a/modules/git/default.nix +++ /dev/null @@ -1,72 +0,0 @@ -{ config, lib, pkgs, ... }: - -with lib; - -let - genConf = attrs: let - escStr = s: "\"${escape [ "\"" "\\" ] s}\""; - mkVal = v: if isBool v && v then "true" - else if isBool v && !v then "false" - else escStr (toString v); - mkLine = key: val: "${key} = ${mkVal val}"; - - filterNull = filterAttrs (_: v: !(isNull v)); - - mkSection = sect: subsect: vals: '' - [${sect}${optionalString (subsect != null) " ${escStr subsect}"}] - ${concatStringsSep "\n" (mapAttrsToList mkLine (filterNull vals))} - ''; - - mkConf = sect: content: let - subs = filterAttrs (_: isAttrs) content; - nonSubs = filterAttrs (_: s: !isAttrs s) content; - hasPlain = (attrNames nonSubs) != []; - plainSects = singleton (mkSection sect null nonSubs); - in mapAttrsToList (mkSection sect) subs ++ optional hasPlain plainSects; - - text = concatStringsSep "\n" (flatten (mapAttrsToList mkConf attrs)); - in pkgs.writeText "gitconfig" text; - - gitPatched = overrideDerivation pkgs.gitFull (git: { - makeFlags = let - oldFlags = git.makeFlags or []; - newVal = "ETC_GITCONFIG=${config.vuizvui.git.config}"; - in if isList oldFlags - then oldFlags ++ [ newVal ] - else "${oldFlags} ${newVal}"; - }); -in { - options.vuizvui.git = { - enable = mkEnableOption "Git"; - - config = mkOption { - description = "System-wide default config for Git"; - - type = let - superType = types.attrsOf types.unspecified; - in mkOptionType { - name = "attribute set of either plain values or " - + "attribute sets of values (if it is a subsection)"; - inherit (superType) check merge; - inherit (superType) getSubOptions getSubModules substSubModules; - }; - - default = {}; - example = { - color.ui = "auto"; - merge.tool = "vimdiff"; - guitool.foobar.noconsole = true; - }; - - apply = genConf; - }; - }; - - config = mkIf config.vuizvui.git.enable { - environment.systemPackages = [ - gitPatched - pkgs.gitAndTools.git-remote-hg - pkgs.gitAndTools.hub - ]; - }; -} |