From 30e7c659552f7237a1cb9d159dee9d0e8b68dcc8 Mon Sep 17 00:00:00 2001 From: "Yann Esposito (Yogsototh)" Date: Wed, 3 Apr 2019 22:36:17 +0200 Subject: [PATCH] nix env for reproductible devenv and build --- .envrc | 1 + aggreact.cabal | 7 ++++--- nix/nixpkgs.json | 7 +++++++ nix/nixpkgs.nix | 10 ++++++++++ nix/update-nixpkgs-dev.sh | 4 ++++ nix/update-nixpkgs.sh | 5 +++++ shell.nix | 12 ++++++++++++ 7 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 .envrc create mode 100644 nix/nixpkgs.json create mode 100644 nix/nixpkgs.nix create mode 100755 nix/update-nixpkgs-dev.sh create mode 100755 nix/update-nixpkgs.sh create mode 100644 shell.nix diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..4a4726a --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use_nix diff --git a/aggreact.cabal b/aggreact.cabal index c223022..3e24a61 100644 --- a/aggreact.cabal +++ b/aggreact.cabal @@ -1,8 +1,10 @@ --- This file has been generated from package.yaml by hpack version 0.28.2. +cabal-version: 1.12 + +-- This file has been generated from package.yaml by hpack version 0.31.2. -- -- see: https://github.com/sol/hpack -- --- hash: 2c0743c70d80e2ac0827c17be0cfb1ca6bfd0a613a186d520ce3faeddd522550 +-- hash: cd60f98ce5adc1993e4769824e33298d5d80b96bd03e156d69698fae38f4ef5c name: aggreact version: 0.1.0.0 @@ -16,7 +18,6 @@ copyright: © 2018 Yann Esposito license: ISC license-file: LICENSE build-type: Simple -cabal-version: >= 1.10 extra-source-files: README.md stack.yaml diff --git a/nix/nixpkgs.json b/nix/nixpkgs.json new file mode 100644 index 0000000..a4d28eb --- /dev/null +++ b/nix/nixpkgs.json @@ -0,0 +1,7 @@ +{ + "url": "https://github.com/nixos/nixpkgs.git", + "rev": "e03966a60f517700f5fee5182a5a798f8d0709df", + "date": "2019-04-03T21:17:44+02:00", + "sha256": "1jwgzfnjgfcr67c7nz8hkw4a13qa296bv5cr6m36pfydw27aqdas", + "fetchSubmodules": false +} diff --git a/nix/nixpkgs.nix b/nix/nixpkgs.nix new file mode 100644 index 0000000..b650ce0 --- /dev/null +++ b/nix/nixpkgs.nix @@ -0,0 +1,10 @@ +{ }: +let + hostpkgs = import {}; + srcDef = builtins.fromJSON (builtins.readFile ./nixpkgs.json); + nixpkgs = hostpkgs.fetchFromGitHub { + owner = "NixOS"; + repo = "nixpkgs"; + inherit (srcDef) rev sha256; + }; +in import nixpkgs { } diff --git a/nix/update-nixpkgs-dev.sh b/nix/update-nixpkgs-dev.sh new file mode 100755 index 0000000..c290649 --- /dev/null +++ b/nix/update-nixpkgs-dev.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p nix-prefetch-git + +nix-prefetch-git https://github.com/nixos/nixpkgs.git > ./nix/nixpkgs.json diff --git a/nix/update-nixpkgs.sh b/nix/update-nixpkgs.sh new file mode 100755 index 0000000..0bb858a --- /dev/null +++ b/nix/update-nixpkgs.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p nix-prefetch-git + +nix-prefetch-git https://github.com/nixos/nixpkgs-channels.git \ + --rev refs/heads/nixos-unstable > ./nix/nixpkgs.json diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..ef48ca1 --- /dev/null +++ b/shell.nix @@ -0,0 +1,12 @@ +with import nix/nixpkgs.nix {}; + +mkShell { + name = "aggreact"; + buildInputs = [ gnupg + haskellPackages.stack + haskellPackages.ghcid + ]; + LC_ALL = "en_US.UTF-8"; + LANG = "en_US.UTF-8"; + TMPDIR = "/tmp"; +}