at 23.11-pre 1.7 kB view raw
1{ pkgs, lib, config, ... }: 2 3with lib; 4 5let 6 7 cfg = config.services.ihaskell; 8 ihaskell = pkgs.ihaskell.override { 9 packages = cfg.extraPackages; 10 }; 11 12in 13 14{ 15 options = { 16 services.ihaskell = { 17 enable = mkOption { 18 type = types.bool; 19 default = false; 20 description = lib.mdDoc "Autostart an IHaskell notebook service."; 21 }; 22 23 extraPackages = mkOption { 24 type = types.functionTo (types.listOf types.package); 25 default = haskellPackages: []; 26 defaultText = literalExpression "haskellPackages: []"; 27 example = literalExpression '' 28 haskellPackages: [ 29 haskellPackages.wreq 30 haskellPackages.lens 31 ] 32 ''; 33 description = lib.mdDoc '' 34 Extra packages available to ghc when running ihaskell. The 35 value must be a function which receives the attrset defined 36 in {var}`haskellPackages` as the sole argument. 37 ''; 38 }; 39 }; 40 }; 41 42 config = mkIf cfg.enable { 43 44 users.users.ihaskell = { 45 group = config.users.groups.ihaskell.name; 46 description = "IHaskell user"; 47 home = "/var/lib/ihaskell"; 48 createHome = true; 49 uid = config.ids.uids.ihaskell; 50 }; 51 52 users.groups.ihaskell.gid = config.ids.gids.ihaskell; 53 54 systemd.services.ihaskell = { 55 description = "IHaskell notebook instance"; 56 wantedBy = [ "multi-user.target" ]; 57 after = [ "network.target" ]; 58 serviceConfig = { 59 User = config.users.users.ihaskell.name; 60 Group = config.users.groups.ihaskell.name; 61 ExecStart = "${pkgs.runtimeShell} -c \"cd $HOME;${ihaskell}/bin/ihaskell-notebook\""; 62 }; 63 }; 64 }; 65}