summaryrefslogtreecommitdiffstats
path: root/modules/tools.nix
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2015-03-05 13:01:05 +0100
committertv <tv@krebsco.de>2015-05-19 23:10:57 +0200
commitf52e3eb5b94b8cffcc2b57f4604aac2e9402be39 (patch)
treee34e330c04beb0822d59da3f43b0a1e32c06b582 /modules/tools.nix
initial commit
Diffstat (limited to 'modules/tools.nix')
-rw-r--r--modules/tools.nix101
1 files changed, 101 insertions, 0 deletions
diff --git a/modules/tools.nix b/modules/tools.nix
new file mode 100644
index 0000000..4be84a6
--- /dev/null
+++ b/modules/tools.nix
@@ -0,0 +1,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/[^":]*\)"|\1|
+ s|^trace:\s*\(.*\)|\1|
+ ''}
+ '';
+
+ };
+
+ 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 ];
+}