nix: Add git-hooks to the flake file
This commit is contained in:
parent
45b2a7805b
commit
b59e4ab315
|
@ -31,3 +31,5 @@ docs/spec.pdf
|
|||
.tex
|
||||
.pdf
|
||||
docs/overall_picture.png
|
||||
.direnv/
|
||||
.pre-commit-config.yaml
|
|
@ -1,39 +0,0 @@
|
|||
# Apply to all files without commiting:
|
||||
# pre-commit run --all-files
|
||||
# Update this file:
|
||||
# pre-commit autoupdate
|
||||
fail_fast: false
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v4.3.0
|
||||
hooks:
|
||||
- id: check-added-large-files
|
||||
- id: check-symlinks
|
||||
- id: check-case-conflict
|
||||
- id: check-docstring-first
|
||||
- id: check-executables-have-shebangs
|
||||
- id: forbid-new-submodules
|
||||
- id: end-of-file-fixer
|
||||
- id: trailing-whitespace
|
||||
- id: mixed-line-ending
|
||||
- id: fix-byte-order-marker
|
||||
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: include-fixer py
|
||||
name: Fixing local includes
|
||||
language: python
|
||||
entry: ./scripts/include-fixer.py
|
||||
files: ".*.(h|cpp)"
|
||||
|
||||
- repo: https://github.com/pocc/pre-commit-hooks
|
||||
rev: v1.3.5
|
||||
hooks:
|
||||
- id: clang-format
|
||||
- id: cppcheck
|
||||
args: ['--project=compile_commands.json']
|
||||
- repo: https://github.com/detailyang/pre-commit-shell
|
||||
rev: 1.0.5
|
||||
hooks:
|
||||
- id: shell-lint
|
||||
args: ['-x']
|
127
flake.lock
127
flake.lock
|
@ -1,5 +1,21 @@
|
|||
{
|
||||
"nodes": {
|
||||
"flake-compat": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1696426674,
|
||||
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
|
@ -18,7 +34,100 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils_2": {
|
||||
"inputs": {
|
||||
"systems": "systems_2"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1710146030,
|
||||
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"git-hooks": {
|
||||
"inputs": {
|
||||
"flake-compat": "flake-compat",
|
||||
"flake-utils": "flake-utils_2",
|
||||
"gitignore": "gitignore",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"nixpkgs-stable": "nixpkgs-stable"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1712055707,
|
||||
"narHash": "sha256-4XLvuSIDZJGS17xEwSrNuJLL7UjDYKGJSbK1WWX2AK8=",
|
||||
"owner": "cachix",
|
||||
"repo": "git-hooks.nix",
|
||||
"rev": "e35aed5fda3cc79f88ed7f1795021e559582093a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "cachix",
|
||||
"repo": "git-hooks.nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"gitignore": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"git-hooks",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1709087332,
|
||||
"narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "gitignore.nix",
|
||||
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "hercules-ci",
|
||||
"repo": "gitignore.nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1710765496,
|
||||
"narHash": "sha256-p7ryWEeQfMwTB6E0wIUd5V2cFTgq+DRRBz2hYGnJZyA=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "e367f7a1fb93137af22a3908f00b9a35e2d286a7",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs-stable": {
|
||||
"locked": {
|
||||
"lastModified": 1710695816,
|
||||
"narHash": "sha256-3Eh7fhEID17pv9ZxrPwCLfqXnYP006RKzSs0JptsN84=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "614b4613980a522ba49f0d194531beddbb7220d3",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-23.11",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"dirtyRev": "1681ff1c67b9e337c204178d4cd85c9327e35eff-dirty",
|
||||
"dirtyShortRev": "1681ff1c67b9-dirty",
|
||||
|
@ -35,7 +144,8 @@
|
|||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
"git-hooks": "git-hooks",
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
|
@ -52,6 +162,21 @@
|
|||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems_2": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
|
|
197
flake.nix
197
flake.nix
|
@ -19,9 +19,10 @@
|
|||
#inputs.nixpkgs.url = "github:NixOS/nixpkgs/bcb1a9c7e1d8568c5e58316fe3254eb8f4455439";
|
||||
#inputs.nixpkgs.url = "github:lxsameer/nixpkgs/e1f7865bce4d52d30dd1d61e79798ee2765cc2b0";
|
||||
inputs.nixpkgs.url = "/home/lxsameer/src/nixpkgs/";
|
||||
inputs.git-hooks.url = "github:cachix/git-hooks.nix";
|
||||
inputs.flake-utils.url = "github:numtide/flake-utils";
|
||||
|
||||
outputs = inputs@{ self, nixpkgs, flake-utils, ... }:
|
||||
outputs = { self, nixpkgs, flake-utils, git-hooks, ... }:
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
version = "1.0.0";
|
||||
|
@ -31,11 +32,8 @@
|
|||
# them upstream little by little.
|
||||
overlays = [
|
||||
(final: prev: {
|
||||
p11-kit = prev.p11-kit.overrideAttrs (old: {
|
||||
patches = [
|
||||
./nix/patches/p11-kit_skip_test.patch
|
||||
];
|
||||
});
|
||||
p11-kit = prev.p11-kit.overrideAttrs
|
||||
(old: { patches = [ ./nix/patches/p11-kit_skip_test.patch ]; });
|
||||
|
||||
cpio = prev.cpio.overrideAttrs (old: {
|
||||
nativeBuildInputs = [ prev.autoreconfHook ];
|
||||
|
@ -71,57 +69,65 @@
|
|||
# default in lld-18. We need to explicitly turn it off for
|
||||
# these problematic packages untill they fix it upstream.
|
||||
libgcrypt = prev.libgcrypt.overrideAttrs (old: {
|
||||
NIX_LDFLAGS = if prev.stdenv.cc.isClang
|
||||
then [ "--undefined-version" ]
|
||||
else [];
|
||||
NIX_LDFLAGS = if prev.stdenv.cc.isClang then
|
||||
[ "--undefined-version" ]
|
||||
else
|
||||
[ ];
|
||||
});
|
||||
libxcrypt = prev.libxcrypt.overrideAttrs (old: {
|
||||
NIX_LDFLAGS = if prev.stdenv.cc.isClang
|
||||
then [ "--undefined-version" ]
|
||||
else [];
|
||||
NIX_LDFLAGS = if prev.stdenv.cc.isClang then
|
||||
[ "--undefined-version" ]
|
||||
else
|
||||
[ ];
|
||||
});
|
||||
ncurses = prev.ncurses.overrideAttrs (old: {
|
||||
NIX_LDFLAGS = if prev.stdenv.cc.isClang
|
||||
then [ "--undefined-version" ]
|
||||
else [];
|
||||
NIX_LDFLAGS = if prev.stdenv.cc.isClang then
|
||||
[ "--undefined-version" ]
|
||||
else
|
||||
[ ];
|
||||
});
|
||||
|
||||
libbsd = prev.libbsd.overrideAttrs (old: { #
|
||||
NIX_LDFLAGS = if prev.stdenv.cc.isClang
|
||||
then [ "--undefined-version" ]
|
||||
else [];
|
||||
libbsd = prev.libbsd.overrideAttrs (old: {
|
||||
NIX_LDFLAGS = if prev.stdenv.cc.isClang then
|
||||
[ "--undefined-version" ]
|
||||
else
|
||||
[ ];
|
||||
});
|
||||
|
||||
binutils = prev.binutils.overrideAttrs (old: {
|
||||
NIX_LDFLAGS = [ "-Wl,--undefined-version" ]# if prev.stdenv.cc.isClang
|
||||
# then
|
||||
# else []
|
||||
NIX_LDFLAGS = [
|
||||
"-Wl,--undefined-version"
|
||||
] # if prev.stdenv.cc.isClang
|
||||
# then
|
||||
# else []
|
||||
;
|
||||
});
|
||||
|
||||
libidn2 = prev.libidn2.overrideAttrs (old: { #old.NIX_LDFLAGS ++
|
||||
NIX_LDFLAGS = if prev.stdenv.cc.isClang
|
||||
then [ "--undefined-version" ]
|
||||
else [];
|
||||
libidn2 = prev.libidn2.overrideAttrs (old: {
|
||||
# old.NIX_LDFLAGS ++
|
||||
NIX_LDFLAGS = if prev.stdenv.cc.isClang then
|
||||
[ "--undefined-version" ]
|
||||
else
|
||||
[ ];
|
||||
});
|
||||
|
||||
nghttp2 = prev.nghttp2.overrideAttrs (old: {
|
||||
buildInputs = old.buildInputs ++ [ final.zlib ];
|
||||
});
|
||||
nghttp2 = prev.nghttp2.overrideAttrs
|
||||
(old: { buildInputs = old.buildInputs ++ [ final.zlib ]; });
|
||||
|
||||
#==============================================================
|
||||
|
||||
iwyu = (prev.include-what-you-use.overrideAttrs (old:
|
||||
let
|
||||
version = "0.22";
|
||||
let version = "0.22";
|
||||
in {
|
||||
inherit version;
|
||||
|
||||
src = prev.fetchurl {
|
||||
url = "${old.meta.homepage}/downloads/${old.pname}-${version}.src.tar.gz";
|
||||
url =
|
||||
"${old.meta.homepage}/downloads/${old.pname}-${version}.src.tar.gz";
|
||||
hash = "sha256-hZB0tGHqS4MlpzQYwgfKM7XmVmsI5rWH65FkQWVppt0=";
|
||||
};
|
||||
cmakeFlags = [ "-DCMAKE_PREFIX_PATH=${prev.llvmPackages_18.llvm.dev}" ];
|
||||
cmakeFlags =
|
||||
[ "-DCMAKE_PREFIX_PATH=${prev.llvmPackages_18.llvm.dev}" ];
|
||||
|
||||
})).override {
|
||||
llvmPackages = prev.__splicedPackages.llvmPackages_18;
|
||||
|
@ -129,7 +135,6 @@
|
|||
})
|
||||
];
|
||||
|
||||
|
||||
utils = import ./nix/utils.nix { inherit nixpkgs; };
|
||||
|
||||
# Create a package set based on the build system
|
||||
|
@ -137,10 +142,9 @@
|
|||
hostPkgs = pkgs_set.host;
|
||||
pkgs = pkgs_set.target;
|
||||
|
||||
nativePkgs = import nixpkgs { inherit system overlays; };
|
||||
|
||||
# Create a stdenv based on LLVM
|
||||
stdenv = pkgs.stdenvAdapters.overrideCC pkgs.stdenv pkgs.llvmPackages_18.clangUseLLVM;
|
||||
stdenv = pkgs.stdenvAdapters.overrideCC pkgs.stdenv
|
||||
pkgs.llvmPackages_18.clangUseLLVM;
|
||||
|
||||
gc = pkgs.callPackage ./nix/boehmgc.nix { inherit stdenv; };
|
||||
|
||||
|
@ -161,45 +165,16 @@
|
|||
clang' = stdenv.cc.overrideAttrs (old: {
|
||||
propagatedBuildInputs = [ stdenv.cc.bintools ] ++ [ zlib' ];
|
||||
});
|
||||
llvm = pkgs.llvmPackages_18.llvm.overrideAttrs (old: {
|
||||
propagatedBuildInputs = [ zlib' ];
|
||||
});
|
||||
llvm = pkgs.llvmPackages_18.llvm.overrideAttrs
|
||||
(old: { propagatedBuildInputs = [ zlib' ]; });
|
||||
|
||||
# This is the actual stdenv that we need to use anywhere else
|
||||
stdenv' = pkgs.stdenvAdapters.overrideCC pkgs.stdenv clang';
|
||||
|
||||
# Just disabling the tests that fails under musl
|
||||
git' = pkgs.git.overrideAttrs (old: {
|
||||
preInstallCheck =
|
||||
pkgs.lib.replaceStrings [ ''disable_test t0201-gettext-fallbacks'' ]
|
||||
[ ''
|
||||
disable_test t0201-gettext-fallbacks
|
||||
disable_test t2082-parallel-checkout-attributes
|
||||
'' ]
|
||||
old.preInstallCheck;
|
||||
});
|
||||
nativeBuildToolsDeps = (with hostPkgs; [ cmake ninja ccache ]);
|
||||
|
||||
nativeBuildToolsDeps = (with hostPkgs; [
|
||||
cmake
|
||||
ninja
|
||||
ccache
|
||||
git
|
||||
python3
|
||||
]);
|
||||
|
||||
buildToolsDeps = (with pkgs; [
|
||||
llvm
|
||||
llvmPackages_18.mlir
|
||||
llvmPackages_18.clang
|
||||
iwyu
|
||||
]);
|
||||
|
||||
shellTools = (with pkgs; [
|
||||
zsh
|
||||
zsh-autosuggestions
|
||||
zsh-autocomplete
|
||||
zsh-syntax-highlighting
|
||||
]);
|
||||
buildToolsDeps =
|
||||
(with pkgs; [ llvm llvmPackages_18.mlir llvmPackages_18.clang iwyu ]);
|
||||
|
||||
buildDeps = (with pkgs; [
|
||||
gc
|
||||
|
@ -209,59 +184,17 @@
|
|||
llvmPackages_18.clang
|
||||
]);
|
||||
|
||||
testDeps = (with hostPkgs; [
|
||||
gtest
|
||||
gmock
|
||||
gbenchmark
|
||||
]);
|
||||
|
||||
tex = nativePkgs.texlive.combine {
|
||||
inherit (nativePkgs.texlive)
|
||||
scheme-minimal
|
||||
latex-bin
|
||||
latexmk
|
||||
xelatex-dev
|
||||
sourcesanspro
|
||||
xkeyval
|
||||
etoolbox
|
||||
titlesec
|
||||
fontspec
|
||||
hyperref
|
||||
mfirstuc
|
||||
parskip
|
||||
geometry
|
||||
pdftexcmds
|
||||
infwarerr
|
||||
kvoptions
|
||||
;
|
||||
};
|
||||
|
||||
|
||||
mathDeps = (with nativePkgs; [
|
||||
idris2
|
||||
agda
|
||||
git
|
||||
zsh
|
||||
zsh-autosuggestions
|
||||
zsh-autocomplete
|
||||
zsh-syntax-highlighting
|
||||
tex
|
||||
]);
|
||||
|
||||
testDeps = (with hostPkgs; [ gtest gmock gbenchmark ]);
|
||||
|
||||
in {
|
||||
inherit pkgs;
|
||||
devShells.default = (pkgs.mkShell.override { stdenv = stdenv';}) {
|
||||
nativeBuildInputs = nativeBuildToolsDeps ++ buildToolsDeps ++ shellTools;
|
||||
buildInputs = buildDeps ++ testDeps;
|
||||
CPP_LS = "serene-clangd";
|
||||
};
|
||||
devShells.default = (pkgs.mkShell.override { stdenv = stdenv'; }) {
|
||||
inherit (self.checks.${system}.git-hook-check) shellHook;
|
||||
|
||||
# This shell is gcc based and we use it only
|
||||
# for the mathematics side of our design
|
||||
devShells.math = nativePkgs.mkShell {
|
||||
#nativeBuildInputs = mathDeps;
|
||||
buildInputs = mathDeps;
|
||||
nativeBuildInputs = nativeBuildToolsDeps ++ buildToolsDeps;
|
||||
buildInputs = buildDeps ++ testDeps
|
||||
++ self.checks.${system}.git-hook-check.enabledPackages;
|
||||
CPP_LS = "serene-clangd";
|
||||
};
|
||||
|
||||
packages.devshell = stdenv'.mkDerivation {
|
||||
|
@ -270,9 +203,25 @@
|
|||
|
||||
doUnpack = false;
|
||||
doCheck = false;
|
||||
nativeBuildInputs = nativeBuildToolsDeps ++ buildToolsDeps ++ shellTools;
|
||||
nativeBuildInputs = nativeBuildToolsDeps ++ buildToolsDeps;
|
||||
buildInputs = buildDeps ++ testDeps;
|
||||
} ;
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
checks = {
|
||||
git-hook-check = git-hooks.lib.${system}.run {
|
||||
src = ./.;
|
||||
hooks = {
|
||||
nixfmt.enable = true;
|
||||
clang-format = {
|
||||
enable = true;
|
||||
types_or = hostPkgs.lib.mkForce [ "c" "c++" ];
|
||||
};
|
||||
shellcheck.enable = true;
|
||||
cmake-format.enable = true;
|
||||
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue