flake: rewrite to use flake-parts
This commit is contained in:
parent
728a071b52
commit
50debb5dec
21 changed files with 445 additions and 760 deletions
|
@ -1,6 +1,24 @@
|
|||
{ self, inputs, ... }:
|
||||
{ self, lib, ... }:
|
||||
|
||||
{
|
||||
exportedModules = [
|
||||
./devos.nix
|
||||
];
|
||||
perSystem = { pkgs, ... }: {
|
||||
devshells.default =
|
||||
let
|
||||
pythonEnv = (pkgs.python310.withPackages (p: with p; [
|
||||
pkgs.qtile.passthru.unwrapped
|
||||
]));
|
||||
in
|
||||
{
|
||||
devshell.packages = [
|
||||
pythonEnv
|
||||
];
|
||||
|
||||
env = [
|
||||
{
|
||||
name = "PYTHONPATH";
|
||||
value = "${pythonEnv}/${pythonEnv.sitePackages}";
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,67 +0,0 @@
|
|||
{ pkgs, extraModulesPath, inputs, ... }:
|
||||
let
|
||||
|
||||
hooks = import ./hooks;
|
||||
|
||||
pkgWithCategory = category: package: { inherit package category; };
|
||||
linter = pkgWithCategory "linter";
|
||||
docs = pkgWithCategory "docs";
|
||||
devos = pkgWithCategory "devos";
|
||||
|
||||
pythonEnv = pkgs.python310.withPackages (p: with p; [
|
||||
pkgs.qtile.passthru.unwrapped
|
||||
]);
|
||||
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
|
||||
'');
|
||||
|
||||
devshell.packages = [
|
||||
pythonEnv
|
||||
];
|
||||
|
||||
commands = with pkgs; [
|
||||
(devos nixUnstable)
|
||||
(devos agenix)
|
||||
{
|
||||
category = "devos";
|
||||
name = pkgs.nvfetcher.pname;
|
||||
help = pkgs.nvfetcher.meta.description;
|
||||
command = "cd $PRJ_ROOT/pkgs; ${pkgs.nvfetcher}/bin/nvfetcher -c ./sources.toml $@";
|
||||
}
|
||||
(linter nixpkgs-fmt)
|
||||
(linter editorconfig-checker)
|
||||
# (docs python3Packages.grip) too many deps
|
||||
(docs mdbook)
|
||||
]
|
||||
|
||||
++ lib.optional
|
||||
(system != "i686-linux")
|
||||
(devos cachix)
|
||||
|
||||
;
|
||||
|
||||
env = [
|
||||
{
|
||||
name = "PYTHONPATH";
|
||||
value = "${pythonEnv}/${pythonEnv.sitePackages}";
|
||||
}
|
||||
];
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
{
|
||||
enable = true;
|
||||
pre-commit.text = builtins.readFile ./pre-commit.sh;
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
#!/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