From 6ba1a8e9755ae03287457d5fe9bb3565f7421c4b Mon Sep 17 00:00:00 2001 From: "D. Moonfire" Date: Thu, 7 Mar 2024 19:37:15 -0600 Subject: [PATCH] feat: added the ability to ignore files automatically --- .gitignore | 8 ++++---- .prettierignore | 4 ++++ DCO.md | 34 +++++++++++++++++++++++++++++++ TASKS.md | 3 +-- flake.nix | 12 +++++++++++ src/ignores/default.nix | 45 +++++++++++++++++++++++++++++++++++++++++ 6 files changed, 100 insertions(+), 6 deletions(-) create mode 100644 .prettierignore create mode 100644 DCO.md create mode 100644 src/ignores/default.nix diff --git a/.gitignore b/.gitignore index 75a9f9e..7b6017d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,9 @@ -.direnv/ # nixago: ignore-linked-files -/DCO.md -/rustfmt.toml /treefmt.toml /.prettierrc.json /lefthook.yml -/.conform.yaml \ No newline at end of file +/.conform.yaml + +# mfgames-project-setup: ignore-files +/.direnv/ \ No newline at end of file diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..98d9aa3 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,4 @@ + +# mfgames-project-setup: ignore-files +/LICENSE.md +/DCO.md \ No newline at end of file diff --git a/DCO.md b/DCO.md new file mode 100644 index 0000000..49b8cb0 --- /dev/null +++ b/DCO.md @@ -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. diff --git a/TASKS.md b/TASKS.md index ef8fcdc..ce66993 100644 --- a/TASKS.md +++ b/TASKS.md @@ -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. diff --git a/flake.nix b/flake.nix index 4003f1e..1fa681d 100644 --- a/flake.nix +++ b/flake.nix @@ -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 ''; }; diff --git a/src/ignores/default.nix b/src/ignores/default.nix new file mode 100644 index 0000000..2c05d71 --- /dev/null +++ b/src/ignores/default.nix @@ -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