about summary refs log tree commit diff stats
path: root/templates
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--templates/awk/.envrc (renamed from awk/.envrc)4
-rw-r--r--templates/awk/.gitignore5
-rw-r--r--templates/awk/.licensure.yml159
-rw-r--r--templates/awk/COPYING (renamed from awk/COPYING)0
-rw-r--r--templates/awk/LICENSE.spdx (renamed from awk/LICENSE.spdx)0
-rw-r--r--templates/awk/README.md10
-rw-r--r--templates/awk/cog.toml26
-rw-r--r--templates/awk/docs/TODO.1.md70
-rw-r--r--templates/awk/flake.lock129
-rw-r--r--templates/awk/flake.nix (renamed from awk/flake.nix)78
l---------templates/awk/scripts/renew_copyright_header.sh1
-rw-r--r--templates/awk/src/TODO.awk4
l---------templates/awk/treefmt.nix1
-rwxr-xr-xtemplates/awk/update.sh3
14 files changed, 458 insertions, 32 deletions
diff --git a/awk/.envrc b/templates/awk/.envrc
index a9c7e4e..96eca6b 100644
--- a/awk/.envrc
+++ b/templates/awk/.envrc
@@ -1,4 +1,6 @@
-use flake
+use flake || use nix
+watch_file flake.nix
+
 if on_git_branch; then
   echo && git status --short --branch &&
   echo && git fetch --verbose
diff --git a/templates/awk/.gitignore b/templates/awk/.gitignore
new file mode 100644
index 0000000..b50689b
--- /dev/null
+++ b/templates/awk/.gitignore
@@ -0,0 +1,5 @@
+# build
+/result
+
+# dev env
+.direnv
diff --git a/templates/awk/.licensure.yml b/templates/awk/.licensure.yml
new file mode 100644
index 0000000..e62adb0
--- /dev/null
+++ b/templates/awk/.licensure.yml
@@ -0,0 +1,159 @@
+---
+# Regexes which if matched by a file path will always be excluded from
+# getting a license header
+excludes:
+  - .*lock
+  - \.git/.*
+  - LICENSE.spdx
+  - COPYING
+  - COPYING.LESSER
+  - .*\.(rst|txt|pdf)
+# Definition of the licenses used on this project and to what files
+# they should apply.
+#
+# No default license configuration is provided. This section must be
+# configured by the user.
+licenses:
+  # Either a regex or the string "any" to determine to what files this
+  # license should apply. It is common for projects to have files
+  # under multiple licenses or with multiple copyright holders. This
+  # provides the ability to automatically license files correctly
+  # based on their file paths.
+  #
+  # If "any" is provided all files will match this license.
+  - files: any
+    #
+    #   The license identifier, a list of common identifiers can be
+    #   found at: https://spdx.org/licenses/ but existence of the ident
+    #   in this list it is not enforced unless auto_template is set to
+    #   true.
+    ident: GPL-3.0-or-later
+    #
+    #   A list of authors who hold copyright over these files
+    authors:
+      # Provide either your full name or company name for copyright purposes
+      - name: TODO
+        # Optionally provide email for copyright purposes
+        email: "TODO"
+
+    #   The template that will be rendered to generate the header before
+    #   comment characters are applied. Available variables are:
+    #    - [year]: substituted with the current year.
+    #    - [name of author]: Substituted with name of the author and email
+    #      if provided. If email is provided the output appears as Full
+    #      Name <email@example.com>. If multiple authors are provided the
+    #      list is concatenated together with commas.
+    template: |
+        Copyright (C) 2023 - [year]:
+        [name of author]
+        SPDX-License-Identifier: GPL-3.0-or-later
+
+        This file is part of the TODO.
+
+        Trixy is free software: you can redistribute it and/or modify
+        it under the terms of the Lesser GNU General Public License as
+        published by the Free Software Foundation, either version 3 of
+        the License, or (at your option) any later version.
+
+        This program is distributed in the hope that it will be useful,
+        but WITHOUT ANY WARRANTY; without even the implied warranty of
+        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+        GNU General Public License for more details.
+
+        You should have received a copy of the GNU General Public License
+        and the Lesser GNU General Public License along with this program.
+        If not, see <https://www.gnu.org/licenses/>.
+
+
+    #   If auto_template is true then template is ignored and the SPDX
+    #   API will be queried with the ident value to automatically
+    #   determine the license header template. auto_template works best
+    #   with licenses that have a standardLicenseHeader field defined in
+    #   their license info JSON, if it is not then we will use the full
+    #   licenseText to generate the header which works fine for short
+    #   licenses like MIT but can be quite lengthy for other licenses
+    #   like BSD-4-Clause. The above default template is valid for most
+    #   licenses and is recommended for MIT, and BSD licenses. Common
+    #   licenses that work well with the auto_template feature are GPL
+    #   variants, and the Apache 2.0 license.
+    #
+    #   Important Note: this means the ident must be a valid SPDX identifier
+    # auto_template: true
+
+    #   If true try to detect the text wrapping of the template, and unwrap it
+    unwrap_text: false
+
+# Define type of comment characters to apply based on file extensions.
+comments:
+  # The extensions (or singular extension) field defines which file
+  # extensions to apply the commenter to.
+  - extensions:
+      - js
+      - go
+    # The commenter field defines the kind of commenter to
+    # generate. There are two types of commenters: line and block.
+    #
+    # This demonstrates a line commenter configuration. A line
+    # commenter type will apply the comment_char to the beginning of
+    # each line in the license header. It will then apply a number of
+    # empty newlines to the end of the header equal to trailing_lines.
+    #
+    # If trailing_lines is omitted it is assumed to be 0.
+    commenter:
+      type: line
+      comment_char: "//"
+      trailing_lines: 1
+
+  - extensions:
+      - rs
+      - tri
+      - css
+      - cpp
+      - c
+      - h
+    # This demonstrates a block commenter configuration. A block
+    # commenter type will add start_block_char as the first character
+    # in the license header and add end_block_char as the last character
+    # in the license header. If per_line_char is provided each line of
+    # the header between the block start and end characters will be
+    # line commented with the per_line_char
+    #
+    # trailing_lines works the same for both block and line commenter
+    # types
+    commenter:
+      type: block
+      start_block_char: "/*\n"
+      end_block_char: "*/\n"
+      per_line_char: "*"
+      trailing_lines: 1
+
+  - extension:
+      - html
+      - md
+    commenter:
+      type: block
+      start_block_char: "<!--\n"
+      end_block_char: "-->\n"
+      trailing_lines: 1
+
+  - extensions:
+      - el
+      - lisp
+    commenter:
+      type: line
+      comment_char: ";;;"
+      trailing_lines: 1
+
+  # The extension string "any" is special and so will match any file
+  # extensions. Commenter configurations are always checked in the
+  # order they are defined, so if any is used it should be the last
+  # commenter configuration or else it will override all others.
+  #
+  # In this configuration if we can't match the file extension we fall
+  # back to the popular '#' line comment used in most scripting
+  # languages.
+  - extension: any
+    commenter:
+      type: line
+      comment_char: '#'
+      trailing_lines: 1
diff --git a/awk/COPYING b/templates/awk/COPYING
index f288702..f288702 100644
--- a/awk/COPYING
+++ b/templates/awk/COPYING
diff --git a/awk/LICENSE.spdx b/templates/awk/LICENSE.spdx
index ecb7d83..ecb7d83 100644
--- a/awk/LICENSE.spdx
+++ b/templates/awk/LICENSE.spdx
diff --git a/templates/awk/README.md b/templates/awk/README.md
new file mode 100644
index 0000000..5912c16
--- /dev/null
+++ b/templates/awk/README.md
@@ -0,0 +1,10 @@
+# TODO
+
+Some text about the project.
+
+## Licence
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
diff --git a/templates/awk/cog.toml b/templates/awk/cog.toml
new file mode 100644
index 0000000..677e20a
--- /dev/null
+++ b/templates/awk/cog.toml
@@ -0,0 +1,26 @@
+tag_prefix = "v"
+branch_whitelist = ["main", "prime"]
+ignore_merge_commits = false
+
+[commit_types]
+
+pre_bump_hooks = [
+  "nix flake check",                                                    # verify the project builds
+  "./scripts/renew_copyright_header.sh",                                # update the license header in each file
+  "nix fmt",                                                            # format
+  "flake_version_update --version v{{version}} --input-file flake.nix",
+]
+post_bump_hooks = [
+  "git push",
+  "git push origin v{{version}}", # push the new tag to origin
+]
+
+[bump_profiles]
+
+[changelog]
+path = "NEWS.md"
+template = "remote"
+remote = "TODO"
+repository = "TODO"
+owner = "TODO"
+authors = [{ signature = "Benedikt Peetz", username = "bpeetz" }]
diff --git a/templates/awk/docs/TODO.1.md b/templates/awk/docs/TODO.1.md
new file mode 100644
index 0000000..e14fec5
--- /dev/null
+++ b/templates/awk/docs/TODO.1.md
@@ -0,0 +1,70 @@
+% FUPDATE(1) fupdate 1.0.0
+% Benedikt Peetz
+% May 2023
+
+# NAME
+
+fupdate - updates your flake, while checking for common mistakes
+
+# SYNOPSIS
+
+**fupdate** list of \[*flake*|*\<some word>*|*--help*|*-h*\]
+
+# DESCRIPTION
+
+Argument can be stacked, this makes it possible to specify multiple targets to be updated in succession. See the Examples section for further details.
+
+No argument or *flake*
+: **fupdate**, when executed without arguments or with *flake*, will update your *flake.lock*, check for duplicate flake inputs, i.e., an input has an input declared, which you have also declared as input, and will run a script called *update.sh*, if you allow it.
+The allowance for the script is asked, when you run **fupdate** and the found script is not yet allowed. Furthermore, the allowance is based on the concrete sha256 hash of the script, so any changes will require another allowance.
+
+**\<some word>** as argument
+: If the executable **update-\<some word>** is reachable thought the PATH variable, than this is run. Otherwise, the program will exit.
+
+# OPTIONS
+
+**--help**, **-h**
+: Displays a help message and exit.
+
+**--version**, **-v**
+: Displays the software version and exit.
+
+# EXAMPLES
+
+**fupdate** or **fupdate flake**
+: Updates your *flake.lock*. See the Description section for further details.
+
+**fupdate sys**
+: Run the executable **update-sys**, if it exists. See the Description section for further details.
+
+**fupdate flake sys docs**
+: First updates your flake, then, if the command succeeded, runs **update-sys**, afterweich **update-docs** is run.
+
+# FILES
+
+*update.sh*
+: This is supposed to be a shell script located in your flake base directory, i.e., the directory which contains both a *flake.nix* and a *flake.lock* file.
+
+*~/.local/share/flake-update/*
+: **fupdate** will store the hashes to the allowed *update.sh* files here.
+
+# BUGS
+
+Report bugs to <https://codeberg.org/soispha/flake_update/issues>.
+
+# COPYRIGHT
+
+Copyright (C) 2023  Benedikt Peetz
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <https://www.gnu.org/licenses/>.
diff --git a/templates/awk/flake.lock b/templates/awk/flake.lock
new file mode 100644
index 0000000..544cbdf
--- /dev/null
+++ b/templates/awk/flake.lock
@@ -0,0 +1,129 @@
+{
+  "nodes": {
+    "flake-compat": {
+      "flake": false,
+      "locked": {
+        "lastModified": 1696426674,
+        "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
+        "owner": "edolstra",
+        "repo": "flake-compat",
+        "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
+        "type": "github"
+      },
+      "original": {
+        "owner": "edolstra",
+        "repo": "flake-compat",
+        "type": "github"
+      }
+    },
+    "flake-utils": {
+      "inputs": {
+        "systems": [
+          "systems"
+        ]
+      },
+      "locked": {
+        "lastModified": 1710146030,
+        "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
+        "owner": "numtide",
+        "repo": "flake-utils",
+        "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
+        "type": "github"
+      },
+      "original": {
+        "owner": "numtide",
+        "repo": "flake-utils",
+        "type": "github"
+      }
+    },
+    "flake_version_update": {
+      "inputs": {
+        "flake-utils": [
+          "flake-utils"
+        ],
+        "nixpkgs": [
+          "nixpkgs"
+        ],
+        "systems": [
+          "systems"
+        ]
+      },
+      "locked": {
+        "lastModified": 1685288691,
+        "narHash": "sha256-oP6h34oJ8rm6KlUpyZrX+ww3hnoWny2ecrEXxkU7F3c=",
+        "ref": "refs/heads/prime",
+        "rev": "e9a97e01eca780bd16e1dbdbd8856b59558f4959",
+        "revCount": 5,
+        "type": "git",
+        "url": "https://codeberg.org/soispha/flake_version_update.git"
+      },
+      "original": {
+        "type": "git",
+        "url": "https://codeberg.org/soispha/flake_version_update.git"
+      }
+    },
+    "nixpkgs": {
+      "locked": {
+        "lastModified": 1711715736,
+        "narHash": "sha256-9slQ609YqT9bT/MNX9+5k5jltL9zgpn36DpFB7TkttM=",
+        "owner": "NixOS",
+        "repo": "nixpkgs",
+        "rev": "807c549feabce7eddbf259dbdcec9e0600a0660d",
+        "type": "github"
+      },
+      "original": {
+        "owner": "NixOS",
+        "ref": "nixpkgs-unstable",
+        "repo": "nixpkgs",
+        "type": "github"
+      }
+    },
+    "root": {
+      "inputs": {
+        "flake-compat": "flake-compat",
+        "flake-utils": "flake-utils",
+        "flake_version_update": "flake_version_update",
+        "nixpkgs": "nixpkgs",
+        "systems": "systems",
+        "treefmt-nix": "treefmt-nix"
+      }
+    },
+    "systems": {
+      "locked": {
+        "lastModified": 1680978846,
+        "narHash": "sha256-Gtqg8b/v49BFDpDetjclCYXm8mAnTrUzR0JnE2nv5aw=",
+        "owner": "nix-systems",
+        "repo": "x86_64-linux",
+        "rev": "2ecfcac5e15790ba6ce360ceccddb15ad16d08a8",
+        "type": "github"
+      },
+      "original": {
+        "owner": "nix-systems",
+        "repo": "x86_64-linux",
+        "type": "github"
+      }
+    },
+    "treefmt-nix": {
+      "inputs": {
+        "nixpkgs": [
+          "nixpkgs"
+        ]
+      },
+      "locked": {
+        "lastModified": 1711803027,
+        "narHash": "sha256-Qic3OvsVLpetchzaIe2hJqgliWXACq2Oee6mBXa/IZQ=",
+        "owner": "numtide",
+        "repo": "treefmt-nix",
+        "rev": "1810d51a015c1730f2fe05a255258649799df416",
+        "type": "github"
+      },
+      "original": {
+        "owner": "numtide",
+        "repo": "treefmt-nix",
+        "type": "github"
+      }
+    }
+  },
+  "root": "root",
+  "version": 7
+}
diff --git a/awk/flake.nix b/templates/awk/flake.nix
index 1d9b0b2..aeacf3b 100644
--- a/awk/flake.nix
+++ b/templates/awk/flake.nix
@@ -1,17 +1,16 @@
 {
-  description = ""; # TODO
+  description = "TODO";
 
   inputs = {
     nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
-    systems = {
-      url = "github:nix-systems/x86_64-linux"; # only evaluate for this system
-    };
-    flake-utils = {
-      url = "github:numtide/flake-utils";
+
+    treefmt-nix = {
+      url = "github:numtide/treefmt-nix";
       inputs = {
-        systems.follows = "systems";
+        nixpkgs.follows = "nixpkgs";
       };
     };
+
     flake_version_update = {
       url = "git+https://codeberg.org/soispha/flake_version_update.git";
       inputs = {
@@ -20,58 +19,75 @@
         flake-utils.follows = "flake-utils";
       };
     };
+
+    # inputs for following
+    systems = {
+      url = "github:nix-systems/x86_64-linux"; # only evaluate for this system
+    };
+    flake-compat = {
+      url = "github:edolstra/flake-compat";
+      flake = false;
+    };
+    flake-utils = {
+      url = "github:numtide/flake-utils";
+      inputs = {
+        systems.follows = "systems";
+      };
+    };
   };
 
   outputs = {
     self,
     nixpkgs,
     flake-utils,
+    treefmt-nix,
     flake_version_update,
     ...
   }:
     flake-utils.lib.eachDefaultSystem (system: let
       pkgs = nixpkgs.legacyPackages.${system};
+      treefmtEval = import ./treefmt.nix {inherit treefmt-nix pkgs;};
 
       # This version is set automatically on `cog bump --auto`;
       version = "v1.0.0"; # GUIDING VERSION STRING
+
+      man_number = "1"; # TODO change if necessary
+      pname = "TODO";
     in {
       packages.default = pkgs.stdenv.mkDerivation {
-        pname = ""; # TODO
-        inherit version;
+        inherit version pname;
         src = ./.;
 
-        nativeBuildInputs = builtins.attrValues {
-          inherit
-            (pkgs)
-            #pandoc
-            
-            ;
-        };
+        nativeBuildInputs = with pkgs; [pandoc fd];
 
-        dependencies = builtins.attrValues {
-          inherit (pkgs) gawk;
-        };
+        dependencies = with pkgs; [gawk];
 
         buildPhase = ''
-          #mkdir --parents $out/docs;
-          #pandoc $src/docs/<name>.1.md -s -t man  > $out/docs/<name>.1
+          mkdir --parents $out/docs;
+          pandoc ./docs/${pname}.${man_number}.md -s -t man  > $out/docs/${pname}.${man_number}
         '';
 
         installPhase = ''
-          install -D $out/docs/<name>.<man_number>  $out/share/man/man<man_number>/<name>;
-          install -D $scr/scr/<name>.awk $out/bin/<name>;
+          install -D $out/docs/${pname}.${man_number}  $out/share/man/man${man_number}/${pname};
+
+          install -D ./src/${pname}.awk $out/bin/${pname}.awk;
+
+          # Generate a wrapper script.
+          cat << EOF > $out/bin/${pname}
+          #! /usr/bin/env sh
+          $out/bin/${pname}.awk -- "\$@"
+          EOF
+
+          # Set correct permissions
+          chmod +x $out/bin/${pname}
         '';
       };
-      app.default = {
-        type = "app";
-        program = "${self.packages.${system}.default}/bin/<name>";
-      };
+
+      checks.formatting = treefmtEval.config.build.check self;
+      formatter = treefmtEval.config.build.wrapper;
+
       devShells.default = pkgs.mkShell {
         packages = with pkgs; [
-          nil
-          alejandra
-          statix
-          ltex-ls
           cocogitto
           flake_version_update.packages."${system}".default
 
diff --git a/templates/awk/scripts/renew_copyright_header.sh b/templates/awk/scripts/renew_copyright_header.sh
new file mode 120000
index 0000000..f286da9
--- /dev/null
+++ b/templates/awk/scripts/renew_copyright_header.sh
@@ -0,0 +1 @@
+../../../common/renew_copyright_header.sh
\ No newline at end of file
diff --git a/templates/awk/src/TODO.awk b/templates/awk/src/TODO.awk
new file mode 100644
index 0000000..78b2356
--- /dev/null
+++ b/templates/awk/src/TODO.awk
@@ -0,0 +1,4 @@
+#!/usr/bin/env -S gawk -f
+BEGIN {
+  printf ("Hello World!\n");
+}
diff --git a/templates/awk/treefmt.nix b/templates/awk/treefmt.nix
new file mode 120000
index 0000000..6a4fe7d
--- /dev/null
+++ b/templates/awk/treefmt.nix
@@ -0,0 +1 @@
+../../treefmt.nix
\ No newline at end of file
diff --git a/templates/awk/update.sh b/templates/awk/update.sh
new file mode 100755
index 0000000..49216b8
--- /dev/null
+++ b/templates/awk/update.sh
@@ -0,0 +1,3 @@
+#!/usr/bin/env sh
+
+nix flake update