Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Focus on stable Nix with npins instead of Flakes #166

Merged
merged 3 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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