blob: cf3fda93a6c6fe3ea3ec5ce37baa9e33b4b36f4d (
plain)
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
|
{ config, pkgs, ... }:
let
inherit (pkgs) lib stdenv;
inherit (lib.strings) concatStringsSep stringAsChars;
inherit (lib.attrsets) attrValues mapAttrs;
inherit (lib) makeSearchPath;
inherit (import ../../lib { inherit pkgs; }) shell-escape;
# TODO make these scripts available in an maintenance shell
scripts = {
# just so we don't reboot accidentally
reboot =
''
echo no reboot >&2
exit 23
'';
rebuild =
''
nixpkgs=''${nixpkgs-/home/tv/src/nixpkgs}
nixos-rebuild \
--show-trace \
-I nixpkgs="$nixpkgs" \
switch \
2>&1 \
| sed ${shell-escape ''
s|"\(/home/tv/src/config/[^":]*\)"|[31;1m\1[m|
s|^trace:\s*\(.*\)|[35;1m\1[m|
''}
'';
};
wrap = script:
''
#! /bin/sh
set -euf
${script}
'';
#lib=$lib
#export PATH=$bin:${makeSearchPath "bin" buildInputs}
buildScript = name: script:
builtins.trace "building ${name}"
''
echo ${shell-escape script} > $bin/${shell-escape name}
chmod +x $bin/${shell-escape name}
'';
tools = pkgs.stdenv.mkDerivation rec {
name = "tools";
src = /var/empty;
buildInputs = [];
buildPhase =
''
mkdir $out
bin=$out/bin
mkdir $bin
${concatStringsSep "\n" (attrValues (mapAttrs buildScript scripts))}
'';
#''
#mkdir $out
#lib=$out/lib
#cp -r lib $lib
#bin=$out/bin
#mkdir $bin
#${concatStringsSep "\n" (attrValues (mapAttrs (name: script:
# ''
# {
# echo '#! /bin/sh'
# echo 'set -euf'
# echo "lib=$lib"
# echo "export PATH=$bin:${makeSearchPath "bin" buildInputs}"
# echo ${shell-escape script}
# } > $bin/${name}
# chmod +x $bin/${name}
# '') scripts))}
#'';
installPhase = ":";
};
in
{
environment.systemPackages = [ tools ];
}
|