From dfc8e5ab05e5bb555000f9af0d58309671dccf4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edward=20Tj=C3=B6rnhammar?= Date: Wed, 15 Apr 2015 22:59:07 +0200 Subject: [PATCH] ihaskell: cleanup wrapper and service --- nixos/modules/services/misc/ihaskell.nix | 5 +-- .../tools/haskell/ihaskell/wrapper.nix | 42 +++++++------------ 2 files changed, 17 insertions(+), 30 deletions(-) diff --git a/nixos/modules/services/misc/ihaskell.nix b/nixos/modules/services/misc/ihaskell.nix index b857045bb7d0..7f7f981de498 100644 --- a/nixos/modules/services/misc/ihaskell.nix +++ b/nixos/modules/services/misc/ihaskell.nix @@ -68,9 +68,8 @@ in after = [ "network.target" ]; serviceConfig = { User = config.users.extraUsers.ihaskell.name; - Group = config.users.extraUsers.ihaskell.name; - Restart = "always"; - ExecStart = "${ihaskell}/bin/IHaskell notebook"; + Group = config.users.extraGroups.ihaskell.name; + ExecStart = "${pkgs.stdenv.shell} -c \"cd $HOME;${ihaskell}/bin/ihaskell-notebook\""; }; }; }; diff --git a/pkgs/development/tools/haskell/ihaskell/wrapper.nix b/pkgs/development/tools/haskell/ihaskell/wrapper.nix index 4ce78c31fe2f..035ad738a824 100644 --- a/pkgs/development/tools/haskell/ihaskell/wrapper.nix +++ b/pkgs/development/tools/haskell/ihaskell/wrapper.nix @@ -1,4 +1,4 @@ -{ stdenv, buildEnv, ghcWithPackages, makeWrapper, ihaskell, ipython, packages }: +{ stdenv, writeScriptBin, buildEnv, ghcWithPackages, ihaskell, ipython, packages }: let ihaskellEnv = ghcWithPackages (self: [ self.ihaskell @@ -6,30 +6,18 @@ let self.ihaskell-diagrams self.ihaskell-display ] ++ packages self); + ihaskellSh = writeScriptBin "ihaskell-notebook" '' + #!/bin/sh + export GHC_PACKAGE_PATH="$(echo ${ihaskellEnv}/lib/*/package.conf.d| tr ' ' ':'):$GHC_PACKAGE_PATH" + export PATH="${ihaskell}/bin:${ihaskellEnv}/bin:${ipython}/bin" + ${ihaskell}/bin/ihaskell install -l $(${ihaskellEnv}/bin/ghc --print-libdir) && ${ipython}/bin/ipython notebook --kernel=haskell + ''; profile = "${ihaskell.pname}-${ihaskell.version}/profile/profile.tar"; - drv = buildEnv { - name = "ihaskell-with-packages"; - paths = [ ihaskellEnv ipython ]; - postBuild = '' - tar xf ${ihaskell.src} ${profile} - mkdir -p $out/share/`dirname ${profile}` - mkdir profile - cd profile - tar xf ../${profile} - for cfg in ipython_*config.py;do - sed -i -e "1iexe = '${ihaskell}/bin/IHaskell'" $cfg - done - tar cf $out/share/${profile} . - wrapProgram "$out/bin/IHaskell" \ - --prefix PATH : "${ihaskellEnv}/bin:${ipython}/bin" \ - --set PROFILE_DIR "\$HOME/.ipython/profile_haskell" \ - --set PROFILE_TAR "$out/share/${profile}" \ - --set PROFILE_INIT "\$([ ! -d \$PROFILE_DIR ] \ - && mkdir -p \$PROFILE_DIR \ - && tar xf \$PROFILE_TAR -C \$PROFILE_DIR \ - ; [ -d \$PROFILE_DIR ] && for cfg in \$PROFILE_DIR/ipython_*config.py;do \ - sed -i -e '/.*exe.*IHaskell.*/d' \$cfg; sed -i -e \"1iexe = '${ihaskell}/bin/IHaskell'\" \$cfg;done )" \ - --set GHC_PACKAGE_PATH "\$(echo $out/lib/*/package.conf.d| tr ' ' ':'):" \ - ''; - }; -in stdenv.lib.overrideDerivation drv (x : { buildInputs = x.buildInputs ++ [ makeWrapper ]; }) \ No newline at end of file +in +buildEnv { + name = "ihaskell-with-packages"; + paths = [ ihaskellEnv ipython ]; + postBuild = '' + ln -s ${ihaskellSh}/bin/ihaskell-notebook $out/bin/. + ''; +}