stockholm: export HOSTNAME and STOCKHOLM_VERSION

This commit is contained in:
tv 2017-12-05 23:25:09 +01:00
parent 3fb25717c5
commit 289dd785e5
2 changed files with 14 additions and 13 deletions

View File

@ -207,6 +207,10 @@
''); '');
init.env = pkgs.writeText "init.env" /* sh */ '' init.env = pkgs.writeText "init.env" /* sh */ ''
export HOSTNAME="$(${pkgs.nettools}/bin/hostname)"
export STOCKHOLM_VERSION="''${STOCKHOLM_VERSION-$(${shell.get-version})}"
export quiet export quiet
export system export system
export target export target
@ -274,6 +278,16 @@
fi fi
''; '';
shell.get-version = pkgs.writeDash "stockholm.get-version" ''
set -efu
version=git.$(${pkgs.git}/bin/git describe --always --dirty)
case $version in (*-dirty)
version=$version@$HOSTNAME
esac
date=$(${pkgs.coreutils}/bin/date +%y.%m)
echo "$date.$version"
'';
in in
pkgs.writeOut "stockholm" (lib.mapAttrs' (name: link: pkgs.writeOut "stockholm" (lib.mapAttrs' (name: link:

View File

@ -2,16 +2,6 @@ let
lib = import ./lib; lib = import ./lib;
pkgs = import <nixpkgs> { overlays = [(import ./krebs/5pkgs)]; }; pkgs = import <nixpkgs> { overlays = [(import ./krebs/5pkgs)]; };
get-version = pkgs.writeDash "get-version" ''
set -efu
version=git.$(${pkgs.git}/bin/git describe --always --dirty)
case $version in (*-dirty)
version=$version@$HOSTNAME
esac
date=$(${pkgs.coreutils}/bin/date +%y.%m)
echo "$date.$version"
'';
in pkgs.stdenv.mkDerivation { in pkgs.stdenv.mkDerivation {
name = "stockholm"; name = "stockholm";
shellHook = /* sh */ '' shellHook = /* sh */ ''
@ -39,9 +29,6 @@ in pkgs.stdenv.mkDerivation {
: :
} }
export HOSTNAME="$(${pkgs.nettools}/bin/hostname)"
export STOCKHOLM_VERSION="''${STOCKHOLM_VERSION-$(${get-version})}"
PS1='\[\e[38;5;162m\]\w\[\e[0m\] ' PS1='\[\e[38;5;162m\]\w\[\e[0m\] '
''; '';
} }