about summary refs log tree commit diff stats
path: root/templates/awk/flake.nix
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--templates/awk/flake.nix (renamed from awk/flake.nix)78
1 files changed, 47 insertions, 31 deletions
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