Skip to content

Commit 89a25a3

Browse files
committed
Format all Nix files
1 parent 0b1b75b commit 89a25a3

File tree

3 files changed

+79
-43
lines changed

3 files changed

+79
-43
lines changed

default.nix

+37-21
Original file line numberDiff line numberDiff line change
@@ -4,54 +4,70 @@
44
#
55
# SPDX-License-Identifier: MPL-2.0
66

7+
let
8+
sources = import ./npins;
9+
in
710
{
811
system ? builtins.currentSystem,
9-
sources ? import ./npins,
12+
nixpkgs ? sources.nixpkgs,
13+
serokell-nix ? sources.serokell-nix,
1014
}:
1115
let
1216
overlay = self: super: {
1317
haskell = super.haskell // {
14-
packageOverrides = self: super: {
15-
nixfmt = self.callCabal2nix "nixfmt" src { };
16-
};
18+
packageOverrides = self: super: { nixfmt = self.callCabal2nix "nixfmt" src { }; };
1719
};
1820
};
1921

20-
pkgs = import sources.nixpkgs {
22+
pkgs = import nixpkgs {
2123
inherit system;
22-
overlays = [ overlay (import (sources.serokell-nix + "/overlay")) ];
23-
config = {};
24+
overlays = [
25+
overlay
26+
(import (serokell-nix + "/overlay"))
27+
];
28+
config = { };
2429
};
2530

2631
inherit (pkgs) haskell lib;
2732

28-
regexes =
29-
[ ".*.cabal$" "^src.*" "^main.*" "^Setup.hs$" "^js.*" "LICENSE" ];
33+
regexes = [
34+
".*.cabal$"
35+
"^src.*"
36+
"^main.*"
37+
"^Setup.hs$"
38+
"^js.*"
39+
"LICENSE"
40+
];
3041
src = builtins.path {
3142
path = ./.;
3243
name = "nixfmt-src";
33-
filter = path: type:
34-
let relPath = lib.removePrefix (toString ./. + "/") (toString path);
35-
in lib.any (re: builtins.match re relPath != null) regexes;
44+
filter =
45+
path: type:
46+
let
47+
relPath = lib.removePrefix (toString ./. + "/") (toString path);
48+
in
49+
lib.any (re: builtins.match re relPath != null) regexes;
3650
};
3751

3852
build = pkgs.haskellPackages.nixfmt;
39-
4053
in
41-
build // rec {
54+
build
55+
// rec {
4256
packages = {
4357
nixfmt = build;
4458
nixfmt-static = haskell.lib.justStaticExecutables packages.nixfmt;
4559
nixfmt-deriver = packages.nixfmt-static.cabal2nixDeriver;
4660

4761
nixfmt-shell = packages.nixfmt.env.overrideAttrs (oldAttrs: {
48-
buildInputs = oldAttrs.buildInputs ++ (with pkgs; [
49-
# nixfmt: expand
50-
cabal-install
51-
stylish-haskell
52-
shellcheck
53-
npins
54-
]);
62+
buildInputs =
63+
oldAttrs.buildInputs
64+
++ (with pkgs; [
65+
# nixfmt: expand
66+
cabal-install
67+
stylish-haskell
68+
shellcheck
69+
npins
70+
]);
5571
});
5672

5773
inherit (pkgs) reuse;

flake.nix

+9-7
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66

77
inputs.flake-utils.url = "github:numtide/flake-utils";
88

9-
outputs = { flake-utils, self }:
10-
flake-utils.lib.eachDefaultSystem (system:
9+
outputs =
10+
{ flake-utils, self }:
11+
flake-utils.lib.eachDefaultSystem (
12+
system:
1113
let
12-
result = import ./default.nix {
13-
inherit system;
14-
};
15-
in {
14+
result = import ./default.nix { inherit system; };
15+
in
16+
{
1617
packages = result.packages // {
1718
default = result;
1819
};
@@ -23,5 +24,6 @@
2324
};
2425

2526
checks = result.checks;
26-
});
27+
}
28+
);
2729
}

npins/default.nix

+33-15
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,32 @@ let
33
data = builtins.fromJSON (builtins.readFile ./sources.json);
44
version = data.version;
55

6-
mkSource = spec:
7-
assert spec ? type; let
6+
mkSource =
7+
spec:
8+
assert spec ? type;
9+
let
810
path =
9-
if spec.type == "Git" then mkGitSource spec
10-
else if spec.type == "GitRelease" then mkGitSource spec
11-
else if spec.type == "PyPi" then mkPyPiSource spec
12-
else if spec.type == "Channel" then mkChannelSource spec
13-
else builtins.throw "Unknown source type ${spec.type}";
11+
if spec.type == "Git" then
12+
mkGitSource spec
13+
else if spec.type == "GitRelease" then
14+
mkGitSource spec
15+
else if spec.type == "PyPi" then
16+
mkPyPiSource spec
17+
else if spec.type == "Channel" then
18+
mkChannelSource spec
19+
else
20+
builtins.throw "Unknown source type ${spec.type}";
1421
in
1522
spec // { outPath = path; };
1623

17-
mkGitSource = { repository, revision, url ? null, hash, ... }:
24+
mkGitSource =
25+
{
26+
repository,
27+
revision,
28+
url ? null,
29+
hash,
30+
...
31+
}:
1832
assert repository ? type;
1933
# At the moment, either it is a plain git repository (which has an url), or it is a GitHub/GitLab repository
2034
# In the latter case, there we will always be an url to the tarball
@@ -23,19 +37,23 @@ let
2337
inherit url;
2438
sha256 = hash; # FIXME: check nix version & use SRI hashes
2539
})
26-
else assert repository.type == "Git"; builtins.fetchGit {
27-
url = repository.url;
28-
rev = revision;
29-
# hash = hash;
30-
};
40+
else
41+
assert repository.type == "Git";
42+
builtins.fetchGit {
43+
url = repository.url;
44+
rev = revision;
45+
# hash = hash;
46+
};
3147

32-
mkPyPiSource = { url, hash, ... }:
48+
mkPyPiSource =
49+
{ url, hash, ... }:
3350
builtins.fetchurl {
3451
inherit url;
3552
sha256 = hash;
3653
};
3754

38-
mkChannelSource = { url, hash, ... }:
55+
mkChannelSource =
56+
{ url, hash, ... }:
3957
builtins.fetchTarball {
4058
inherit url;
4159
sha256 = hash;

0 commit comments

Comments
 (0)