Skip to content

Commit 0b1b75b

Browse files
committed
Focus on stable Nix and use npins for dependencies
- Simplifies the whole thing due to not having to mess with `system`, see NixOS/nix#3843 - Makes the lockfile _way_ smaller, see NixOS/nix#7730
1 parent 6d4452e commit 0b1b75b

File tree

7 files changed

+146
-1243
lines changed

7 files changed

+146
-1243
lines changed

.reuse/dep5

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ Copyright: 2019 Serokell <[email protected]>
55
2019 Lars Jellema <[email protected]>
66
License: MPL-2.0
77

8+
Files: npins/*
9+
Copyright: 2024 Silvan Mosberger <[email protected]>
10+
License: MPL-2.0
11+
812
Files: test/diff/*
913
Copyright: 2024 piegames <[email protected]>
1014
License: MPL-2.0

default.nix

+63-14
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,66 @@
1-
# SPDX-FileCopyrightText: 2020 Serokell <https://serokell.io/>
1+
# © 2019 Serokell <[email protected]>
2+
# © 2019 Lars Jellema <[email protected]>
3+
# © 2024 Silvan Mosberger <[email protected]>
24
#
35
# SPDX-License-Identifier: MPL-2.0
46

5-
(import
6-
(
7-
let
8-
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
9-
in
10-
fetchTarball {
11-
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
12-
sha256 = lock.nodes.flake-compat.locked.narHash;
13-
}
14-
)
15-
{
16-
src = ./.;
17-
}).defaultNix
7+
{
8+
system ? builtins.currentSystem,
9+
sources ? import ./npins,
10+
}:
11+
let
12+
overlay = self: super: {
13+
haskell = super.haskell // {
14+
packageOverrides = self: super: {
15+
nixfmt = self.callCabal2nix "nixfmt" src { };
16+
};
17+
};
18+
};
19+
20+
pkgs = import sources.nixpkgs {
21+
inherit system;
22+
overlays = [ overlay (import (sources.serokell-nix + "/overlay")) ];
23+
config = {};
24+
};
25+
26+
inherit (pkgs) haskell lib;
27+
28+
regexes =
29+
[ ".*.cabal$" "^src.*" "^main.*" "^Setup.hs$" "^js.*" "LICENSE" ];
30+
src = builtins.path {
31+
path = ./.;
32+
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;
36+
};
37+
38+
build = pkgs.haskellPackages.nixfmt;
39+
40+
in
41+
build // rec {
42+
packages = {
43+
nixfmt = build;
44+
nixfmt-static = haskell.lib.justStaticExecutables packages.nixfmt;
45+
nixfmt-deriver = packages.nixfmt-static.cabal2nixDeriver;
46+
47+
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+
]);
55+
});
56+
57+
inherit (pkgs) reuse;
58+
};
59+
60+
shell = packages.nixfmt-shell;
61+
62+
checks = {
63+
hlint = pkgs.build.haskell.hlint ./.;
64+
stylish-haskell = pkgs.build.haskell.stylish-haskell ./.;
65+
};
66+
}

0 commit comments

Comments
 (0)