Skip to content

Commit

Permalink
Merge pull request #166 from NixOS/npins
Browse files Browse the repository at this point in the history
Focus on stable Nix with npins instead of Flakes
  • Loading branch information
dasJ authored Mar 15, 2024
2 parents b265f30 + 89a25a3 commit 136005f
Show file tree
Hide file tree
Showing 7 changed files with 187 additions and 1,248 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
93 changes: 79 additions & 14 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,17 +1,82 @@
# 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
let
sources = import ./npins;
in
{
system ? builtins.currentSystem,
nixpkgs ? sources.nixpkgs,
serokell-nix ? sources.serokell-nix,
}:
let
overlay = self: super: {
haskell = super.haskell // {
packageOverrides = self: super: { nixfmt = self.callCabal2nix "nixfmt" src { }; };
};
};

pkgs = import nixpkgs {
inherit system;
overlays = [
overlay
(import (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 136005f

Please sign in to comment.