46 lines
1.4 KiB
Nix
46 lines
1.4 KiB
Nix
inputs @ { ... }:
|
|
let
|
|
lib = inputs.pkgs.lib;
|
|
ignore-sentinel = "mfgames-project-setup: ignore-files";
|
|
ignore-list = [
|
|
"_mfgames_project_setup_ignore \".gitignore\" \".direnv/\""
|
|
]
|
|
++ lib.optionals inputs.contributorCovenant.enable [
|
|
"_mfgames_project_setup_ignore \".prettierignore\" \"DCO.md\""
|
|
]
|
|
++ lib.optionals inputs.creativeCommonsAttributionShareAlike.enable [
|
|
"_mfgames_project_setup_ignore \".prettierignore\" \"LICENSE.md\""
|
|
]
|
|
++ lib.optionals inputs.creativeCommonsAttributionNonCommercialShareAlike.enable [
|
|
"_mfgames_project_setup_ignore \".prettierignore\" \"LICENSE.md\""
|
|
]
|
|
++ lib.optionals inputs.developerCertificateOfOrigin.enable [
|
|
"_mfgames_project_setup_ignore \".prettierignore\" \"LICENSE.md\""
|
|
]
|
|
++ lib.optionals inputs.mit.enable [
|
|
"_mfgames_project_setup_ignore \".prettierignore\" \"LICENSE.md\""
|
|
];
|
|
in
|
|
''
|
|
_mfgames_project_setup_ignore() (
|
|
if ! test -f $1
|
|
then
|
|
touch $1
|
|
fi
|
|
if ! grep -qF "${ignore-sentinel}" $1
|
|
then
|
|
echo -e "\n# ${ignore-sentinel}" >> $1
|
|
fi
|
|
if ! grep -qF "/$2" $1
|
|
then
|
|
newgitignore="$(awk "1;/${ignore-sentinel}/{ print \"/$2\"; }" $1)"
|
|
echo -e -n "$newgitignore" > $1
|
|
git add $1
|
|
echo "mfgames-project-setup: '/$2' added to $1"
|
|
fi
|
|
)
|
|
${lib.concatStringsSep "\n" ignore-list}
|
|
''
|
|
|
|
## Add this output to the ignore file
|