-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
78 lines (76 loc) · 2.83 KB
/
flake.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
{
description = "csvs - comma-separated value store";
inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; };
outputs = inputs@{ self, nixpkgs, ... }:
let
eachSystem = systems: f:
let
op = attrs: system:
let
ret = f system;
op = attrs: key:
let
appendSystem = key: system: ret: { ${system} = ret.${key}; };
in attrs // {
${key} = (attrs.${key} or { })
// (appendSystem key system ret);
};
in builtins.foldl' op attrs (builtins.attrNames ret);
in builtins.foldl' op { } systems;
defaultSystems = [
"aarch64-linux"
"aarch64-darwin"
"i686-linux"
"x86_64-darwin"
"x86_64-linux"
];
in eachSystem defaultSystems (system:
let
pkgs = import nixpkgs { inherit system; };
csvs-sh = pkgs.stdenv.mkDerivation {
name = "csvs-sh";
src = ./scripts;
buildPhase = ''
true
'';
postPatch = ''
substituteInPlace merge --replace "jq" "${pkgs.jq}/bin/jq"
substituteInPlace unescape --replace "jq" "${pkgs.jq}/bin/jq"
substituteInPlace break-biorg --replace "jq" "${pkgs.jq}/bin/jq"
substituteInPlace build-biorg --replace "jq" "${pkgs.jq}/bin/jq"
substituteInPlace build-biorg --replace "bash" "${pkgs.bash}/bin/bash"
substituteInPlace mdirsync --replace "bash" "${pkgs.bash}/bin/bash"
substituteInPlace mdirsync --replace "awk" "${pkgs.gawk}/bin/awk"
substituteInPlace csvs --replace "awk" "${pkgs.gawk}/bin/awk"
substituteInPlace gc --replace "jq" "${pkgs.jq}/bin/jq"
substituteInPlace gc --replace "sponge" "${pkgs.moreutils}/bin/sponge"
substituteInPlace lookup --replace "grep" "${pkgs.gnugrep}/bin/grep"
substituteInPlace build-biorg --replace "grep" "${pkgs.gnugrep}/bin/grep"
substituteInPlace merge --replace "grep" "${pkgs.gnugrep}/bin/grep"
substituteInPlace break-biorg --replace "grep" "${pkgs.gnugrep}/bin/grep"
substituteInPlace break-fs --replace "parallel" "${pkgs.parallel}/bin/parallel"
substituteInPlace break-fs --replace "jq" "${pkgs.jq}/bin/jq"
'';
installPhase = ''
mkdir -p $out/bin/
cp * $out/bin/
chmod +x $out/bin/*
'';
};
in rec {
devShell = pkgs.mkShell {
buildInputs = with pkgs; [
bash_unit
coreutils
file
gawk
jq
moreutils
parallel
ripgrep
];
};
packages = { inherit csvs-sh; };
defaultPackage = csvs-sh;
});
}