diff options
Diffstat (limited to 'Biz')
-rw-r--r-- | Biz/Bild/Deps/Haskell.nix | 126 | ||||
-rw-r--r-- | Biz/Bild/Rules.nix | 31 | ||||
-rw-r--r-- | Biz/Cloud/Web.nix | 7 | ||||
-rw-r--r-- | Biz/Dev.nix | 1 | ||||
-rw-r--r-- | Biz/Dev/Configuration.nix | 11 | ||||
-rw-r--r-- | Biz/Dev/Hoogle.nix | 79 | ||||
-rw-r--r-- | Biz/Devalloc.hs | 2 |
7 files changed, 175 insertions, 82 deletions
diff --git a/Biz/Bild/Deps/Haskell.nix b/Biz/Bild/Deps/Haskell.nix index 5e06a5d..001cdb2 100644 --- a/Biz/Bild/Deps/Haskell.nix +++ b/Biz/Bild/Deps/Haskell.nix @@ -1,64 +1,66 @@ +hpkgs: +with hpkgs; [ - "MonadRandom" - "QuickCheck" - "acid-state" - "aeson" - "async" - "bytestring" - "clay" - "cmark" - "config-ini" - "containers" - "directory" - "docopt" - "ekg" - "envy" - "fast-logger" - "filepath" - "ghcjs-base" - "github" - "haskeline" - "http-types" - "ixset" - "katip" - "lucid" - "miso" - "monad-logger" - "monad-metrics" - "mtl" - "network-uri" - "optparse-simple" - "parsec" - "process" - "protolude" - "quickcheck-instances" - "random" - "regex-applicative" - "req" - "safecopy" - "scotty" - "servant" - "servant-auth" - "servant-auth-server" - "servant-lucid" - "servant-server" - "split" - "stm" - "string-quote" - "stripe-haskell" - "tasty" - "text" - "time" - "transformers" - "unagi-chan" - "unix" - "unordered-containers" - "uuid" - "vector" - "wai" - "wai-app-static" - "wai-extra" - "wai-middleware-metrics" - "warp" - "x509" + MonadRandom + QuickCheck + acid-state + aeson + async + bytestring + clay + cmark + config-ini + containers + directory + docopt + ekg + envy + fast-logger + filepath + ghcjs-base + github + haskeline + http-types + ixset + katip + lucid + miso + monad-logger + monad-metrics + mtl + network-uri + optparse-simple + parsec + process + protolude + quickcheck-instances + random + regex-applicative + req + safecopy + scotty + servant + servant-auth + servant-auth-server + servant-lucid + servant-server + split + stm + string-quote + stripe-haskell + tasty + text + time + transformers + unagi-chan + unix + unordered-containers + uuid + vector + wai + wai-app-static + wai-extra + wai-middleware-metrics + warp + x509 ] diff --git a/Biz/Bild/Rules.nix b/Biz/Bild/Rules.nix index f5f016f..9a7ad77 100644 --- a/Biz/Bild/Rules.nix +++ b/Biz/Bild/Rules.nix @@ -13,14 +13,14 @@ let lines = s: lib.strings.splitString "\n" s; removeNull = ls: builtins.filter (x: x != null) ls; - depsToPackageSet = packageSet: deps: + selectAttrs = deps: packageSet: lib.attrsets.attrVals deps packageSet; # returns true if a is a subset of b, where a and b are attrsets subset = a: b: builtins.all (x: builtins.elem x b) a; - haskellDeps = import ./Deps/Haskell.nix; + haskellDeps = hpkgs: import ./Deps/Haskell.nix hpkgs; # gather data needed for compiling by analyzing the main module analyze = main: rec { @@ -45,25 +45,20 @@ let (lines content))); }; - mkGhc = compiler: (deps: compiler (hp: - if (subset deps haskellDeps) - then depsToPackageSet hp deps - else throw '' - missing from nix/haskell-deps.nix: - ${toString (lib.lists.subtractLists haskellDeps deps)} - '')); - - ghc_ = mkGhc pkgs.haskell.packages.${ghcCompiler}.ghcWithHoogle; - ghcjs_ = mkGhc pkgs.haskell.packages.${ghcjsCompiler}.ghcWithPackages; -in { + mkGhcPackageSet = pkgs.haskell.packages.${ghcCompiler}.ghcWithHoogle; + mkGhcjsPackageSet = pkgs.haskell.packages.${ghcjsCompiler}.ghcWithPackages; + +in rec { + ghcPackageSetFull = mkGhcPackageSet haskellDeps; + ghc = main: let data = analyze main; - ghc = ghc_ data.deps; + ghc = mkGhcPackageSet (hp: selectAttrs data.deps hp); in stdenv.mkDerivation { name = data.module; src = ../../.; - nativeBuildInputs = [ ghc ] ++ depsToPackageSet nixpkgs data.sysdeps; + nativeBuildInputs = [ ghc ] ++ selectAttrs data.sysdeps nixpkgs; strictDeps = true; buildPhase = '' mkdir -p $out/bin @@ -82,7 +77,7 @@ in { ghcjs = main: let data = analyze main; - ghcjs = ghcjs_ data.deps; + ghcjs = mkGhcjsPackageSet (hp: selectAttrs data.dep hp); in stdenv.mkDerivation { name = data.module; src = ../../.; @@ -108,9 +103,9 @@ in { name = "bizdev"; buildInputs = [ # haskell deps - (ghc_ haskellDeps) + (mkGhcPackageSet haskellDeps) # ghcjs doesn't need everything, and many things fail to build - (ghcjs_ [ + (mkGhcjsPackageSet [ "aeson" "clay" "containers" diff --git a/Biz/Cloud/Web.nix b/Biz/Cloud/Web.nix index 56eeb2d..81f3cf0 100644 --- a/Biz/Cloud/Web.nix +++ b/Biz/Cloud/Web.nix @@ -44,6 +44,12 @@ in useACMEHost = rootDomain; }; + "hoogle.${rootDomain}" = { + locations."/".proxyPass = "http://${bensIp}:8008"; + forceSSL = true; + useACMEHost = rootDomain; + }; + "tv.${rootDomain}" = { locations."/".proxyPass = "http://${bensIp}:8096"; # emby runs on port 8096 forceSSL = true; @@ -81,5 +87,6 @@ in "devalloc.io" "matrix.${rootDomain}" "chat.${rootDomain}" + "hoogle.${rootDomain}" ];# } diff --git a/Biz/Dev.nix b/Biz/Dev.nix index 14c0375..1dc2204 100644 --- a/Biz/Dev.nix +++ b/Biz/Dev.nix @@ -9,6 +9,7 @@ bild.os { ./Users.nix ./Dev/Configuration.nix ./Dev/Hardware.nix + ./Dev/Hoogle.nix ./Devalloc.nix ]; networking.hostName = "lithium"; diff --git a/Biz/Dev/Configuration.nix b/Biz/Dev/Configuration.nix index 24293cf..13be1be 100644 --- a/Biz/Dev/Configuration.nix +++ b/Biz/Dev/Configuration.nix @@ -8,6 +8,7 @@ let jellyfin = 8096; httpdev = { from = 8000; to = 8099; }; devallocHost = 8095; + hoogle = 8008; }; in { networking = { @@ -109,6 +110,15 @@ in { }; services = { + my-hoogle = { + enable = true; + port = ports.hoogle; + home = "//hoogle.simatime.com"; + packages = import ../Bild/Deps/Haskell.nix; + haskellPackages = pkgs.haskell.packages.ghc865; + host = "0.0.0.0"; + }; + pcscd.enable = true; logind = { lidSwitch = "ignore"; @@ -223,7 +233,6 @@ in { nixos.enable = true; }; - nix = { autoOptimiseStore = true; buildCores = 0; # use all available cores diff --git a/Biz/Dev/Hoogle.nix b/Biz/Dev/Hoogle.nix new file mode 100644 index 0000000..13a5bda --- /dev/null +++ b/Biz/Dev/Hoogle.nix @@ -0,0 +1,79 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.services.my-hoogle; + + hoogleEnv = pkgs.buildEnv { + name = "hoogle"; + paths = [ (cfg.haskellPackages.ghcWithHoogle cfg.packages) ]; + }; + +in { + + options.services.my-hoogle = { + enable = mkEnableOption "Haskell documentation server"; + + port = mkOption { + type = types.int; + default = 8080; + description = '' + Port number Hoogle will be listening to. + ''; + }; + + packages = mkOption { + default = hp: []; + defaultText = "hp: []"; + example = "hp: with hp; [ text lens ]"; + description = '' + The Haskell packages to generate documentation for. + + The option value is a function that takes the package set specified in + the <varname>haskellPackages</varname> option as its sole parameter and + returns a list of packages. + ''; + }; + + haskellPackages = mkOption { + description = "Which haskell package set to use."; + default = pkgs.haskellPackages; + defaultText = "pkgs.haskellPackages"; + }; + + home = mkOption { + type = types.str; + description = "Url for hoogle logo"; + default = "https://hoogle.haskell.org"; + }; + + host = mkOption { + type = types.str; + description = "Set the host to bind on."; + default = "127.0.0.1"; + }; + }; + + config = mkIf cfg.enable { + systemd.services.hoogle = { + description = "Haskell documentation server"; + + wantedBy = [ "multi-user.target" ]; + + serviceConfig = { + Restart = "always"; + ExecStart = ''${hoogleEnv}/bin/hoogle server --local --port ${toString cfg.port} --home ${cfg.home} --host ${cfg.host}''; + + DynamicUser = true; + + ProtectHome = true; + + RuntimeDirectory = "hoogle"; + WorkingDirectory = "%t/hoogle"; + }; + }; + }; + +} diff --git a/Biz/Devalloc.hs b/Biz/Devalloc.hs index 38976c1..a4bfb8d 100644 --- a/Biz/Devalloc.hs +++ b/Biz/Devalloc.hs @@ -26,7 +26,7 @@ -- : dep lucid -- : dep protolude -- : dep req --- : dep safe-copy +-- : dep safecopy -- : dep servant -- : dep servant-lucid -- : dep servant-server |