Skip to content

Commit

Permalink
Use npins instead of Flakes for dependencies
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
infinisil committed Mar 14, 2024
1 parent 6d4452e commit 36a683f
Show file tree
Hide file tree
Showing 7 changed files with 146 additions and 1,243 deletions.
4 changes: 4 additions & 0 deletions .reuse/dep5
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ Copyright: 2019 Serokell <[email protected]>
2019 Lars Jellema <[email protected]>
License: MPL-2.0

Files: npins/*
Copyright: 2024 Silvan Mosberger <[email protected]>
License: MPL-2.0

Files: test/diff/*
Copyright: 2024 piegames <[email protected]>
License: MPL-2.0
Expand Down
77 changes: 63 additions & 14 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,17 +1,66 @@
# SPDX-FileCopyrightText: 2020 Serokell <https://serokell.io/>
# © 2019 Serokell <[email protected]>
# © 2019 Lars Jellema <[email protected]>
# © 2024 Silvan Mosberger <[email protected]>
#
# SPDX-License-Identifier: MPL-2.0

(import
(
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in
fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}
)
{
src = ./.;
}).defaultNix
{
system ? builtins.currentSystem,
sources ? import ./npins,
}:
let
overlay = self: super: {
haskell = super.haskell // {
packageOverrides = self: super: {
nixfmt = self.callCabal2nix "nixfmt" src { };
};
};
};

pkgs = import sources.nixpkgs {
inherit system;
overlays = [ overlay (import (sources.serokell-nix + "/overlay")) ];
config = {};
};

inherit (pkgs) haskell lib;

regexes =
[ ".*.cabal$" "^src.*" "^main.*" "^Setup.hs$" "^js.*" "LICENSE" ];
src = builtins.path {
path = ./.;
name = "nixfmt-src";
filter = path: type:
let relPath = lib.removePrefix (toString ./. + "/") (toString path);
in lib.any (re: builtins.match re relPath != null) regexes;
};

build = pkgs.haskellPackages.nixfmt;

in
build // rec {
packages = {
nixfmt = build;
nixfmt-static = haskell.lib.justStaticExecutables packages.nixfmt;
nixfmt-deriver = packages.nixfmt-static.cabal2nixDeriver;

nixfmt-shell = packages.nixfmt.env.overrideAttrs (oldAttrs: {
buildInputs = oldAttrs.buildInputs ++ (with pkgs; [
# nixfmt: expand
cabal-install
stylish-haskell
shellcheck
npins
]);
});

inherit (pkgs) reuse;
};

shell = packages.nixfmt-shell;

checks = {
hlint = pkgs.build.haskell.hlint ./.;
stylish-haskell = pkgs.build.haskell.stylish-haskell ./.;
};
}
Loading

0 comments on commit 36a683f

Please sign in to comment.