Add nix derivation

This commit is contained in:
Tom McLaughlin 2021-08-01 02:54:54 -07:00
parent 711becd671
commit 02033ddc3d
3 changed files with 39 additions and 0 deletions

27
default.nix Normal file
View File

@ -0,0 +1,27 @@
{
pkgs ? import (import ./pinned-nixpkgs.nix) {}
}:
let
script = ./time-ghc-modules;
process = ./scripts/process;
index = ./dist/index.html;
in
with pkgs;
runCommand "time-ghc-modules" {
propagatedBuildInputs = [makeWrapper];
inherit script process index;
} ''
mkdir -p $out/bin
cp $script $out/bin/time-ghc-modules
wrapProgram $out/bin/time-ghc-modules --prefix PATH : ${lib.makeBinPath [ sqlite ]}
mkdir -p $out/bin/scripts
ln -s $process $out/bin/scripts/process
mkdir -p $out/bin/dist
ln -s $index $out/bin/dist/index.html
''

6
pinned-nixpkgs.nix Normal file
View File

@ -0,0 +1,6 @@
builtins.fetchGit {
url = "https://github.com/NixOS/nixpkgs.git";
rev = "973910f5c31b9ba6c171c33a8bd7199990b14c72";
ref = "release-21.05";
}

6
time-ghc-modules-nix Executable file
View File

@ -0,0 +1,6 @@
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
$(nix-build $SCRIPT_DIR)/bin/time-ghc-modules "$@"