-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* top-level refactor For very simple flakes, it doesn't make sense to create a whole folder structure. ADDITIONS: * Add a top-level package.nix that maps to `packages.<system>.default` * Add a top-level formatter.nix that maps to `formatter.<system>` and `packages.<system>.formatter`. * Load devshells from the devshells/ folder. CHANGES: * perSystem values now merge legacyPackages and packages in that order. * packages are loaded with `callPackage`. BREAKING: * Remove `packages/<pname>/package.nix` as it makes the interface too complicated. * lib/default.nix: take `{ flake, inputs }:` instead of `inputs`. * README: remove old packages folder section This is now covered in the main docs
- Loading branch information
Showing
7 changed files
with
371 additions
and
256 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
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
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
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 |
---|---|---|
@@ -0,0 +1,65 @@ | ||
{ | ||
pname, | ||
pkgs, | ||
flake, | ||
}: | ||
let | ||
formatter = pkgs.writeShellApplication { | ||
name = pname; | ||
|
||
runtimeInputs = [ | ||
pkgs.deadnix | ||
pkgs.nixfmt-rfc-style | ||
]; | ||
|
||
text = '' | ||
set -euo pipefail | ||
set -x | ||
deadnix --no-lambda-pattern-names --edit "$@" | ||
nixfmt "$@" | ||
''; | ||
|
||
meta = { | ||
description = "format your project"; | ||
}; | ||
}; | ||
|
||
check = | ||
pkgs.runCommand "format-check" | ||
{ | ||
nativeBuildInputs = [ | ||
formatter | ||
pkgs.git | ||
]; | ||
|
||
# only check on Linux | ||
meta.platforms = pkgs.lib.platforms.linux; | ||
} | ||
'' | ||
export HOME=$NIX_BUILD_TOP/home | ||
# keep timestamps so that treefmt is able to detect mtime changes | ||
cp --no-preserve=mode --preserve=timestamps -r ${flake} source | ||
cd source | ||
git init --quiet | ||
git add . | ||
shopt -s globstar | ||
${pname} **/*.nix | ||
if ! git diff --exit-code; then | ||
echo "-------------------------------" | ||
echo "aborting due to above changes ^" | ||
exit 1 | ||
fi | ||
touch $out | ||
''; | ||
in | ||
formatter | ||
// { | ||
passthru = formatter.passthru // { | ||
tests = { | ||
check = check; | ||
}; | ||
}; | ||
} |
Oops, something went wrong.