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