aboutsummaryrefslogtreecommitdiff
path: root/nixpkgs/nixos/modules/services/misc/ihaskell.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/nixos/modules/services/misc/ihaskell.nix')
-rw-r--r--nixpkgs/nixos/modules/services/misc/ihaskell.nix62
1 files changed, 62 insertions, 0 deletions
diff --git a/nixpkgs/nixos/modules/services/misc/ihaskell.nix b/nixpkgs/nixos/modules/services/misc/ihaskell.nix
new file mode 100644
index 00000000000..11597706d0d
--- /dev/null
+++ b/nixpkgs/nixos/modules/services/misc/ihaskell.nix
@@ -0,0 +1,62 @@
+{ pkgs, lib, config, ... }:
+
+with lib;
+
+let
+
+ cfg = config.services.ihaskell;
+ ihaskell = pkgs.ihaskell.override {
+ packages = self: cfg.extraPackages self;
+ };
+
+in
+
+{
+ options = {
+ services.ihaskell = {
+ enable = mkOption {
+ default = false;
+ description = "Autostart an IHaskell notebook service.";
+ };
+
+ 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.users.ihaskell = {
+ group = config.users.groups.ihaskell.name;
+ description = "IHaskell user";
+ home = "/var/lib/ihaskell";
+ createHome = true;
+ uid = config.ids.uids.ihaskell;
+ };
+
+ users.groups.ihaskell.gid = config.ids.gids.ihaskell;
+
+ systemd.services.ihaskell = {
+ description = "IHaskell notebook instance";
+ wantedBy = [ "multi-user.target" ];
+ after = [ "network.target" ];
+ serviceConfig = {
+ User = config.users.users.ihaskell.name;
+ Group = config.users.groups.ihaskell.name;
+ ExecStart = "${pkgs.runtimeShell} -c \"cd $HOME;${ihaskell}/bin/ihaskell-notebook\"";
+ };
+ };
+ };
+}