]> git.immae.eu Git - perso/Immae/Config/Nix.git/blob - libs.nix
Fix missing paths for piedsjaloux website
[perso/Immae/Config/Nix.git] / libs.nix
1 let nixpkgs_unstable = import (builtins.fetchTarball {
2 # FIXME: upgrade to nixpkgs 19 when stable and stick to stable
3 # versions
4 name = "nixos-unstable-2018-12-08";
5 url = https://github.com/nixos/nixpkgs/archive/61c3169a0e17d789c566d5b241bfe309ce4a6275.tar.gz;
6 sha256 = "0qbycg7wkb71v20rchlkafrjfpbk2fnlvvbh3ai9pyfisci5wxvq";
7 }) {};
8 in
9 with nixpkgs_unstable;
10 {
11 inherit nixpkgs_unstable;
12 fetchedGithub = path:
13 let
14 json = lib.importJSON path;
15 in rec {
16 version = json.tag;
17 name = "${json.meta.name}-${version}";
18 src = fetchFromGitHub json.github;
19 };
20
21 fetchedGit = path:
22 let
23 json = lib.importJSON path;
24 in rec {
25 version = json.tag;
26 name = "${json.meta.name}-${version}";
27 src = fetchgit json.git;
28 };
29
30 fetchedGitPrivate = path:
31 let
32 json = lib.importJSON path;
33 in rec {
34 version = json.tag;
35 name = "${json.meta.name}-${version}";
36 src = fetchgitPrivate json.git;
37 };
38
39 wrap = { paths ? [], vars ? {}, file ? null, script ? null, name ? "wrap" }:
40 assert file != null || script != null ||
41 abort "wrap needs 'file' or 'script' argument";
42 with rec {
43 set = n: v: "--set ${pkgs.lib.escapeShellArg n} " +
44 "${pkgs.lib.escapeShellArg v}";
45 args = (map (p: "--prefix PATH : ${p}/bin") paths) ++
46 (builtins.attrValues (pkgs.lib.mapAttrs set vars));
47 };
48 runCommand name
49 {
50 f = if file == null then writeScript name script else file;
51 buildInputs = [ makeWrapper ];
52 }
53 ''
54 makeWrapper "$f" "$out" ${toString args}
55 '';
56 }