about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Simons <simons@cryp.to>2015-04-14 14:21:44 +0200
committerPeter Simons <simons@cryp.to>2015-04-14 14:21:44 +0200
commit65822005f01f1b1975255b83a9e7599c07e97e62 (patch)
treeb71306040c08014f6739fe7c84912022e56bb117
parent34c4b25e016945734a830a06e747a09c213a5d50 (diff)
parent7d0ddbd154ba9ee1e76ef3bee634b67d9eb552af (diff)
downloadnixlib-65822005f01f1b1975255b83a9e7599c07e97e62.tar
nixlib-65822005f01f1b1975255b83a9e7599c07e97e62.tar.gz
nixlib-65822005f01f1b1975255b83a9e7599c07e97e62.tar.bz2
nixlib-65822005f01f1b1975255b83a9e7599c07e97e62.tar.lz
nixlib-65822005f01f1b1975255b83a9e7599c07e97e62.tar.xz
nixlib-65822005f01f1b1975255b83a9e7599c07e97e62.tar.zst
nixlib-65822005f01f1b1975255b83a9e7599c07e97e62.zip
Merge pull request #7314 from edwtjo/ihaskell-fixups
IHaskell fixes
-rw-r--r--nixos/modules/misc/ids.nix2
-rw-r--r--nixos/modules/module-list.nix1
-rw-r--r--nixos/modules/services/misc/ihaskell.nix77
-rw-r--r--pkgs/development/tools/haskell/ihaskell/ng-wrapper.nix35
-rw-r--r--pkgs/development/tools/haskell/ihaskell/wrapper.nix43
-rw-r--r--pkgs/top-level/all-packages.nix7
6 files changed, 102 insertions, 63 deletions
diff --git a/nixos/modules/misc/ids.nix b/nixos/modules/misc/ids.nix
index c2523a3cc329..426518585520 100644
--- a/nixos/modules/misc/ids.nix
+++ b/nixos/modules/misc/ids.nix
@@ -214,6 +214,7 @@
       ripple-data-api = 186;
       mediatomb = 187;
       rdnssd = 188;
+      ihaskell = 189;
 
       # When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399!
 
@@ -405,6 +406,7 @@
       #ripple-data-api = 186; #unused
       mediatomb = 187;
       #rdnssd = 188; # unused
+      ihaskell = 189;
 
       # When adding a gid, make sure it doesn't match an existing
       # uid. Users and groups with the same name should have equal
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix
index 17717c5988dc..8a4adfc24f52 100644
--- a/nixos/modules/module-list.nix
+++ b/nixos/modules/module-list.nix
@@ -193,6 +193,7 @@
   ./services/misc/gitlab.nix
   ./services/misc/gitolite.nix
   ./services/misc/gpsd.nix
+  ./services/misc/ihaskell.nix
   ./services/misc/mediatomb.nix
   ./services/misc/mesos-master.nix
   ./services/misc/mesos-slave.nix
diff --git a/nixos/modules/services/misc/ihaskell.nix b/nixos/modules/services/misc/ihaskell.nix
new file mode 100644
index 000000000000..b857045bb7d0
--- /dev/null
+++ b/nixos/modules/services/misc/ihaskell.nix
@@ -0,0 +1,77 @@
+{ pkgs, lib, config, ... }:
+
+with lib;
+
+let
+
+  cfg = config.services.ihaskell;
+  ihaskell = pkgs.ihaskell.override {
+    inherit (cfg.haskellPackages) ihaskell ghcWithPackages;
+    packages = self: cfg.extraPackages self;
+  };
+
+in
+
+{
+  options = {
+    services.ihaskell = {
+      enable = mkOption {
+        default = false;
+        example = true;
+        description = "Autostart an IHaskell notebook service.";
+      };
+
+      haskellPackages = mkOption {
+        default = pkgs.haskellngPackages;
+        defaultText = "pkgs.haskellngPackages";
+        example = literalExample "pkgs.haskell-ng.packages.ghc784";
+        description = ''
+          haskellPackages used to build IHaskell and other packages.
+          This can be used to change the GHC version used to build
+          IHaskell and the packages listed in
+          <varname>extraPackages</varname>.
+        '';
+      };
+
+      extraPackages = mkOption {
+        default = self: [];
+        example = literalExample ''
+          haskellPackages: [
+            haskellPackages.wreq
+            haskellPackages.lens
+          ]
+        '';
+        description = ''
+          Extra packages available to ghc when running ihaskell. The
+          value must be a function which receives the attrset defined
+          in <varname>haskellPackages</varname> as the sole argument.
+        '';
+      };
+    };
+  };
+
+  config = mkIf cfg.enable {
+
+    users.extraUsers.ihaskell = {
+      group = config.users.extraGroups.ihaskell.name;
+      description = "IHaskell user";
+      home = "/var/lib/ihaskell";
+      createHome = true;
+      uid = config.ids.uids.ihaskell;
+    };
+
+    users.extraGroups.ihaskell.gid = config.ids.gids.ihaskell;
+
+    systemd.services.ihaskell = {
+      description = "IHaskell notebook instance";
+      wantedBy = [ "multi-user.target" ];
+      after = [ "network.target" ];
+      serviceConfig = {
+        User = config.users.extraUsers.ihaskell.name;
+        Group = config.users.extraUsers.ihaskell.name;
+        Restart = "always";
+        ExecStart = "${ihaskell}/bin/IHaskell notebook";
+      };
+    };
+  };
+}
diff --git a/pkgs/development/tools/haskell/ihaskell/ng-wrapper.nix b/pkgs/development/tools/haskell/ihaskell/ng-wrapper.nix
deleted file mode 100644
index 4ce78c31fe2f..000000000000
--- a/pkgs/development/tools/haskell/ihaskell/ng-wrapper.nix
+++ /dev/null
@@ -1,35 +0,0 @@
-{ stdenv, buildEnv, ghcWithPackages, makeWrapper, ihaskell, ipython, packages }:
-let
-  ihaskellEnv = ghcWithPackages (self: [
-    self.ihaskell
-    self.ihaskell-blaze
-    self.ihaskell-diagrams
-    self.ihaskell-display
-  ] ++ packages self);
-  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
diff --git a/pkgs/development/tools/haskell/ihaskell/wrapper.nix b/pkgs/development/tools/haskell/ihaskell/wrapper.nix
index b20f8fa4f507..4ce78c31fe2f 100644
--- a/pkgs/development/tools/haskell/ihaskell/wrapper.nix
+++ b/pkgs/development/tools/haskell/ihaskell/wrapper.nix
@@ -1,15 +1,17 @@
-{ stdenv, makeWrapper, ihaskell, ipython, ghc }:
-
-stdenv.mkDerivation rec {
-
-  inherit (ihaskell) name pname src version meta;
-
-  buildInputs = [ makeWrapper ];
-
-  preferLocalBuild = true;
-
-  buildCommand = let profile = "${pname}-${version}/profile/profile.tar"; in ''
-    tar xf $src ${profile}
+{ stdenv, buildEnv, ghcWithPackages, makeWrapper, ihaskell, ipython, packages }:
+let
+  ihaskellEnv = ghcWithPackages (self: [
+    self.ihaskell
+    self.ihaskell-blaze
+    self.ihaskell-diagrams
+    self.ihaskell-display
+  ] ++ packages self);
+  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
@@ -18,19 +20,16 @@ stdenv.mkDerivation rec {
       sed -i -e "1iexe = '${ihaskell}/bin/IHaskell'" $cfg
     done
     tar cf $out/share/${profile} .
-    makeWrapper "${ihaskell}/bin/IHaskell" "$out/bin/ihaskell" \
-      --prefix PATH : "${ghc}/bin:${ihaskell}/bin:${ipython}/bin" \
-      --prefix LD_LIBRARY_PATH : "${ihaskell}/lib/ghc-${ghc.version}/${name}/" \
-      --add-flags "--ipython=${ipython}/bin/ipython" \
+    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 ) \
-        " \
-      --prefix GHC_PACKAGE_PATH : "\$(${ghc.GHCGetPackages} ${ghc.version}|sed -e 's, -package-db ,:,g'|cut -b 2-):${ihaskell}/lib/ghc-${ghc.version}/package.conf.d/${pname}-${version}.installedconf" \
-      --set GHC_PACKAGE_PATH "\$GHC_PACKAGE_PATH:" # always end with : to include base packages
-  '';
-}
+            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
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index cff7acba30d9..f139b9d7b76b 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -1680,13 +1680,8 @@ let
 
   ihaskell = callPackage ../development/tools/haskell/ihaskell/wrapper.nix {
     inherit (pythonPackages) ipython;
-    inherit (haskellPackages) ihaskell ghc;
-  };
-
-  ihaskell-with-packages = callPackage ../development/tools/haskell/ihaskell/ng-wrapper.nix {
-    inherit (pythonPackages) ipython;
     inherit (haskellngPackages) ihaskell ghcWithPackages;
-    packages = self: config.ihaskell.packages or [];
+    packages = config.ihaskell.packages or (self: []);
   };
 
   imapproxy = callPackage ../tools/networking/imapproxy { };