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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
|
{ stdenv, lib, pkgs }:
let
inherit (pkgs) callPackage;
# Takes a derivation and a list of binary names
# and returns an attribute set of `name -> path`.
# The list can also contain renames in the form of
# { use, as }, which goes `as -> usePath`.
getBins = drv: xs:
let f = x:
# TODO: typecheck
let x' = if builtins.isString x then { use = x; as = x; } else x;
in {
name = x'.as;
value = "${lib.getBin drv}/bin/${x'.use}";
};
in builtins.listToAttrs (builtins.map f xs);
# Create a store path where the executable `exe`
# is linked to $out/bin/${name}.
# This is useful for e.g. including it as a “package”
# in `buildInputs` of a shell.nix.
#
# For example, if I have the exeutable /nix/store/…-hello,
# I can make it into /nix/store/…-binify-hello/bin/hello
# with `binify { exe = …; name = "hello" }`.
binify = { exe, name }:
pkgs.runCommandLocal "binify-${name}" {} ''
mkdir -p $out/bin
ln -sT ${lib.escapeShellArg exe} $out/bin/${lib.escapeShellArg name}
'';
exactSource = import ./exact-source.nix;
# various nix utils and fun experiments
nixperiments =
let
src = pkgs.fetchFromGitHub {
owner = "Profpatsch";
repo = "nixperiments";
rev = "e04abced1a4fef7ad63f67ec621f6484226ed104";
sha256 = "1if9szjj1g1l5n31pmbiyp5f3llwl6xlqxklc6g2xf4rq59d2d6w";
};
in import src { nixpkgs = pkgs; };
testing = import ./testing {
inherit lib;
inherit (runExeclineFns) runExecline;
inherit (pkgs) runCommandLocal;
bin = getBins pkgs.s6PortableUtils [ "s6-touch" "s6-echo" ];
};
# TODO: upstream
writeHaskellInterpret = nameOrPath: { withPackages ? lib.const [] }: content:
let ghc = pkgs.haskellPackages.ghcWithPackages withPackages; in
pkgs.writers.makeScriptWriter {
interpreter = "${ghc}/bin/runhaskell";
check = pkgs.writers.writeDash "ghc-typecheck" ''
ln -s "$1" ./Main.hs
${ghc}/bin/ghc -fno-code -Wall ./Main.hs
'';
} nameOrPath content;
runExeclineFns =
# todo: factor out calling tests
let
it = import ./execline/run-execline.nix {
bin = getBins pkgs.execline [ "execlineb" "redirfd" "importas" "exec" ];
inherit stdenv lib;
};
itLocal = name: args: execline:
it name (args // {
derivationArgs = args.derivationArgs or {} // {
preferLocalBuild = true;
allowSubstitutes = false;
};
}) execline;
tests = import ./execline/run-execline-tests.nix {
# can’t use runExeclineLocal in the tests,
# because it is tested by the tests (well, it does
# work, but then you have to run the tests every time)
runExecline = it;
inherit (testing) drvSeqL;
inherit (pkgs) coreutils;
inherit stdenv;
bin = (getBins pkgs.execline [
"execlineb"
{ use = "if"; as = "execlineIf"; }
"redirfd" "importas"
])
// (getBins pkgs.s6PortableUtils
[ "s6-cat" "s6-grep" "s6-touch" "s6-test" "s6-chmod" ]);
};
in {
runExecline = it;
runExeclineLocal = name: args: execline:
testing.drvSeqL tests (itLocal name args execline);
};
writeExeclineFns = callPackage ./execline/write-execline.nix {};
in rec {
inherit (nixperiments)
# canonical pattern matching primitive
match
# generate an option parser for scripts
script
# derivation testing
drvSeq drvSeqL withTests
# using the nix evaluator as a json transformation runtime
json2json json2string;
inherit (nixperiments.filterSourceGitignore)
# filterSource by parsing a .gitignore file
filterSourceGitignoreWith
readGitignoreFile
;
inherit (import ./deploy.nix { inherit pkgs getBins; })
deploy
;
backlight = callPackage ./backlight { inherit (pkgs.xorg) xbacklight; };
display-infos = callPackage ./display-infos { inherit sfttime; };
git-commit-index = callPackage ./git-commit-index { inherit script; };
nix-http-serve = callPackage ./nix-http-serve {};
nman = callPackage ./nman {};
sfttime = callPackage ./sfttime {};
show-qr-code = callPackage ./show-qr-code {};
warpspeed = callPackage ./warpspeed {
inherit (pkgs.haskellPackages) ghcWithPackages;
};
youtube2audiopodcast = callPackage ./youtube2audiopodcast {
inherit writeExecline writeHaskellInterpret getBins runInEmptyEnv sandbox;
};
inherit (callPackage ./utils-hs {})
nix-gen until watch-server
haskellPackages;
query-audio-streams = callPackage ./query-album-streams {
inherit writeExecline writeHaskellInterpret getBins;
};
# patched version of droopy, with javascript user-enhancement
droopy = pkgs.droopy.overrideDerivation (old: {
src = pkgs.fetchFromGitHub {
owner = "Profpatsch";
repo = "Droopy";
rev = "55c60c612b913f9fbce9fceebbcb3a332152f1a4";
sha256 = "0jcazj9gkdf4k7vsi33dpw9myyy02gjihwsy36dfqq4bas312cq1";
};
installPhase = old.installPhase or "" + ''
mkdir -p $out/share/droopy
cp -r $src/static $out/share/droopy
'';
makeWrapperArgs = old.makeWrapperArgs or [] ++ [
"--set DROOPY_STATIC \"$out/share/droopy/static\""
];
});
inherit (import ./write-rust.nix { inherit pkgs runExeclineLocal getBins drvSeqL; })
writeRustSimple
writeRustSimpleLib
testRustSimple
;
inherit (runExeclineFns)
runExecline runExeclineLocal;
inherit (writeExeclineFns)
writeExecline writeExeclineBin;
inherit (import ./execline/runblock.nix { inherit pkgs; })
runblock;
inherit (import ./execline/nixecline.nix { inherit writeExecline; })
backtick;
inherit (import ./execline/e.nix { inherit pkgs writeExecline getBins; })
e;
toNetstring = s:
"${toString (builtins.stringLength s)}:${s},";
inherit getBins binify;
inherit (import ./sandbox.nix {inherit pkgs writeExecline; })
sandbox runInEmptyEnv;
symlink = pkgs.callPackage ./execline/symlink.nix {
inherit runExecline toNetstring;
};
importer = pkgs.callPackage ./execline/importer.nix {
inherit symlink;
};
inherit (import ./profpatsch.de { inherit pkgs lib toNetstring writeExecline runExecline getBins writeRustSimple netencode-rs el-semicolon el-exec el-substitute netencode record-get; })
websiteStatic
importas-if
;
inherit (import ./nix-tools.nix { inherit pkgs getBins writeExecline runblock backtick; })
nix-run
nix-eval
;
easy-dhall-nix = (import (pkgs.fetchFromGitHub {
owner = "justinwoo";
repo = "easy-dhall-nix";
rev = "288ee825c326f352a5db194a024bd3e1f2f735b2";
sha256 = "12v4ql1nm1famz8r80k1xkkdgj7285vy2vn16iili0qwvz3i98ah";
}) { inherit pkgs; });
dhall = easy-dhall-nix.dhall-simple;
dhall-nix = easy-dhall-nix.dhall-nix-simple;
dhall-json = easy-dhall-nix.dhall-json-simple;
# dhall-flycheck = (import /home/philip/kot/dhall/flycheck/overlay.nix pkgs pkgs).dhall-flycheck;
dhall-flycheck =
(import "${pkgs.fetchFromGitHub {
owner = "Profpatsch";
repo = "dhall-flycheck";
rev = "2ace6b38cec356d8821b3390b670d301d54623b";
sha256 = "0d6qjr245jmx1lvqdplvrshlkpfaqa46aizyhyb6hg37v8jq8rv7";
}}/overlay.nix" pkgs pkgs).dhall-flycheck;
buildDhallPackage = pkgs.callPackage ./dhall/build-dhall-package-improved.nix { inherit dhall; };
inherit (import ./importDhall.nix { inherit pkgs dhall-nix dhall-json exactSource; })
importDhall
importDhall2
readDhallFileAsJson
;
rust-deps = (import ./rust-deps.nix { inherit (pkgs) buildRustCrate; });
inherit (import ./xdg-open { inherit pkgs getBins importDhall2 writeExecline dhall buildDhallPackage runExeclineLocal netencode-rs writeRustSimple record-get el-exec; })
xdg-open
Prelude
read-headers-and-follow-redirect
mini-url
assert-printf
as-stdin
printenv
;
inherit (import ./netencode { inherit pkgs writeRustSimpleLib writeRustSimple el-semicolon el-exec; })
netencode-rs
netencode-rs-tests
record-get
;
inherit (import ./execline/default.nix { inherit pkgs writeRustSimpleLib rust-deps; })
el-semicolon
el-semicolon-tests
el-exec
el-substitute
;
netencode = import ./netencode/netencode.nix;
inherit (import ./lru.nix { inherit pkgs writeRustSimple; })
lru-dir
;
backup = import ./backup { inherit pkgs writeExecline getBins backtick; };
}
|