aboutsummaryrefslogtreecommitdiff
path: root/infra/libkookie/nixpkgs/pkgs/development/tools/haskell/dconf2nix
diff options
context:
space:
mode:
authorMx Kookie <kookie@spacekookie.de>2020-10-31 19:35:09 +0100
committerMx Kookie <kookie@spacekookie.de>2020-10-31 19:35:09 +0100
commitc4625b175f8200f643fd6e11010932ea44c78433 (patch)
treebce3f89888c8ac3991fa5569a878a9eab6801ccc /infra/libkookie/nixpkgs/pkgs/development/tools/haskell/dconf2nix
parent49f735974dd103039ddc4cb576bb76555164a9e7 (diff)
parentd661aa56a8843e991261510c1bb28fdc2f6975ae (diff)
Add 'infra/libkookie/' from commit 'd661aa56a8843e991261510c1bb28fdc2f6975ae'
git-subtree-dir: infra/libkookie git-subtree-mainline: 49f735974dd103039ddc4cb576bb76555164a9e7 git-subtree-split: d661aa56a8843e991261510c1bb28fdc2f6975ae
Diffstat (limited to 'infra/libkookie/nixpkgs/pkgs/development/tools/haskell/dconf2nix')
-rw-r--r--infra/libkookie/nixpkgs/pkgs/development/tools/haskell/dconf2nix/dconf2nix.nix24
-rw-r--r--infra/libkookie/nixpkgs/pkgs/development/tools/haskell/dconf2nix/default.nix32
-rwxr-xr-xinfra/libkookie/nixpkgs/pkgs/development/tools/haskell/dconf2nix/update.sh26
3 files changed, 82 insertions, 0 deletions
diff --git a/infra/libkookie/nixpkgs/pkgs/development/tools/haskell/dconf2nix/dconf2nix.nix b/infra/libkookie/nixpkgs/pkgs/development/tools/haskell/dconf2nix/dconf2nix.nix
new file mode 100644
index 000000000000..60b9ba3e0e45
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/development/tools/haskell/dconf2nix/dconf2nix.nix
@@ -0,0 +1,24 @@
+{ mkDerivation, base, containers, fetchgit, hedgehog
+, optparse-applicative, parsec, stdenv, template-haskell, text
+}:
+mkDerivation {
+ pname = "dconf2nix";
+ version = "0.0.6";
+ src = fetchgit {
+ url = "https://github.com/gvolpe/dconf2nix.git";
+ sha256 = "0ql3xrr05kg1xrfxq86mhzh5ky33sngx57sahzck3rb8fv2g6amv";
+ rev = "cf976e033c1a89f897924baa219c3b227fe68489";
+ fetchSubmodules = true;
+ };
+ isLibrary = true;
+ isExecutable = true;
+ libraryHaskellDepends = [
+ base containers optparse-applicative parsec text
+ ];
+ executableHaskellDepends = [ base ];
+ testHaskellDepends = [
+ base containers hedgehog parsec template-haskell text
+ ];
+ description = "Convert dconf files to Nix, as expected by Home Manager";
+ license = stdenv.lib.licenses.asl20;
+}
diff --git a/infra/libkookie/nixpkgs/pkgs/development/tools/haskell/dconf2nix/default.nix b/infra/libkookie/nixpkgs/pkgs/development/tools/haskell/dconf2nix/default.nix
new file mode 100644
index 000000000000..cfd391866ee3
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/development/tools/haskell/dconf2nix/default.nix
@@ -0,0 +1,32 @@
+{ haskell, haskellPackages, lib, runCommand }:
+
+let
+ dconf2nix =
+ haskell.lib.justStaticExecutables
+ (haskell.lib.overrideCabal haskellPackages.dconf2nix (oldAttrs: {
+ maintainers = (oldAttrs.maintainers or []) ++ [
+ lib.maintainers.gvolpe
+ ];
+ }));
+in
+
+dconf2nix.overrideAttrs (oldAttrs: {
+ passthru = (oldAttrs.passthru or {}) // {
+ updateScript = ./update.sh;
+
+ # These tests can be run with the following command.
+ #
+ # $ nix-build -A dconf2nix.passthru.tests
+ tests =
+ runCommand
+ "dconf2nix-tests"
+ {
+ nativeBuildInputs = [
+ dconf2nix
+ ];
+ }
+ ''
+ dconf2nix > $out
+ '';
+ };
+})
diff --git a/infra/libkookie/nixpkgs/pkgs/development/tools/haskell/dconf2nix/update.sh b/infra/libkookie/nixpkgs/pkgs/development/tools/haskell/dconf2nix/update.sh
new file mode 100755
index 000000000000..8129824e256b
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/development/tools/haskell/dconf2nix/update.sh
@@ -0,0 +1,26 @@
+#!/usr/bin/env nix-shell
+#!nix-shell -i bash -p cabal2nix curl jq
+#
+# This script will update the dconf2nix 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 )"
+
+# dconf2nix derivation created with cabal2nix.
+dconf2nix_derivation_file="${script_dir}/dconf2nix.nix"
+
+# This is the current revision of dconf2nix in Nixpkgs.
+old_version="$(sed -En 's/.*\bversion = "(.*?)".*/\1/p' "$dconf2nix_derivation_file")"
+
+# This is the latest release version of dconf2nix on GitHub.
+new_version=$(curl --silent "https://api.github.com/repos/gvolpe/dconf2nix/releases" | jq '.[0].tag_name' --raw-output)
+
+echo "Updating dconf2nix from old version $old_version to new version $new_version."
+echo "Running cabal2nix and outputting to ${dconf2nix_derivation_file}..."
+
+cabal2nix --revision "$new_version" "https://github.com/gvolpe/dconf2nix.git" > "$dconf2nix_derivation_file"
+
+echo "Finished."