A new start
This commit is contained in:
commit
72271e8cae
78 changed files with 2472 additions and 0 deletions
10
shell/default.nix
Normal file
10
shell/default.nix
Normal file
|
@ -0,0 +1,10 @@
|
|||
{ self, inputs, ... }:
|
||||
{
|
||||
externalModules = with inputs; [
|
||||
bud.devshellModules.bud
|
||||
];
|
||||
modules = [
|
||||
./devos.nix
|
||||
];
|
||||
}
|
||||
|
62
shell/devos.nix
Normal file
62
shell/devos.nix
Normal file
|
@ -0,0 +1,62 @@
|
|||
{ pkgs, extraModulesPath, ... }:
|
||||
let
|
||||
|
||||
hooks = import ./hooks;
|
||||
|
||||
pkgWithCategory = category: package: { inherit package category; };
|
||||
linter = pkgWithCategory "linter";
|
||||
docs = pkgWithCategory "docs";
|
||||
devos = pkgWithCategory "devos";
|
||||
|
||||
in
|
||||
{
|
||||
_file = toString ./.;
|
||||
|
||||
imports = [ "${extraModulesPath}/git/hooks.nix" ];
|
||||
git = { inherit hooks; };
|
||||
|
||||
# tempfix: remove when merged https://github.com/numtide/devshell/pull/123
|
||||
devshell.startup.load_profiles = pkgs.lib.mkForce (
|
||||
pkgs.lib.noDepEntry ''
|
||||
# PATH is devshell's exorbitant privilige:
|
||||
# fence against its pollution
|
||||
_PATH=''${PATH}
|
||||
# Load installed profiles
|
||||
for file in "$DEVSHELL_DIR/etc/profile.d/"*.sh; do
|
||||
# If that folder doesn't exist, bash loves to return the whole glob
|
||||
[[ -f "$file" ]] && source "$file"
|
||||
done
|
||||
# Exert exorbitant privilige and leave no trace
|
||||
export PATH=''${_PATH}
|
||||
unset _PATH
|
||||
''
|
||||
);
|
||||
|
||||
packages = with pkgs; [
|
||||
git-crypt
|
||||
];
|
||||
|
||||
commands = with pkgs; [
|
||||
(devos nixUnstable)
|
||||
{
|
||||
category = "devos";
|
||||
name = nvfetcher-bin.pname;
|
||||
help = nvfetcher-bin.meta.description;
|
||||
command = "cd $DEVSHELL_ROOT/pkgs; ${pkgs.nvfetcher-bin}/bin/nvfetcher -c ./sources.toml --no-output $@";
|
||||
}
|
||||
(linter nixpkgs-fmt)
|
||||
(linter editorconfig-checker)
|
||||
# (docs python3Packages.grip) too many deps
|
||||
(docs mdbook)
|
||||
]
|
||||
|
||||
++ lib.optional
|
||||
(pkgs ? deploy-rs)
|
||||
(devos deploy-rs.deploy-rs)
|
||||
|
||||
++ lib.optional
|
||||
(system != "i686-linux")
|
||||
(devos cachix)
|
||||
|
||||
;
|
||||
}
|
4
shell/hooks/default.nix
Normal file
4
shell/hooks/default.nix
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
enable = true;
|
||||
pre-commit.text = builtins.readFile ./pre-commit.sh;
|
||||
}
|
29
shell/hooks/pre-commit.sh
Executable file
29
shell/hooks/pre-commit.sh
Executable file
|
@ -0,0 +1,29 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
if git rev-parse --verify HEAD >/dev/null 2>&1
|
||||
then
|
||||
against=HEAD
|
||||
else
|
||||
# Initial commit: diff against an empty tree object
|
||||
against=$(${git}/bin/git hash-object -t tree /dev/null)
|
||||
fi
|
||||
|
||||
diff="git diff-index --name-only --cached $against --diff-filter d"
|
||||
|
||||
nix_files=($($diff -- '*.nix'))
|
||||
all_files=($($diff))
|
||||
|
||||
# Format staged nix files.
|
||||
if [[ -n "${nix_files[@]}" ]]; then
|
||||
nixpkgs-fmt "${nix_files[@]}" \
|
||||
&& git add "${nix_files[@]}"
|
||||
fi
|
||||
|
||||
# check editorconfig
|
||||
editorconfig-checker -- "${all_files[@]}"
|
||||
if [[ $? != '0' ]]; then
|
||||
printf "%b\n" \
|
||||
"\nCode is not aligned with .editorconfig" \
|
||||
"Review the output and commit your fixes" >&2
|
||||
exit 1
|
||||
fi
|
Loading…
Add table
Add a link
Reference in a new issue