Compare commits
4 Commits
9c05664130
...
b4fac5ab8c
Author | SHA1 | Date | |
---|---|---|---|
b4fac5ab8c | |||
6c6b5d3377 | |||
70cd4f1ec5 | |||
a098861c8d |
@ -83,6 +83,10 @@
|
|||||||
rec {
|
rec {
|
||||||
packages = {
|
packages = {
|
||||||
inherit nix-serve-ng lix-serve-ng;
|
inherit nix-serve-ng lix-serve-ng;
|
||||||
|
private = pkgs.runCommand "private" { } ''
|
||||||
|
mkdir -p $out/nix-support
|
||||||
|
touch $out/nix-support/private
|
||||||
|
'';
|
||||||
default = nix-serve-ng;
|
default = nix-serve-ng;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -48,6 +48,7 @@ executable nix-serve
|
|||||||
, base32
|
, base32
|
||||||
, bytestring
|
, bytestring
|
||||||
, charset
|
, charset
|
||||||
|
, directory
|
||||||
, http-types
|
, http-types
|
||||||
, managed
|
, managed
|
||||||
, megaparsec
|
, megaparsec
|
||||||
|
10
src/Main.hs
10
src/Main.hs
@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
module Main where
|
module Main where
|
||||||
|
|
||||||
|
import Debug.Trace
|
||||||
|
|
||||||
import Control.Monad.IO.Class (liftIO)
|
import Control.Monad.IO.Class (liftIO)
|
||||||
import Data.ByteString (ByteString)
|
import Data.ByteString (ByteString)
|
||||||
import Data.CharSet.ByteSet (ByteSet(..))
|
import Data.CharSet.ByteSet (ByteSet(..))
|
||||||
@ -35,6 +37,7 @@ import qualified Network.Wai.Middleware.RequestLogger as RequestLogger
|
|||||||
import qualified Nix
|
import qualified Nix
|
||||||
import qualified Options
|
import qualified Options
|
||||||
import qualified Options.Applicative as Options
|
import qualified Options.Applicative as Options
|
||||||
|
import qualified System.Directory as Directory
|
||||||
import qualified System.Environment as Environment
|
import qualified System.Environment as Environment
|
||||||
|
|
||||||
data ApplicationOptions = ApplicationOptions
|
data ApplicationOptions = ApplicationOptions
|
||||||
@ -250,6 +253,11 @@ makeApplication ApplicationOptions{..} request respond = do
|
|||||||
|
|
||||||
done response
|
done response
|
||||||
|
|
||||||
|
let privateFilePath = ByteString.Char8.unpack storePath ++ "/nix-support/private"
|
||||||
|
isPrivate <- liftIO $ Directory.doesPathExist privateFilePath
|
||||||
|
|
||||||
|
traceM $ show (privateFilePath, isPrivate)
|
||||||
|
|
||||||
let streamingBody write flush = do
|
let streamingBody write flush = do
|
||||||
result <- Nix.dumpPath hashPart callback
|
result <- Nix.dumpPath hashPart callback
|
||||||
|
|
||||||
@ -261,7 +269,7 @@ makeApplication ApplicationOptions{..} request respond = do
|
|||||||
() <- write builder
|
() <- write builder
|
||||||
flush
|
flush
|
||||||
|
|
||||||
let headers = [ ("Content-Type", "text/plain") ]
|
let headers = [ ("Content-Type", "text/plain") ] <> [("X-Private", "true") | isPrivate]
|
||||||
|
|
||||||
let response =
|
let response =
|
||||||
Wai.responseStream Types.status200 headers streamingBody
|
Wai.responseStream Types.status200 headers streamingBody
|
||||||
|
Loading…
x
Reference in New Issue
Block a user