Created
December 15, 2017 15:53
-
-
Save cleverca22/c1500068abf8e69867ee9ffc07e1b8b5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[clever@amd-nixos:~]$ nix-build math.nix --argstr a 4294967296 --argstr b 4294967296 | |
these derivations will be built: | |
/nix/store/dbjigm9n6nia5cmfbv9cnlnm240z78sy-do-da-math.hs.drv | |
/nix/store/1yq4lh0wwy563jp8d7awii030makjxy8-do-da-math.drv | |
building path(s) ‘/nix/store/ph39dp1ffckjidhjyhgj4p1685vw8d4a-do-da-math.hs’ | |
building path(s) ‘/nix/store/ab8m9ar1bg5p3h8bs2v8x5lk35mwjnmg-do-da-math’ | |
/nix/store/ab8m9ar1bg5p3h8bs2v8x5lk35mwjnmg-do-da-math | |
[clever@amd-nixos:~]$ cat result | |
18446744073709551616 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ a, b }: | |
with import <nixpkgs> {}; | |
let | |
runHaskell = name: deps: code: pkgs.runCommand name { buildInputs = [ (pkgs.haskellPackages.ghcWithPackages deps) ]; } '' | |
runhaskell ${pkgs.writeText "${name}.hs" code} | |
''; | |
in runHaskell "do-da-math" (ps: []) '' | |
{-# LANGUAGE OverloadedStrings #-} | |
module Main (main) where | |
import qualified Data.ByteString as BS | |
import qualified Data.ByteString.Char8 as BSC | |
import System.Environment | |
main :: IO () | |
main = do | |
let | |
a :: Integer | |
a = ${a} | |
b :: Integer | |
b = ${b} | |
output <- getEnv "out" | |
BS.writeFile output (BSC.pack $ show (a * b)) | |
'' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment