Skip to content

Commit

Permalink
Try to provide reproducible environments.
Browse files Browse the repository at this point in the history
Haskell needed updates.

This doesn't handle the OCaml and Scala implementations properly.
  • Loading branch information
athas committed May 15, 2022
1 parent 549f4b6 commit a1fbf0d
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 12 deletions.
5 changes: 4 additions & 1 deletion fsharp/shell.nix
@@ -1,4 +1,7 @@
with import <nixpkgs> {};
with import (builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/820177eded91f3908cfc72dfee00e831ea3d0060.zip";
sha256 = "1yqx5zy154f8057inwjp2ranizgilvpblqq31cy7nryrwj2apics";
}) {};
stdenv.mkDerivation {
name = "ray";
buildInputs = [ dotnet-sdk_3 gnumake ];
Expand Down
5 changes: 4 additions & 1 deletion futhark/shell.nix
@@ -1,4 +1,7 @@
with import <nixpkgs> {};
with import (builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/820177eded91f3908cfc72dfee00e831ea3d0060.zip";
sha256 = "1yqx5zy154f8057inwjp2ranizgilvpblqq31cy7nryrwj2apics";
}) {};
stdenv.mkDerivation {
name = "ray";
buildInputs = [ futhark ocl-icd opencl-headers ];
Expand Down
4 changes: 2 additions & 2 deletions haskell/Image.hs
@@ -1,9 +1,9 @@
{-# LANGUAGE DeriveGeneric, DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric, DeriveAnyClass, DataKinds #-}
module Image (mkImage, writeImage) where

import Data.Massiv.Array as A
import Data.Massiv.Array.IO

mkImage :: Int -> Int -> (Int -> Int -> Pixel SRGB Word8) -> Image S SRGB Word8
mkImage :: Int -> Int -> (Int -> Int -> Pixel (SRGB 'NonLinear) Word8) -> Image S (SRGB 'NonLinear) Word8
mkImage height width pixel =
makeArrayR S Par (Sz2 height width) (\(i :. j) -> pixel i j)
5 changes: 3 additions & 2 deletions haskell/Raytracing.hs
@@ -1,5 +1,6 @@
{-# LANGUAGE Strict #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE DataKinds #-}
module Raytracing
( Pos, Dir, Camera, mkCamera
, Sphere(..), sphereAABB
Expand Down Expand Up @@ -180,10 +181,10 @@ traceRay objs width height cam =
ray = getRay cam u v
in rayColour objs ray 0

colourToPixel :: Colour -> Pixel SRGB Word8
colourToPixel :: Colour -> Pixel (SRGB 'NonLinear) Word8
colourToPixel (Vec3 r g b) = toPixel8 $ PixelSRGB r g b

render :: Objs -> Int -> Int -> Camera -> Image S SRGB Word8
render :: Objs -> Int -> Int -> Camera -> Image S (SRGB 'NonLinear) Word8
render objs height width cam =
mkImage height width $ \j i ->
colourToPixel $ traceRay objs width height cam j i
2 changes: 1 addition & 1 deletion haskell/cabal.project
@@ -1,2 +1,2 @@
packages: .
index-state: 2020-04-13T13:47:47Z
index-state: 2022-05-15T08:27:37Z
8 changes: 5 additions & 3 deletions haskell/shell.nix
@@ -1,6 +1,8 @@
{ nixpkgs ? import <nixpkgs> {} }:
with nixpkgs;
with import (builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/820177eded91f3908cfc72dfee00e831ea3d0060.zip";
sha256 = "1yqx5zy154f8057inwjp2ranizgilvpblqq31cy7nryrwj2apics";
}) {};
stdenv.mkDerivation {
name = "ray";
buildInputs = [ zlib zlib.out pkgconfig haskell.compiler.ghc883 cabal-install ];
buildInputs = [ zlib zlib.out pkgconfig ghc cabal-install ];
}
8 changes: 8 additions & 0 deletions ispc/shell.nix
@@ -0,0 +1,8 @@
with import (builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/820177eded91f3908cfc72dfee00e831ea3d0060.zip";
sha256 = "1yqx5zy154f8057inwjp2ranizgilvpblqq31cy7nryrwj2apics";
}) {};
stdenv.mkDerivation {
name = "ray";
buildInputs = [ ispc ];
}
9 changes: 9 additions & 0 deletions ocaml/shell.nix
@@ -0,0 +1,9 @@
with import (builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/820177eded91f3908cfc72dfee00e831ea3d0060.zip";
sha256 = "1yqx5zy154f8057inwjp2ranizgilvpblqq31cy7nryrwj2apics";
}) {};
stdenv.mkDerivation {
name = "ray";
# FIXME: this is not enough. See README.md.
buildInputs = [ opam ];
}
8 changes: 8 additions & 0 deletions rust/shell.nix
@@ -0,0 +1,8 @@
with import (builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/820177eded91f3908cfc72dfee00e831ea3d0060.zip";
sha256 = "1yqx5zy154f8057inwjp2ranizgilvpblqq31cy7nryrwj2apics";
}) {};
stdenv.mkDerivation {
name = "ray";
buildInputs = [ cargo rustc ];
}
6 changes: 4 additions & 2 deletions scala/shell.nix
@@ -1,5 +1,7 @@
{ nixpkgs ? import <nixpkgs> {} }:
with nixpkgs;
with import (builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/820177eded91f3908cfc72dfee00e831ea3d0060.zip";
sha256 = "1yqx5zy154f8057inwjp2ranizgilvpblqq31cy7nryrwj2apics";
}) {};
stdenv.mkDerivation {
name = "ray";
buildInputs = [ sbt gnumake ];
Expand Down

0 comments on commit a1fbf0d

Please sign in to comment.