about summary refs log tree commit diff stats
path: root/templates/shell/flake.nix
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--templates/shell/flake.nix104
1 files changed, 67 insertions, 37 deletions
diff --git a/templates/shell/flake.nix b/templates/shell/flake.nix
index b699f25..4025fbe 100644
--- a/templates/shell/flake.nix
+++ b/templates/shell/flake.nix
@@ -1,15 +1,22 @@
 {
-  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
+
+    treefmt-nix = {
+      url = "github:numtide/treefmt-nix";
+      inputs = {
+        nixpkgs.follows = "nixpkgs";
+      };
     };
-    flake-utils = {
-      url = "github:numtide/flake-utils";
+
+    flake_version_update = {
+      url = "git+https://codeberg.org/soispha/flake_version_update.git";
       inputs = {
         systems.follows = "systems";
+        nixpkgs.follows = "nixpkgs";
+        flake-utils.follows = "flake-utils";
       };
     };
     shell_library = {
@@ -18,14 +25,22 @@
         flake-utils.follows = "flake-utils";
         nixpkgs.follows = "nixpkgs";
         systems.follows = "systems";
+        flake_version_update.follows = "flake_version_update";
       };
     };
-    flake_version_update = {
-      url = "git+https://codeberg.org/soispha/flake_version_update.git";
+
+    # 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";
-        nixpkgs.follows = "nixpkgs";
-        flake-utils = "flake-utils";
       };
     };
   };
@@ -34,55 +49,70 @@
     self,
     nixpkgs,
     flake-utils,
-    shell_library,
+    treefmt-nix,
     flake_version_update,
+    shell_library,
     ...
   }:
     flake-utils.lib.eachDefaultSystem (system: let
-      pkgs = nixpkgs.legacyPackages.${system};
+      pkgs = nixpkgs.legacyPackages."${system}";
 
-      built_script = shell_library.lib.${system}.writeShellScriptWithLibrary {
-        name = ""; # TODO
-        path = ./src/your_path; # TODO
-        dependencies = builtins.attrValues {inherit (pkgs) dash;};
-      };
+      treefmtEval = import ./treefmt.nix {inherit treefmt-nix pkgs;};
 
       # This version is set automatically on `cog bump --auto`;
-      version = "v1.0.0"; # GUIDING VERSION STRING
-    in {
-      packages.default = pkgs.stdenv.mkDerivation {
-        pname = ""; # TODO
+      version = "v0.1.0"; # GUIDING VERSION STRING
+      pname = "TODO";
+
+      build = shell_library.lib.${system}.writeShellScript {
+        inherit version;
+        name = pname;
+
+        src = ./src/main.sh;
+        dependencies = with pkgs; [dash];
+
+        replacementStrings = null;
+        generateCompletions = false;
+        keepPath = false;
+        wrap = true;
+      };
+
+      manual = pkgs.stdenv.mkDerivation {
+        name = "${pname}-manual";
         inherit version;
-        src = ./.;
 
-        nativeBuildInputs = builtins.attrValues {
-          inherit
-            (pkgs)
-            #pandoc
-            
-            ;
-        };
+        src = ./docs;
+        nativeBuildInputs = with pkgs; [pandoc];
 
         buildPhase = ''
-          #mkdir --parents $out/docs;
-          #pandoc $src/docs/<name>.1.md -s -t man  > $out/docs/<name>.1
+          mkdir --parents $out/docs;
+
+          pandoc "./${pname}.1.md" -s -t man > $out/docs/${pname}.1
         '';
 
         installPhase = ''
-          install -D $out/docs/<name>.<man_number>  $out/share/man/man<man_number>/<name>;
-          install -D ${built_script}/bin/<name> $out/bin/<name>;
+          install -D $out/docs/${pname}.1  $out/share/man/man1/${pname};
         '';
       };
-      app.default = {
-        type = "app";
-        program = "${self.packages.${system}.default}/bin/<name>";
+    in {
+      packages.default = pkgs.symlinkJoin {
+        name = pname;
+
+        paths = [manual build];
+      };
+
+      checks = {
+        inherit build;
+        formatting = treefmtEval.config.build.check self;
       };
+      formatter = treefmtEval.config.build.wrapper;
+
       devShells.default = pkgs.mkShell {
         packages = with pkgs; [
+          cocogitto
           flake_version_update.packages."${system}".default
+
+          licensure
         ];
       };
     });
 }
-# vim: ts=2
-