diff options
| author | quentin@aristote.fr <quentin@aristote.fr> | 2023-08-27 13:58:26 +0200 |
|---|---|---|
| committer | quentin@aristote.fr <quentin@aristote.fr> | 2023-08-27 16:30:24 +0200 |
| commit | de6dfea61b996c5e52a47842b3b54e1b9a390a91 (patch) | |
| tree | 271809125085017526a8b27b7e0a6e574da2dfc0 | |
| parent | 2cb43216d3c2cbc6f40e0d6646abb9f31a1c40f7 (diff) | |
pkgs: gitignore: reorganize
| -rw-r--r-- | modules/home-manager/personal/programs/git.nix | 38 | ||||
| -rw-r--r-- | pkgs/default.nix | 27 | ||||
| -rw-r--r-- | pkgs/static/gitignore/default.nix | 38 |
3 files changed, 65 insertions, 38 deletions
diff --git a/modules/home-manager/personal/programs/git.nix b/modules/home-manager/personal/programs/git.nix index a34b1b3..a7ae892 100644 --- a/modules/home-manager/personal/programs/git.nix +++ b/modules/home-manager/personal/programs/git.nix @@ -1,14 +1,20 @@ -{ config, lib, pkgs, ... }@extraArgs: - -let +{ + config, + lib, + pkgs, + ... +} @ extraArgs: let primaryEmail = let - primaryEmailList = builtins.filter (account: account.primary) + primaryEmailList = + builtins.filter (account: account.primary) (lib.attrValues config.accounts.email.accounts); - in if primaryEmailList == [ ] then { - userName = lib.mkDefault "Quentin Aristote"; - address = lib.mkDefault "quentin@aristote.fr"; - } else - builtins.head primaryEmailList; + in + if primaryEmailList == [] + then { + userName = lib.mkDefault "Quentin Aristote"; + address = lib.mkDefault "quentin@aristote.fr"; + } + else builtins.head primaryEmailList; in { programs.git = { userName = primaryEmail.userName; @@ -17,8 +23,12 @@ in { inherit (primaryEmail.gpg) key signByDefault; }; - ignores = builtins.map builtins.readFile - (with pkgs.personal.static.gitignore; [ direnv emacs linux ]) ++ [ + ignores = + [ + (builtins.readFile + (pkgs.personal.gitignore.override {templates = ["direnv" "Emacs" "Linux"];})) + ] + ++ [ # Personal rules '' # Nix @@ -31,11 +41,13 @@ in { extraConfig = { safe.directory = lib.mkIf (extraArgs ? osConfig) ( - let + let flake = extraArgs.osConfig.system.autoUpgrade.flake; flakeIsValid = flake != null && lib.hasPrefix "git+file://" flake; flakePath = lib.removePrefix "git+file://" flake; - in lib.optional flakeIsValid flakePath); + in + lib.optional flakeIsValid flakePath + ); }; }; } diff --git a/pkgs/default.nix b/pkgs/default.nix index 176d627..c7a2702 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -1,6 +1,4 @@ -super: - -let +super: let self = { barista = super.callPackage ./barista { fontawesomeMetadata = self.static.fontMetadata.fontawesome; @@ -8,28 +6,29 @@ let self.static.fontMetadata.materialDesignIcons; }; - lib = import ./lib { inherit (super) lib; }; + lib = import ./lib {inherit (super) lib;}; - lockscreen = super.callPackage ./lockscreen { }; + lockscreen = super.callPackage ./lockscreen {}; firefoxAddons = super.callPackage ./firefoxAddons { inherit (super.nur.repos.rycee.firefox-addons) buildFirefoxXpiAddon; }; static = { - css = { lineAwesome = super.callPackage ./static/css/lineAwesome { }; }; + css = {lineAwesome = super.callPackage ./static/css/lineAwesome {};}; fontMetadata = { - fontawesome = super.callPackage ./static/fontMetadata/fontawesome { }; + fontawesome = super.callPackage ./static/fontMetadata/fontawesome {}; materialDesignIcons = - super.callPackage ./static/fontMetadata/materialDesignIcons { }; + super.callPackage ./static/fontMetadata/materialDesignIcons {}; }; - gitignore = super.callPackage ./static/gitignore { }; - icons = super.callPackage ./static/icons { }; + icons = super.callPackage ./static/icons {}; + gitignore = super.callPackage ./static/gitignore {}; userjs = { - arkenfox = super.callPackage ./static/userjs/arkenfox { }; - thunderbird = super.callPackage ./static/userjs/thunderbird { }; + arkenfox = super.callPackage ./static/userjs/arkenfox {}; + thunderbird = super.callPackage ./static/userjs/thunderbird {}; }; - wallpapers = super.callPackage ./static/wallpapers { }; + wallpapers = super.callPackage ./static/wallpapers {}; }; }; -in self +in + self diff --git a/pkgs/static/gitignore/default.nix b/pkgs/static/gitignore/default.nix index ac825a5..67dd28a 100644 --- a/pkgs/static/gitignore/default.nix +++ b/pkgs/static/gitignore/default.nix @@ -1,12 +1,28 @@ -{ fetchurl, lib }: +{ + templates ? [], + toUncomment ? [], + stdenvNoCC, + fetchFromGitHub, + lib, +}: +stdenvNoCC.mkDerivation { + name = lib.concatStringsSep "+" templates + ".gitignore"; + version = "2023-06-30"; -let - fetchGitignore = module: sha256: - let - url = "https://www.toptal.com/developers/gitignore/api/" + module; - name = module + ".gitignore"; - in fetchurl { inherit url sha256 name; }; - sources = lib.importJSON ./sources.json; -in { - fetcher = fetchGitignore; -} // builtins.mapAttrs fetchGitignore sources + src = fetchFromGitHub { + owner = "toptal"; + repo = "gitignore"; + rev = "0a7fb01801c62ca53ab2dcd73ab96185e159e864"; + hash = "sha256-tZ+hlpt7T1by3f9BxzakjpQr+Y4top570J58q8VP9YE="; + }; + + buildPhase = '' + cd templates + for file in ${lib.concatStringsSep " " (builtins.map (name: lib.escapeShellArg "${name}.gitignore") templates)} + do + echo "### $(basename "$file" .gitignore)" >> $out + cat "$file" >> $out + done + substituteInPlace $out ${lib.concatStringsSep " " (builtins.map (line: "--replace ${lib.escapeShellArg "# ${line}"} ${lib.escapeShellArg line}") toUncomment)} + ''; +} |
