Skip to content

Commit 5b7f7f2

Browse files
committed
Add 'nix-tools/' from commit '555d57e1ea81b79945f2608aa261df20f6b602a5'
git-subtree-dir: nix-tools git-subtree-mainline: 1110a74 git-subtree-split: 555d57e
2 parents 1110a74 + 555d57e commit 5b7f7f2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+3266
-0
lines changed

nix-tools/.buildkite/build.sh

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#! /usr/bin/env nix-shell
2+
#! nix-shell -I "nixpkgs=channel:nixos-21.11" --pure -i bash -p nixUnstable cabal-install ghc git nix-prefetch-git cacert
3+
4+
export NIX_PATH="nixpkgs=channel:nixos-21.11"
5+
index_state="2020-01-10T00:00:00Z"
6+
expected_hash="0z2jc4fibfxz88pfgjq3wk5j3v7sn34xkwb8h60hbwfwhhy63vx6"
7+
8+
set -euo pipefail
9+
10+
# This file can interfere with the build.
11+
# https://github.com/input-output-hk/haskell.nix/issues/57
12+
rm -f .nix-tools.cache
13+
14+
echo "+++ Cabal configure"
15+
cabal new-update
16+
cabal new-configure
17+
18+
echo
19+
echo "+++ Run stable version of plan-to-nix"
20+
nix build --impure --expr '(let haskellNix = import (builtins.fetchTarball "https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz") {}; in (import haskellNix.sources.nixpkgs haskellNix.nixpkgsArgs).haskell-nix.nix-tools.ghc8107)' -o nt
21+
./nt/bin/plan-to-nix --output .buildkite/nix1 --plan-json dist-newstyle/cache/plan.json
22+
23+
# Replace currently broken plan-to-nix output
24+
cp .buildkite/fixed.nix .buildkite/nix1/default.nix
25+
26+
echo
27+
echo "+++ Build project"
28+
nix build -f .buildkite/nix1 nix-tools.components.exes --no-link
29+
30+
echo
31+
echo "+++ Run tests"
32+
echo "There are no tests -- https://github.com/input-output-hk/haskell.nix/issues/51"
33+
34+
echo
35+
echo "+++ Add runtime dependencies to PATH"
36+
37+
nix build -f channel:nixos-20.03 nix-prefetch-scripts -o nix-prefetch-scripts
38+
nix build -f channel:nixos-20.03 git -o git
39+
export PATH="$PWD/nix-prefetch-scripts/bin:$PWD/git/bin:$PATH"
40+
41+
echo
42+
echo "+++ Run plan-to-nix again"
43+
44+
# This file can interfere with the build.
45+
# https://github.com/input-output-hk/haskell.nix/issues/57
46+
rm -f .nix-tools.cache
47+
48+
nix build -f .buildkite/nix1 nix-tools.components.exes.plan-to-nix
49+
./result/bin/plan-to-nix --output .buildkite/nix2 --plan-json dist-newstyle/cache/plan.json
50+
51+
# Add module needed to allow Cabal 3.2 to be installed
52+
sed -i -e 's|modules = \[\]|modules = \[{ nonReinstallablePkgs = \[ "rts" "ghc-heap" "ghc-prim" "integer-gmp" "integer-simple" "base" "deepseq" "array" "ghc-boot-th" "pretty" "template-haskell" "ghcjs-prim" "ghcjs-th" "ghc-boot" "ghc" "Win32" "array" "binary" "bytestring" "containers" "directory" "filepath" "ghc-boot" "ghc-compact" "ghc-prim" "hpc" "mtl" "parsec" "process" "text" "time" "transformers" "unix" "xhtml" "stm" "terminfo" \]; }\]|' \
53+
.buildkite/nix2/default.nix
54+
55+
echo
56+
echo "+++ Build project"
57+
58+
nix build -f .buildkite/nix2 nix-tools.components.exes --no-link
59+
60+
echo
61+
echo "--- Test index file truncation"
62+
63+
shopt -s nullglob
64+
for a in /nix/store/*-00-index.tar.gz; do nix-store --delete $a; done
65+
shopt -u nullglob
66+
67+
nix build -f test/truncate-index.nix --no-link \
68+
--arg nix-tools-path ./.buildkite/nix2 \
69+
--argstr index-state "$index_state" \
70+
--argstr hash "$expected_hash" \
71+
indexTruncated

nix-tools/.buildkite/fixed.nix

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{ haskellNix ? import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz) {}
2+
, nixpkgs ? haskellNix.sources.nixpkgs }:
3+
4+
let
5+
pkgs = import nixpkgs haskellNix.nixpkgsArgs;
6+
7+
pkgSet = pkgs.haskell-nix.mkCabalProjectPkgSet {
8+
plan-pkgs = import ./pkgs.nix;
9+
pkg-def-extras = [];
10+
modules = [{
11+
nonReinstallablePkgs= [ "rts" "ghc-heap" "ghc-prim" "integer-gmp" "integer-simple" "base"
12+
"deepseq" "array" "ghc-boot-th" "pretty" "template-haskell"
13+
# ghcjs custom packages
14+
"ghcjs-prim" "ghcjs-th"
15+
"ghc-boot"
16+
"ghc" "Win32" "array" "binary" "bytestring" "containers"
17+
"directory" "filepath" "ghc-boot" "ghc-compact" "ghc-prim"
18+
# "ghci" "haskeline"
19+
"hpc"
20+
"mtl" "parsec" "process" "text" "time" "transformers"
21+
"unix" "xhtml"
22+
# "stm" "terminfo"
23+
];
24+
}];
25+
};
26+
27+
in
28+
pkgSet.config.hsPkgs

nix-tools/.buildkite/pipeline.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
steps:
2+
- label: 'Build'
3+
command: ./.buildkite/build.sh
4+
agents:
5+
system: x86_64-linux

nix-tools/.gitattributes

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# GitHub Linguist annotations.
2+
# Hide nix/.stack.nix/*.nix
3+
# Hide nix/.plan.nix/*.nix
4+
# That is stuff that is generated by nix-tools stack-to-nix
5+
6+
nix/.stack.nix/*.nix linguist-generated=true
7+
nix/.plan.nix/*.nix linguist-generated=true
8+
.stack-to-nix.cache linguist-generated=true
9+
nix/.stack-pkgs.nix linguist-generated=true
10+
nix/.plan-pkgs.nix linguist-generated=true

nix-tools/.gitignore

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
2+
# Created by https://www.gitignore.io/api/haskell,emacs,vim
3+
4+
### Emacs ###
5+
# -*- mode: gitignore; -*-
6+
*~
7+
\#*\#
8+
/.emacs.desktop
9+
/.emacs.desktop.lock
10+
*.elc
11+
auto-save-list
12+
tramp
13+
.\#*
14+
15+
# Org-mode
16+
.org-id-locations
17+
*_archive
18+
19+
# flymake-mode
20+
*_flymake.*
21+
22+
# eshell files
23+
/eshell/history
24+
/eshell/lastdir
25+
26+
# elpa packages
27+
/elpa/
28+
29+
# reftex files
30+
*.rel
31+
32+
# AUCTeX auto folder
33+
/auto/
34+
35+
# cask packages
36+
.cask/
37+
dist/
38+
39+
# Flycheck
40+
flycheck_*.el
41+
42+
# server auth directory
43+
/server/
44+
45+
# projectiles files
46+
.projectile
47+
48+
# directory configuration
49+
.dir-locals.el
50+
51+
### Haskell ###
52+
dist
53+
dist-*
54+
cabal-dev
55+
*.o
56+
*.hi
57+
*.chi
58+
*.chs.h
59+
*.dyn_o
60+
*.dyn_hi
61+
.hpc
62+
.hsenv
63+
.cabal-sandbox/
64+
cabal.sandbox.config
65+
*.prof
66+
*.aux
67+
*.hp
68+
*.eventlog
69+
.stack-work/
70+
cabal.project.local
71+
cabal.project.local~
72+
.HTF/
73+
.ghc.environment.*
74+
75+
### Vim ###
76+
# Swap
77+
[._]*.s[a-v][a-z]
78+
[._]*.sw[a-p]
79+
[._]s[a-rt-v][a-z]
80+
[._]ss[a-gi-z]
81+
[._]sw[a-p]
82+
83+
# Session
84+
Session.vim
85+
86+
# Temporary
87+
.netrwhist
88+
# Auto-generated tag files
89+
tags
90+
# Persistent undo
91+
[._]*.un~
92+
93+
94+
# End of https://www.gitignore.io/api/haskell,emacs,vim

nix-tools/.gitmodules

Whitespace-only changes.

nix-tools/ChangeLog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Revision history for cabal2nixe
2+
3+
## 0.1.0.0 -- YYYY-mm-dd
4+
5+
* First version. Released on an unsuspecting world.

nix-tools/LICENSE

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Copyright (c) 2018, Moritz Angermann
2+
3+
All rights reserved.
4+
5+
Redistribution and use in source and binary forms, with or without
6+
modification, are permitted provided that the following conditions are met:
7+
8+
* Redistributions of source code must retain the above copyright
9+
notice, this list of conditions and the following disclaimer.
10+
11+
* Redistributions in binary form must reproduce the above
12+
copyright notice, this list of conditions and the following
13+
disclaimer in the documentation and/or other materials provided
14+
with the distribution.
15+
16+
* Neither the name of Moritz Angermann nor the names of other
17+
contributors may be used to endorse or promote products derived
18+
from this software without specific prior written permission.
19+
20+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

nix-tools/README.org

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#+STARTUP: showall hidestars
2+
3+
* ~nix-tools~
4+
5+
[[https://buildkite.com/input-output-hk/nix-tools][https://badge.buildkite.com/8c5ed154c28db5d7184560c8000e57180b2b362b7a0431602e.svg]]
6+
7+
~nix-tools~ is a set of Haskell → Nix tools to integrate Haskell
8+
projects into Nix build environments.
9+
10+
* Motivation
11+
12+
Why (yet) another conversion to Nix? ~cabal2nix~ has served the Nix
13+
community well for a long time. It does have short comings that can't
14+
be easily overcome without significantly altering ~cabal2nix~. These
15+
are among others:
16+
17+
- hard coded flags / operating system upon invocation
18+
- package resolution in cabal2nix instead of nix.
19+
20+
Ideally we'd convert cabal files into Nix expression and retain almost
21+
everything from the cabal file and let Nix deal with the expression
22+
afterwards.
23+
24+
~nix-tools~ explores this space of a very simple ~.cabal~ conversion
25+
into a ~nix~ expression and then doing the lifting in Nix.
26+
27+
* QuickStart
28+
29+
View the [[https://input-output-hk.github.io/haskell.nix/][haskell.nix documentation]] for instructions on how to get
30+
started with your own project.
31+
32+
* Building
33+
34+
To build all of the ~nix-tools~ using Cabal:
35+
36+
#+begin_example
37+
cabal new-build
38+
#+end_example
39+
40+
* Project Roadmap
41+
42+
Under the [[https://github.com/input-output-hk/haskell.nix][haskell.nix]]
43+
umbrella there are a few [[https://github.com/input-output-hk/haskell.nix/projects][GitHub Projects]]
44+
for tracking completion of the project goals. If you would like to
45+
follow or contribute to this effort then that would be a good place to
46+
start.
47+
48+
Please open bug reports in the
49+
[[https://github.com/input-output-hk/haskell.nix/issues][Haskell.nix issue tracker]].

nix-tools/Setup.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import Distribution.Simple
2+
main = defaultMain

nix-tools/_config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
theme: jekyll-theme-minimal

nix-tools/cabal-name/Main.hs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module Main where
2+
3+
import CabalName (doCabalName)
4+
import CabalName.CLI (parseCabalNameArgs)
5+
6+
main :: IO ()
7+
main = parseCabalNameArgs >>= doCabalName

nix-tools/cabal.project

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
index-state: 2022-07-25T00:00:00Z
2+
3+
packages: .
4+
5+
allow-newer: hackage-db:Cabal, hpack:Cabal
6+
7+
source-repository-package
8+
type: git
9+
location: https://github.com/michaelpj/hackage-db.git
10+
tag: f3b9240212b036391871e4ea09891e91efcea7a1
11+
--sha256: sha256-n0ATmkwtR68E2FuZK3QIQgZirVmWbd21vIQmzhGKsRw=

0 commit comments

Comments
 (0)