Switch to alejandra for formatting
Use treefmt For context, see upstream PR: https://github.com/divnix/digga/pull/491
This commit is contained in:
parent
ab603a9708
commit
5ad5c9bae6
|
@ -1,75 +1,78 @@
|
||||||
{ config, pkgs, lib, ... }:
|
{
|
||||||
|
config,
|
||||||
with lib;
|
pkgs,
|
||||||
let
|
lib,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
with lib; let
|
||||||
psCfg = config.pub-solar;
|
psCfg = config.pub-solar;
|
||||||
cfg = config.pub-solar.core;
|
cfg = config.pub-solar.core;
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
environment = {
|
environment = {
|
||||||
systemPackages = with pkgs; [
|
systemPackages = with pkgs;
|
||||||
# Core unix utility packages
|
[
|
||||||
coreutils-full
|
# Core unix utility packages
|
||||||
dnsutils
|
coreutils-full
|
||||||
inetutils
|
dnsutils
|
||||||
progress
|
inetutils
|
||||||
pciutils
|
progress
|
||||||
usbutils
|
pciutils
|
||||||
|
usbutils
|
||||||
|
|
||||||
wget
|
wget
|
||||||
openssl
|
openssl
|
||||||
openssh
|
openssh
|
||||||
curl
|
curl
|
||||||
htop
|
htop
|
||||||
lsof
|
lsof
|
||||||
psmisc
|
psmisc
|
||||||
file
|
file
|
||||||
|
|
||||||
# zippit
|
# zippit
|
||||||
zip
|
zip
|
||||||
unzip
|
unzip
|
||||||
|
|
||||||
# Modern modern utilities
|
# Modern modern utilities
|
||||||
p7zip
|
p7zip
|
||||||
croc
|
croc
|
||||||
jq
|
jq
|
||||||
]
|
]
|
||||||
|
++ lib.optionals (!cfg.lite) [
|
||||||
|
mtr
|
||||||
|
|
||||||
++ lib.optionals (!cfg.lite) [
|
gitFull
|
||||||
mtr
|
git-lfs
|
||||||
|
git-bug
|
||||||
|
|
||||||
gitFull
|
xdg-utils
|
||||||
git-lfs
|
sysfsutils
|
||||||
git-bug
|
renameutils
|
||||||
|
nfs-utils
|
||||||
|
moreutils
|
||||||
|
mailutils
|
||||||
|
keyutils
|
||||||
|
input-utils
|
||||||
|
elfutils
|
||||||
|
binutils
|
||||||
|
dateutils
|
||||||
|
diffutils
|
||||||
|
findutils
|
||||||
|
exfat
|
||||||
|
|
||||||
xdg-utils
|
# Nix specific utilities
|
||||||
sysfsutils
|
alejandra
|
||||||
renameutils
|
niv
|
||||||
nfs-utils
|
manix
|
||||||
moreutils
|
nix-index
|
||||||
mailutils
|
nix-tree
|
||||||
keyutils
|
nixpkgs-review
|
||||||
input-utils
|
# Build broken, python2.7-PyJWT-2.0.1.drv' failed
|
||||||
elfutils
|
#nixops
|
||||||
binutils
|
psos
|
||||||
dateutils
|
nvd
|
||||||
diffutils
|
|
||||||
findutils
|
|
||||||
exfat
|
|
||||||
|
|
||||||
# Nix specific utilities
|
# Fun
|
||||||
niv
|
neofetch
|
||||||
manix
|
];
|
||||||
nix-index
|
|
||||||
nix-tree
|
|
||||||
nixpkgs-review
|
|
||||||
# Build broken, python2.7-PyJWT-2.0.1.drv' failed
|
|
||||||
#nixops
|
|
||||||
psos
|
|
||||||
nvd
|
|
||||||
|
|
||||||
# Fun
|
|
||||||
neofetch
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,25 +1,23 @@
|
||||||
channels: final: prev: {
|
channels: final: prev: {
|
||||||
|
|
||||||
__dontExport = true; # overrides clutter up actual creations
|
__dontExport = true; # overrides clutter up actual creations
|
||||||
|
|
||||||
inherit (channels.latest)
|
inherit
|
||||||
|
(channels.latest)
|
||||||
cachix
|
cachix
|
||||||
dhall
|
dhall
|
||||||
discord
|
discord
|
||||||
element-desktop
|
element-desktop
|
||||||
rage
|
rage
|
||||||
nix-index
|
nix-index
|
||||||
nixpkgs-fmt
|
|
||||||
qutebrowser
|
qutebrowser
|
||||||
|
alejandra
|
||||||
signal-desktop
|
signal-desktop
|
||||||
starship
|
starship
|
||||||
deploy-rs
|
deploy-rs
|
||||||
nix
|
nix
|
||||||
|
|
||||||
tdesktop
|
tdesktop
|
||||||
arduino
|
arduino
|
||||||
arduino-cli
|
arduino-cli
|
||||||
|
|
||||||
gurk-rs
|
gurk-rs
|
||||||
thunderbird
|
thunderbird
|
||||||
swaynotificationcenter
|
swaynotificationcenter
|
||||||
|
@ -32,16 +30,18 @@ channels: final: prev: {
|
||||||
#inherit (channels.fork)
|
#inherit (channels.fork)
|
||||||
# ;
|
# ;
|
||||||
|
|
||||||
haskellPackages = prev.haskellPackages.override
|
haskellPackages =
|
||||||
|
prev.haskellPackages.override
|
||||||
(old: {
|
(old: {
|
||||||
overrides = prev.lib.composeExtensions (old.overrides or (_: _: { })) (hfinal: hprev:
|
overrides = prev.lib.composeExtensions (old.overrides or (_: _: {})) (hfinal: hprev: let
|
||||||
let version = prev.lib.replaceChars [ "." ] [ "" ] prev.ghc.version;
|
version = prev.lib.replaceChars ["."] [""] prev.ghc.version;
|
||||||
in
|
in {
|
||||||
{
|
# same for haskell packages, matching ghc versions
|
||||||
# same for haskell packages, matching ghc versions
|
inherit
|
||||||
inherit (channels.latest.haskell.packages."ghc${version}")
|
(channels.latest.haskell.packages."ghc${version}")
|
||||||
haskell-language-server;
|
haskell-language-server
|
||||||
});
|
;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
# Example to override node package
|
# Example to override node package
|
||||||
|
|
|
@ -1,29 +1,40 @@
|
||||||
{ pkgs, extraModulesPath, inputs, lib, ... }:
|
{
|
||||||
let
|
pkgs,
|
||||||
|
extraModulesPath,
|
||||||
inherit (pkgs)
|
inputs,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
inherit
|
||||||
|
(pkgs)
|
||||||
agenix
|
agenix
|
||||||
cachix
|
cachix
|
||||||
editorconfig-checker
|
editorconfig-checker
|
||||||
mdbook
|
mdbook
|
||||||
nix
|
nix
|
||||||
nixpkgs-fmt
|
alejandra
|
||||||
nvfetcher
|
nvfetcher
|
||||||
|
shellcheck
|
||||||
|
shfmt
|
||||||
|
treefmt
|
||||||
|
;
|
||||||
|
|
||||||
|
inherit
|
||||||
|
(pkgs.nodePackages)
|
||||||
|
prettier
|
||||||
;
|
;
|
||||||
|
|
||||||
hooks = import ./hooks;
|
hooks = import ./hooks;
|
||||||
|
|
||||||
pkgWithCategory = category: package: { inherit package category; };
|
pkgWithCategory = category: package: {inherit package category;};
|
||||||
devos = pkgWithCategory "devos";
|
devos = pkgWithCategory "devos";
|
||||||
linter = pkgWithCategory "linter";
|
linter = pkgWithCategory "linter";
|
||||||
docs = pkgWithCategory "docs";
|
docs = pkgWithCategory "docs";
|
||||||
|
in {
|
||||||
in
|
|
||||||
{
|
|
||||||
_file = toString ./.;
|
_file = toString ./.;
|
||||||
|
|
||||||
imports = [ "${extraModulesPath}/git/hooks.nix" ];
|
imports = ["${extraModulesPath}/git/hooks.nix"];
|
||||||
git = { inherit hooks; };
|
git = {inherit hooks;};
|
||||||
|
|
||||||
# override for our own welcome
|
# override for our own welcome
|
||||||
devshell.name = pkgs.lib.mkForce "PubSolarOS";
|
devshell.name = pkgs.lib.mkForce "PubSolarOS";
|
||||||
|
@ -43,26 +54,30 @@ in
|
||||||
unset _PATH
|
unset _PATH
|
||||||
'');
|
'');
|
||||||
|
|
||||||
commands = with pkgs; [
|
commands = with pkgs;
|
||||||
(devos nix)
|
[
|
||||||
(devos agenix)
|
(devos nix)
|
||||||
{
|
(devos agenix)
|
||||||
category = "devos";
|
{
|
||||||
name = pkgs.nvfetcher.pname;
|
category = "devos";
|
||||||
help = pkgs.nvfetcher.meta.description;
|
name = pkgs.nvfetcher.pname;
|
||||||
command = "cd $PRJ_ROOT/pkgs; ${pkgs.nvfetcher}/bin/nvfetcher -c ./sources.toml $@";
|
help = pkgs.nvfetcher.meta.description;
|
||||||
}
|
command = "cd $PRJ_ROOT/pkgs; ${pkgs.nvfetcher}/bin/nvfetcher -c ./sources.toml $@";
|
||||||
(linter nixpkgs-fmt)
|
}
|
||||||
(linter editorconfig-checker)
|
(linter alejandra)
|
||||||
|
(linter editorconfig-checker)
|
||||||
|
(linter nodePackages.prettier)
|
||||||
|
(linter shfmt)
|
||||||
|
(linter shellcheck)
|
||||||
|
(linter treefmt)
|
||||||
|
|
||||||
(docs mdbook)
|
(docs mdbook)
|
||||||
]
|
]
|
||||||
++ lib.optionals (!pkgs.stdenv.buildPlatform.isi686) [
|
++ lib.optionals (!pkgs.stdenv.buildPlatform.isi686) [
|
||||||
(devos cachix)
|
(devos cachix)
|
||||||
]
|
]
|
||||||
++ lib.optionals (pkgs.stdenv.hostPlatform.isLinux && !pkgs.stdenv.buildPlatform.isDarwin) [
|
++ lib.optionals (pkgs.stdenv.hostPlatform.isLinux && !pkgs.stdenv.buildPlatform.isDarwin) [
|
||||||
(devos inputs.nixos-generators.defaultPackage.${pkgs.system})
|
(devos inputs.nixos-generators.defaultPackage.${pkgs.system})
|
||||||
(devos deploy-rs)
|
(devos deploy-rs)
|
||||||
]
|
];
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,43 +1,28 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
if git rev-parse --verify HEAD >/dev/null 2>&1
|
if git rev-parse --verify HEAD >/dev/null 2>&1; then
|
||||||
then
|
|
||||||
against=HEAD
|
against=HEAD
|
||||||
else
|
else
|
||||||
# Initial commit: diff against an empty tree object
|
# Initial commit: diff against an empty tree object
|
||||||
against=$(git hash-object -t tree /dev/null)
|
against=$(${git}/bin/git hash-object -t tree /dev/null)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
diff="git diff-index --name-only --cached $against --diff-filter d"
|
diff="git diff-index --name-only --cached $against --diff-filter d"
|
||||||
|
|
||||||
mapfile -t nix_files < <($diff -- '*.nix')
|
all_files=($($diff))
|
||||||
mapfile -t all_files < <($diff)
|
|
||||||
|
|
||||||
# Format staged nix files
|
# Format staged files.
|
||||||
if (( ${#nix_files[@]} != 0 )); then
|
if ((${#all_files[@]} != 0)); then
|
||||||
# Stash only unstaged changes, keeping staged changes
|
treefmt "${all_files[@]}" &&
|
||||||
old_stash=$(git rev-parse --quiet --verify refs/stash)
|
git add "${all_files[@]}"
|
||||||
git stash push --quiet --keep-index -m 'Unstaged changes before pre-commit hook'
|
fi
|
||||||
new_stash=$(git rev-parse --quiet --verify refs/stash)
|
|
||||||
|
|
||||||
# Format staged changes
|
# check editorconfig
|
||||||
nixpkgs-fmt "${nix_files[@]}" \
|
if ((${#all_files[@]} != 0)); then
|
||||||
&& git add "${nix_files[@]}"
|
if ! editorconfig-checker -- "${all_files[@]}"; then
|
||||||
|
printf "%b\n" \
|
||||||
# If unstaged changes were stashed re-apply to working tree
|
"\nCode is not aligned with .editorconfig" \
|
||||||
if [ "$old_stash" != "$new_stash" ]; then
|
"Review the output and commit your fixes" >&2
|
||||||
git stash pop --quiet
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check editorconfig
|
|
||||||
if (( ${#all_files[@]} != 0 )); then
|
|
||||||
editorconfig-checker -- "${all_files[@]}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ $? != '0' ]]; then
|
|
||||||
printf "%b\n" \
|
|
||||||
"\nCode is not aligned with .editorconfig" \
|
|
||||||
"Review the output and commit your fixes" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
22
treefmt.toml
Normal file
22
treefmt.toml
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
[formatter.nix]
|
||||||
|
command = "alejandra"
|
||||||
|
includes = ["*.nix"]
|
||||||
|
|
||||||
|
[formatter.prettier]
|
||||||
|
command = "prettier"
|
||||||
|
options = ["--write"]
|
||||||
|
includes = [
|
||||||
|
"*.json",
|
||||||
|
"*.yaml",
|
||||||
|
"*.md",
|
||||||
|
]
|
||||||
|
|
||||||
|
[formatter.shell]
|
||||||
|
command = "shfmt"
|
||||||
|
options = [
|
||||||
|
"-s",
|
||||||
|
"-w",
|
||||||
|
"-i",
|
||||||
|
"2",
|
||||||
|
]
|
||||||
|
includes = ["*.sh"]
|
Loading…
Reference in a new issue