Skip to content

Commit a585e41

Browse files
committed
Format with fourmolu and ch-hs-imports
1 parent 0357176 commit a585e41

File tree

149 files changed

+9115
-7256
lines changed

Some content is hidden

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

149 files changed

+9115
-7256
lines changed

default.nix

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
let
2-
haskellNix = import (import ./nix/sources.nix)."haskell.nix" {};
2+
haskellNix = import (import ./nix/sources.nix)."haskell.nix" { };
33

44
nixpkgsSrc = haskellNix.sources.nixpkgs-unstable;
55

@@ -21,7 +21,8 @@ pkgs.haskell-nix.project {
2121
};
2222

2323
modules = [
24-
{ packages.rel8 = {
24+
{
25+
packages.rel8 = {
2526
preCheck = ''
2627
export PATH="${pkgs.postgresql}/bin:${"$PATH"}"
2728
'';

fourmolu.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
indentation: 2
2+
comma-style: leading
3+
import-export-style: diff-friendly
4+
indent-wheres: true
5+
record-brace-space: false
6+
respectful: true
7+
haddock-style: multi-line
8+
newlines-between-decls: 2
9+
fixities: []
10+
single-constraint-parens: auto

nix/sources.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
{
2+
"ch-hs-imports": {
3+
"branch": "master",
4+
"description": null,
5+
"homepage": null,
6+
"owner": "circuithub",
7+
"repo": "ch-hs-imports",
8+
"rev": "e3dc32bb2e945334261b6d72dc5c3df490cebc2b",
9+
"sha256": "08z7hishpp1j7nxwhap4c0ggwhpm15i5swy91r96jh70ql20j3yi",
10+
"type": "tarball",
11+
"url": "https://github.com/circuithub/ch-hs-imports/archive/e3dc32bb2e945334261b6d72dc5c3df490cebc2b.tar.gz",
12+
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
13+
},
214
"haskell.nix": {
315
"branch": "master",
416
"description": "Alternative Haskell Infrastructure for Nixpkgs",

nix/sources.nix

Lines changed: 55 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,27 @@ let
1010
let
1111
name' = sanitizeName name + "-src";
1212
in
13-
if spec.builtin or true then
14-
builtins_fetchurl { inherit (spec) url sha256; name = name'; }
15-
else
16-
pkgs.fetchurl { inherit (spec) url sha256; name = name'; };
13+
if spec.builtin or true then
14+
builtins_fetchurl { inherit (spec) url sha256; name = name'; }
15+
else
16+
pkgs.fetchurl { inherit (spec) url sha256; name = name'; };
1717

1818
fetch_tarball = pkgs: name: spec:
1919
let
2020
name' = sanitizeName name + "-src";
2121
in
22-
if spec.builtin or true then
23-
builtins_fetchTarball { name = name'; inherit (spec) url sha256; }
24-
else
25-
pkgs.fetchzip { name = name'; inherit (spec) url sha256; };
22+
if spec.builtin or true then
23+
builtins_fetchTarball { name = name'; inherit (spec) url sha256; }
24+
else
25+
pkgs.fetchzip { name = name'; inherit (spec) url sha256; };
2626

2727
fetch_git = name: spec:
2828
let
2929
ref =
3030
if spec ? ref then spec.ref else
31-
if spec ? branch then "refs/heads/${spec.branch}" else
32-
if spec ? tag then "refs/tags/${spec.tag}" else
33-
abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!";
31+
if spec ? branch then "refs/heads/${spec.branch}" else
32+
if spec ? tag then "refs/tags/${spec.tag}" else
33+
abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!";
3434
submodules = if spec ? submodules then spec.submodules else false;
3535
submoduleArg =
3636
let
@@ -44,15 +44,15 @@ let
4444
+ "but your nix's (${builtins.nixVersion}) builtins.fetchGit "
4545
+ "does not support them"
4646
)
47-
{}
48-
else {};
47+
{ }
48+
else { };
4949
in
50-
if nixSupportsSubmodules
51-
then { inherit submodules; }
52-
else emptyArgWithWarning;
50+
if nixSupportsSubmodules
51+
then { inherit submodules; }
52+
else emptyArgWithWarning;
5353
in
54-
builtins.fetchGit
55-
({ url = spec.repo; inherit (spec) rev; inherit ref; } // submoduleArg);
54+
builtins.fetchGit
55+
({ url = spec.repo; inherit (spec) rev; inherit ref; } // submoduleArg);
5656

5757
fetch_local = spec: spec.path;
5858

@@ -86,16 +86,16 @@ let
8686
hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath;
8787
hasThisAsNixpkgsPath = <nixpkgs> == ./.;
8888
in
89-
if builtins.hasAttr "nixpkgs" sources
90-
then sourcesNixpkgs
91-
else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then
92-
import <nixpkgs> {}
93-
else
94-
abort
95-
''
96-
Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or
97-
add a package called "nixpkgs" to your sources.json.
98-
'';
89+
if builtins.hasAttr "nixpkgs" sources
90+
then sourcesNixpkgs
91+
else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then
92+
import <nixpkgs> { }
93+
else
94+
abort
95+
''
96+
Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or
97+
add a package called "nixpkgs" to your sources.json.
98+
'';
9999

100100
# The actual fetching function.
101101
fetch = pkgs: name: spec:
@@ -118,10 +118,10 @@ let
118118
saneName = stringAsChars (c: if isNull (builtins.match "[a-zA-Z0-9]" c) then "_" else c) name;
119119
ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}";
120120
in
121-
if ersatz == "" then drv else
122-
# this turns the string into an actual Nix path (for both absolute and
123-
# relative paths)
124-
if builtins.substring 0 1 ersatz == "/" then /. + ersatz else /. + builtins.getEnv "PWD" + "/${ersatz}";
121+
if ersatz == "" then drv else
122+
# this turns the string into an actual Nix path (for both absolute and
123+
# relative paths)
124+
if builtins.substring 0 1 ersatz == "/" then /. + ersatz else /. + builtins.getEnv "PWD" + "/${ersatz}";
125125

126126
# Ports of functions for older nix versions
127127

@@ -132,7 +132,7 @@ let
132132
);
133133

134134
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295
135-
range = first: last: if first > last then [] else builtins.genList (n: first + n) (last - first + 1);
135+
range = first: last: if first > last then [ ] else builtins.genList (n: first + n) (last - first + 1);
136136

137137
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257
138138
stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1));
@@ -143,43 +143,46 @@ let
143143
concatStrings = builtins.concatStringsSep "";
144144

145145
# https://github.com/NixOS/nixpkgs/blob/8a9f58a375c401b96da862d969f66429def1d118/lib/attrsets.nix#L331
146-
optionalAttrs = cond: as: if cond then as else {};
146+
optionalAttrs = cond: as: if cond then as else { };
147147

148148
# fetchTarball version that is compatible between all the versions of Nix
149149
builtins_fetchTarball = { url, name ? null, sha256 }@attrs:
150150
let
151151
inherit (builtins) lessThan nixVersion fetchTarball;
152152
in
153-
if lessThan nixVersion "1.12" then
154-
fetchTarball ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; }))
155-
else
156-
fetchTarball attrs;
153+
if lessThan nixVersion "1.12" then
154+
fetchTarball ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; }))
155+
else
156+
fetchTarball attrs;
157157

158158
# fetchurl version that is compatible between all the versions of Nix
159159
builtins_fetchurl = { url, name ? null, sha256 }@attrs:
160160
let
161161
inherit (builtins) lessThan nixVersion fetchurl;
162162
in
163-
if lessThan nixVersion "1.12" then
164-
fetchurl ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; }))
165-
else
166-
fetchurl attrs;
163+
if lessThan nixVersion "1.12" then
164+
fetchurl ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; }))
165+
else
166+
fetchurl attrs;
167167

168168
# Create the final "sources" from the config
169169
mkSources = config:
170-
mapAttrs (
171-
name: spec:
172-
if builtins.hasAttr "outPath" spec
173-
then abort
174-
"The values in sources.json should not have an 'outPath' attribute"
175-
else
176-
spec // { outPath = replace name (fetch config.pkgs name spec); }
177-
) config.sources;
170+
mapAttrs
171+
(
172+
name: spec:
173+
if builtins.hasAttr "outPath" spec
174+
then
175+
abort
176+
"The values in sources.json should not have an 'outPath' attribute"
177+
else
178+
spec // { outPath = replace name (fetch config.pkgs name spec); }
179+
)
180+
config.sources;
178181

179182
# The "config" used by the fetchers
180183
mkConfig =
181184
{ sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null
182-
, sources ? if isNull sourcesFile then {} else builtins.fromJSON (builtins.readFile sourcesFile)
185+
, sources ? if isNull sourcesFile then { } else builtins.fromJSON (builtins.readFile sourcesFile)
183186
, system ? builtins.currentSystem
184187
, pkgs ? mkPkgs sources system
185188
}: rec {
@@ -191,4 +194,4 @@ let
191194
};
192195

193196
in
194-
mkSources (mkConfig {}) // { __functor = _: settings: mkSources (mkConfig settings); }
197+
mkSources (mkConfig { }) // { __functor = _: settings: mkSources (mkConfig settings); }

0 commit comments

Comments
 (0)