-
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #166 from NixOS/npins
Focus on stable Nix with npins instead of Flakes
- Loading branch information
Showing
7 changed files
with
187 additions
and
1,248 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ./.; | ||
}; | ||
} |
Oops, something went wrong.