feat: added the ability to ignore files automatically

This commit is contained in:
D. Moonfire 2024-03-07 19:37:15 -06:00
parent 6afef1ca95
commit 6ba1a8e975
6 changed files with 100 additions and 6 deletions

8
.gitignore vendored
View file

@ -1,9 +1,9 @@
.direnv/
# nixago: ignore-linked-files
/DCO.md
/rustfmt.toml
/treefmt.toml
/.prettierrc.json
/lefthook.yml
/.conform.yaml
/.conform.yaml
# mfgames-project-setup: ignore-files
/.direnv/

4
.prettierignore Normal file
View file

@ -0,0 +1,4 @@
# mfgames-project-setup: ignore-files
/LICENSE.md
/DCO.md

34
DCO.md Normal file
View file

@ -0,0 +1,34 @@
Developer Certificate of Origin
Version 1.1
Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.
Developer's Certificate of Origin 1.1
By making a contribution to this project, I certify that:
(a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
indicated in the file; or
(b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source
license and I have the right under that license to submit that
work with modifications, whether created in whole or in part
by me, under the same open source license (unless I am
permitted to submit under a different license), as indicated
in the file; or
(c) The contribution was provided directly to me by some other
person who certified (a), (b) or (c) and I have not modified
it.
(d) I understand and agree that this project and the contribution
are public and that a record of the contribution (including all
personal information I submit with it, including my sign-off) is
maintained indefinitely and may be redistributed consistent with
this project or the open source license(s) involved.

View file

@ -1,4 +1,3 @@
# Tasks
- [ ] Need to exclude the generated files from Prettier
- [ ] Add .direnv into `.gitignore`
Nothing, obviously there is nothing wrong with this library.

View file

@ -15,6 +15,7 @@
let
# Helpers for producing system-specific outputs
supportedSystems = [ "x86_64-linux" ];
forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f {
inherit system;
pkgs = import nixpkgs { inherit system; };
@ -69,6 +70,16 @@
prettier = prettierDefaults // prettier;
rust = rustDefaults // rust;
};
ignores = import ./src/ignores/default.nix {
inherit system pkgs nixago nixago-exts;
contributorCovenant = contributorCovenantDefaults // contributorCovenant;
creativeCommonsAttributionNonCommercialShareAlike = licenseDefaults // creativeCommonsAttributionNonCommercialShareAlike;
creativeCommonsAttributionShareAlike = licenseDefaults // creativeCommonsAttributionShareAlike;
developerCertificateOfOrigin = developerCertificateOfOriginDefaults // developerCertificateOfOrigin;
mit = licenseDefaults // mit;
};
in
{
packages = [
@ -84,6 +95,7 @@
shellHook = ''
${configs.shellHook}
${ignores}
${pkgs.lefthook}/bin/lefthook install
'';
};

45
src/ignores/default.nix Normal file
View file

@ -0,0 +1,45 @@
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