about summary refs log tree commit diff
path: root/pkgs/by-name/ni
diff options
context:
space:
mode:
authorSilvan Mosberger <contact@infinisil.com>2024-01-23 22:45:23 +0100
committerGitHub <noreply@github.com>2024-01-23 22:45:23 +0100
commit14a0c72bf97f80159f681efdf8c5f4c26043ee72 (patch)
tree481a697c139b69588a834622c9af4791b1715f00 /pkgs/by-name/ni
parent64cab3aa8d98a09aaf360b9277b2f7837c064293 (diff)
parent22cd1fb65ffedf53cbcd16b4e43ccf5198ce11f4 (diff)
downloadnixlib-14a0c72bf97f80159f681efdf8c5f4c26043ee72.tar
nixlib-14a0c72bf97f80159f681efdf8c5f4c26043ee72.tar.gz
nixlib-14a0c72bf97f80159f681efdf8c5f4c26043ee72.tar.bz2
nixlib-14a0c72bf97f80159f681efdf8c5f4c26043ee72.tar.lz
nixlib-14a0c72bf97f80159f681efdf8c5f4c26043ee72.tar.xz
nixlib-14a0c72bf97f80159f681efdf8c5f4c26043ee72.tar.zst
nixlib-14a0c72bf97f80159f681efdf8c5f4c26043ee72.zip
Merge pull request #276503 from 0x4A6F/master-nixfmt-rfc-style
nixfmt-rfc-style: init at unstable-2024-01-15
Diffstat (limited to 'pkgs/by-name/ni')
-rw-r--r--pkgs/by-name/ni/nixfmt-rfc-style/date.txt1
-rw-r--r--pkgs/by-name/ni/nixfmt-rfc-style/generated-package.nix27
-rw-r--r--pkgs/by-name/ni/nixfmt-rfc-style/package.nix32
-rwxr-xr-xpkgs/by-name/ni/nixfmt-rfc-style/update.sh33
4 files changed, 93 insertions, 0 deletions
diff --git a/pkgs/by-name/ni/nixfmt-rfc-style/date.txt b/pkgs/by-name/ni/nixfmt-rfc-style/date.txt
new file mode 100644
index 000000000000..c024acd63a04
--- /dev/null
+++ b/pkgs/by-name/ni/nixfmt-rfc-style/date.txt
@@ -0,0 +1 @@
+2024-01-15
diff --git a/pkgs/by-name/ni/nixfmt-rfc-style/generated-package.nix b/pkgs/by-name/ni/nixfmt-rfc-style/generated-package.nix
new file mode 100644
index 000000000000..1604555b3b72
--- /dev/null
+++ b/pkgs/by-name/ni/nixfmt-rfc-style/generated-package.nix
@@ -0,0 +1,27 @@
+# This file has been autogenerate with cabal2nix.
+# Update via ./update.sh
+{ mkDerivation, base, cmdargs, directory, fetchzip, filepath, lib
+, megaparsec, mtl, parser-combinators, safe-exceptions, scientific
+, text, transformers, unix
+}:
+mkDerivation {
+  pname = "nixfmt";
+  version = "0.5.0";
+  src = fetchzip {
+    url = "https://github.com/piegamesde/nixfmt/archive/1eff7a84ac82fbebb5f586244f1c80e1fcc4f494.tar.gz";
+    sha256 = "1pg876sr58h7v087kbjsnfr4pzvqpwzibl06w2468qs1sywmd283";
+  };
+  isLibrary = true;
+  isExecutable = true;
+  libraryHaskellDepends = [
+    base megaparsec mtl parser-combinators scientific text transformers
+  ];
+  executableHaskellDepends = [
+    base cmdargs directory filepath safe-exceptions text unix
+  ];
+  jailbreak = true;
+  homepage = "https://github.com/serokell/nixfmt";
+  description = "An opinionated formatter for Nix";
+  license = lib.licenses.mpl20;
+  mainProgram = "nixfmt";
+}
diff --git a/pkgs/by-name/ni/nixfmt-rfc-style/package.nix b/pkgs/by-name/ni/nixfmt-rfc-style/package.nix
new file mode 100644
index 000000000000..a11e2d29ff69
--- /dev/null
+++ b/pkgs/by-name/ni/nixfmt-rfc-style/package.nix
@@ -0,0 +1,32 @@
+{
+  haskell,
+  haskellPackages,
+  lib,
+  runCommand,
+  nixfmt-rfc-style,
+}:
+let
+  inherit (haskell.lib.compose) overrideCabal justStaticExecutables;
+
+  overrides = {
+    version = "unstable-${lib.fileContents ./date.txt}";
+
+    passthru.updateScript = ./update.sh;
+
+    maintainers = lib.teams.formatter.members;
+
+    # These tests can be run with the following command.
+    #
+    # $ nix-build -A nixfmt-rfc-style.tests
+    passthru.tests =
+      runCommand "nixfmt-rfc-style-tests" { nativeBuildInputs = [ nixfmt-rfc-style ]; }
+        ''
+          nixfmt --version > $out
+        '';
+  };
+  raw-pkg = haskellPackages.callPackage ./generated-package.nix { };
+in
+lib.pipe raw-pkg [
+  (overrideCabal overrides)
+  justStaticExecutables
+]
diff --git a/pkgs/by-name/ni/nixfmt-rfc-style/update.sh b/pkgs/by-name/ni/nixfmt-rfc-style/update.sh
new file mode 100755
index 000000000000..c70a6e88e788
--- /dev/null
+++ b/pkgs/by-name/ni/nixfmt-rfc-style/update.sh
@@ -0,0 +1,33 @@
+#!/usr/bin/env nix-shell
+#!nix-shell -i bash -p cabal2nix curl jq
+#
+# This script will update the nixfmt-rfc-style derivation to the latest version using
+# cabal2nix.
+
+set -eo pipefail
+
+# This is the directory of this update.sh script.
+script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
+
+derivation_file="${script_dir}/generated-package.nix"
+date_file="${script_dir}/date.txt"
+
+# This is the latest version of nixfmt-rfc-style branch on GitHub.
+new_version=$(curl --silent https://api.github.com/repos/piegamesde/nixfmt/git/refs/heads/rfc101-style | jq '.object.sha' --raw-output)
+new_date=$(curl --silent https://api.github.com/repos/piegamesde/nixfmt/git/commits/"$new_version" | jq '.committer.date' --raw-output)
+
+echo "Updating nixfmt-rfc-style to version $new_date."
+echo "Running cabal2nix and outputting to ${derivation_file}..."
+
+cat > "$derivation_file" << EOF
+# This file has been autogenerate with cabal2nix.
+# Update via ./update.sh
+EOF
+
+cabal2nix --jailbreak \
+  "https://github.com/piegamesde/nixfmt/archive/${new_version}.tar.gz" \
+  >> "$derivation_file"
+
+date --date="$new_date" -I > "$date_file"
+
+echo "Finished."