-
Notifications
You must be signed in to change notification settings - Fork 10
/
lib.nix
83 lines (72 loc) · 3 KB
/
lib.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# This file is for building `nix-thunk` with arbitrary GHC, currently
# using `haskell.nix`. For *using* `nix-thunk`, you just need `default.nix`.
#
# This file is UNSTABLE, and should not be used in downstream projects
# accordingly.
let defaultInputs = import ./defaultInputs.nix; in
{
haskell-nix ? defaultInputs.haskell-nix {},
pkgs ? defaultInputs.pkgs { inherit haskell-nix; },
}:
rec {
inherit haskell-nix pkgs;
inherit (pkgs) lib;
postInstallGenerateOptparseApplicativeCompletion = exeName: ''
bashCompDir="''${!outputBin}/share/bash-completion/completions"
zshCompDir="''${!outputBin}/share/zsh/vendor-completions"
fishCompDir="''${!outputBin}/share/fish/vendor_completions.d"
mkdir -p "$bashCompDir" "$zshCompDir" "$fishCompDir"
"''${!outputBin}/bin/${exeName}" --bash-completion-script "''${!outputBin}/bin/${exeName}" >"$bashCompDir/${exeName}"
"''${!outputBin}/bin/${exeName}" --zsh-completion-script "''${!outputBin}/bin/${exeName}" >"$zshCompDir/_${exeName}"
"''${!outputBin}/bin/${exeName}" --fish-completion-script "''${!outputBin}/bin/${exeName}" >"$fishCompDir/${exeName}.fish"
# Sanity check
grep -F ${exeName} <$bashCompDir/${exeName} >/dev/null || {
echo 'Could not find ${exeName} in completion script.'
exit 1
}
'';
haskellPackageSource = pkgs.haskell-nix.haskellLib.cleanGit {
name = "nix-thunk";
src = ./.;
};
perGhc =
{ ghc ? (import ./versions.nix).ghc.preferred }:
rec {
# The Haskell.nix project that is used to build this by default
project = pkgs.haskell-nix.project {
src = haskellPackageSource;
compiler-nix-name = ghc;
modules = [
({...}: {
packages.cli-git.components.library.build-tools = [
pkgs.git
];
packages.cli-nix.components.library.build-tools = [
pkgs.nix-prefetch-git
pkgs.nix # For nix-prefetch-url
];
packages.nix-thunk.components.exes.nix-thunk = {
enableStatic = true;
postInstall = postInstallGenerateOptparseApplicativeCompletion "nix-thunk";
};
})
];
};
# The nix-thunk command itself; if you just want to use nix-thunk, this is the
# thing to install
command = project.nix-thunk.components.exes.nix-thunk;
};
inherit (import ./dep/gitignore.nix { inherit lib; }) gitignoreSource;
inherit (import ./. { inherit pkgs gitignoreSource; })
thunkSource
mapSubdirectories
;
# The version of nixpkgs that we use for fetching packing thunks (by
# themselves). If you need to ensure that nix-thunk will work without a
# network connection, make sure this is in your nix store. Not to be used for
# building packages.
packedThunkNixpkgs = builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/3aad50c30c826430b0270fcf8264c8c41b005403.tar.gz";
sha256 = "0xwqsf08sywd23x0xvw4c4ghq0l28w2ki22h0bdn766i16z9q2gr";
};
}