1
1
mirror of https://github.com/nmattia/niv.git synced 2024-11-29 09:42:35 +03:00

Merge pull request #171 from zimbatm/nixpkgs-fmt-check

ci: add nixpkgs-fmt check (v2)
This commit is contained in:
Nicolas Mattia 2020-01-06 11:20:08 +01:00 committed by GitHub
commit 5170a6f3f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 89 additions and 69 deletions

View File

@ -145,6 +145,7 @@ with rec
# version from `package.yaml` and create a dummy module that we inject in the # version from `package.yaml` and create a dummy module that we inject in the
# `ghci` command. # `ghci` command.
niv-devshell = haskellPackages.shellFor { niv-devshell = haskellPackages.shellFor {
buildInputs = [ pkgs.nixpkgs-fmt ];
packages = ps: [ ps.niv ]; packages = ps: [ ps.niv ];
shellHook = '' shellHook = ''
repl_for() { repl_for() {

View File

@ -2,6 +2,7 @@
import sources.nixpkgs { import sources.nixpkgs {
overlays = [ overlays = [
(_: pkgs: { inherit sources; }) (_: pkgs: { inherit sources; })
(_: pkgs: { nixpkgs-fmt = import pkgs.sources.nixpkgs-fmt {}; })
(_: pkgs: { termtosvg = pkgs.callPackage ./termtosvg.nix {}; }) (_: pkgs: { termtosvg = pkgs.callPackage ./termtosvg.nix {}; })
]; ];
config = {}; config = {};

View File

@ -11,6 +11,18 @@
"url": "https://github.com/NixOS/nixpkgs-channels/archive/d85e435b7bded2596d7b201bcd938c94d8a921c1.tar.gz", "url": "https://github.com/NixOS/nixpkgs-channels/archive/d85e435b7bded2596d7b201bcd938c94d8a921c1.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz" "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
}, },
"nixpkgs-fmt": {
"branch": "master",
"description": "Nix code formatter for nixpkgs [maintainer=@zimbatm]",
"homepage": "https://nix-community.github.io/nixpkgs-fmt/",
"owner": "nix-community",
"repo": "nixpkgs-fmt",
"rev": "2a64f4b6a597d0d62004ffcec3ae4fd83cd1efc8",
"sha256": "01kx4y1d4c5fjvpcffk92pk9hdbgg5j9h2ryqy2hfm54s7mb0k63",
"type": "tarball",
"url": "https://github.com/nix-community/nixpkgs-fmt/archive/2a64f4b6a597d0d62004ffcec3ae4fd83cd1efc8.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"termtosvg": { "termtosvg": {
"branch": "develop", "branch": "develop",
"description": "Record terminal sessions as SVG animations", "description": "Record terminal sessions as SVG animations",

View File

@ -132,5 +132,4 @@ let
pkgs = mkPkgs sources; pkgs = mkPkgs sources;
}; };
in in
mkSources (mkConfig {}) // mkSources (mkConfig {}) // { __functor = _: settings: mkSources (mkConfig settings); }
{ __functor = _: settings: mkSources (mkConfig settings); }

View File

@ -2,6 +2,7 @@
#!nix-shell -i bash #!nix-shell -i bash
#!nix-shell -I nixpkgs=./nix #!nix-shell -I nixpkgs=./nix
#!nix-shell -p nix #!nix-shell -p nix
#!nix-shell -p nixpkgs-fmt
#!nix-shell --pure #!nix-shell --pure
unset NIX_SSL_CERT_FILE unset NIX_SSL_CERT_FILE
@ -32,4 +33,11 @@ fi
# Build and create a root # Build and create a root
nix-build ${nixargs[@]} nix-build ${nixargs[@]}
echo "Formatting"
if ! nixpkgs-fmt --check . ; then
echo
echo 'run `nixpkgs-fmt .` to fix this issue'
exit 1
fi
echo "all good" echo "all good"

View File

@ -144,6 +144,7 @@ data SourcesNixVersion
| V11 | V11
| V12 | V12
| V13 | V13
| V14
deriving stock (Bounded, Enum, Eq) deriving stock (Bounded, Enum, Eq)
-- | A user friendly version -- | A user friendly version
@ -162,6 +163,7 @@ sourcesVersionToText = \case
V11 -> "11" V11 -> "11"
V12 -> "12" V12 -> "12"
V13 -> "13" V13 -> "13"
V14 -> "14"
latestVersionMD5 :: T.Text latestVersionMD5 :: T.Text
latestVersionMD5 = sourcesVersionToMD5 maxBound latestVersionMD5 = sourcesVersionToMD5 maxBound
@ -187,6 +189,7 @@ sourcesVersionToMD5 = \case
V11 -> "8a95b7d93b16f7c7515d98f49b0ec741" V11 -> "8a95b7d93b16f7c7515d98f49b0ec741"
V12 -> "2f9629ad9a8f181ed71d2a59b454970c" V12 -> "2f9629ad9a8f181ed71d2a59b454970c"
V13 -> "5e23c56b92eaade4e664cb16dcac1e0a" V13 -> "5e23c56b92eaade4e664cb16dcac1e0a"
V14 -> "b470e235e7bcbf106d243fea90b6cfc9"
-- | The MD5 sum of ./nix/sources.nix -- | The MD5 sum of ./nix/sources.nix
sourcesNixMD5 :: IO T.Text sourcesNixMD5 :: IO T.Text

View File

@ -12,8 +12,7 @@ pkgs.runCommand "git-test"
export NIX_STATE_DIR=$TMPDIR export NIX_STATE_DIR=$TMPDIR
export NIX_LOG_DIR=$TMPDIR export NIX_LOG_DIR=$TMPDIR
export HOME=$TMPDIR export HOME=$TMPDIR
'' + '' + # First we create a dummy git repo with one commit on master, and one commit
# First we create a dummy git repo with one commit on master, and one commit
# on "branch". # on "branch".
'' ''
gitdir=$(mktemp -d) gitdir=$(mktemp -d)
@ -35,9 +34,7 @@ pkgs.runCommand "git-test"
# reset to master as "default branch" # reset to master as "default branch"
git checkout master git checkout master
popd > /dev/null popd > /dev/null
'' + '' + # Then we `niv add` that repo and check some properties, like the revision
# Then we `niv add` that repo and check some properties, like the revision
# and revCount, to make sure it was imported properly, and that sources.nix # and revCount, to make sure it was imported properly, and that sources.nix
# does what it's supposed to do. # does what it's supposed to do.
'' ''
@ -78,4 +75,3 @@ pkgs.runCommand "git-test"
touch $out touch $out
'' ''
) )