forked from pub-solar/os
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
f6062d0019
commit
24b8b9f060
|
@ -1,13 +1,16 @@
|
||||||
{ 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
|
# Core unix utility packages
|
||||||
coreutils-full
|
coreutils-full
|
||||||
dnsutils
|
dnsutils
|
||||||
|
@ -34,7 +37,6 @@ in
|
||||||
croc
|
croc
|
||||||
jq
|
jq
|
||||||
]
|
]
|
||||||
|
|
||||||
++ lib.optionals (!cfg.lite) [
|
++ lib.optionals (!cfg.lite) [
|
||||||
mtr
|
mtr
|
||||||
|
|
||||||
|
@ -58,6 +60,7 @@ in
|
||||||
exfat
|
exfat
|
||||||
|
|
||||||
# Nix specific utilities
|
# Nix specific utilities
|
||||||
|
alejandra
|
||||||
niv
|
niv
|
||||||
manix
|
manix
|
||||||
nix-index
|
nix-index
|
||||||
|
|
|
@ -1,36 +1,37 @@
|
||||||
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
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
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 (channels.latest.haskell.packages."ghc${version}")
|
inherit
|
||||||
haskell-language-server;
|
(channels.latest.haskell.packages."ghc${version}")
|
||||||
|
haskell-language-server
|
||||||
|
;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -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";
|
||||||
|
@ -37,8 +48,12 @@ in
|
||||||
help = pkgs.nvfetcher.meta.description;
|
help = pkgs.nvfetcher.meta.description;
|
||||||
command = "cd $PRJ_ROOT/pkgs; ${pkgs.nvfetcher}/bin/nvfetcher -c ./sources.toml $@";
|
command = "cd $PRJ_ROOT/pkgs; ${pkgs.nvfetcher}/bin/nvfetcher -c ./sources.toml $@";
|
||||||
}
|
}
|
||||||
(linter nixpkgs-fmt)
|
(linter alejandra)
|
||||||
(linter editorconfig-checker)
|
(linter editorconfig-checker)
|
||||||
|
(linter nodePackages.prettier)
|
||||||
|
(linter shfmt)
|
||||||
|
(linter shellcheck)
|
||||||
|
(linter treefmt)
|
||||||
|
|
||||||
(docs mdbook)
|
(docs mdbook)
|
||||||
]
|
]
|
||||||
|
@ -48,6 +63,5 @@ in
|
||||||
++ 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,7 +1,6 @@
|
||||||
#!/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
|
||||||
|
@ -10,23 +9,20 @@ fi
|
||||||
|
|
||||||
diff="git diff-index --name-only --cached $against --diff-filter d"
|
diff="git diff-index --name-only --cached $against --diff-filter d"
|
||||||
|
|
||||||
nix_files=($($diff -- '*.nix'))
|
|
||||||
all_files=($($diff))
|
all_files=($($diff))
|
||||||
|
|
||||||
# Format staged nix files.
|
# Format staged files.
|
||||||
if (( ${#nix_files[@]} != 0 )); then
|
if ((${#all_files[@]} != 0)); then
|
||||||
nixpkgs-fmt "${nix_files[@]}" \
|
treefmt "${all_files[@]}" &&
|
||||||
&& git add "${nix_files[@]}"
|
git add "${all_files[@]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# check editorconfig
|
# check editorconfig
|
||||||
if (( ${#all_files[@]} != 0 )); then
|
if ((${#all_files[@]} != 0)); then
|
||||||
editorconfig-checker -- "${all_files[@]}"
|
if ! editorconfig-checker -- "${all_files[@]}"; then
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ $? != '0' ]]; then
|
|
||||||
printf "%b\n" \
|
printf "%b\n" \
|
||||||
"\nCode is not aligned with .editorconfig" \
|
"\nCode is not aligned with .editorconfig" \
|
||||||
"Review the output and commit your fixes" >&2
|
"Review the output and commit your fixes" >&2
|
||||||
exit 1
|
exit 1
|
||||||
|
fi
|
||||||
fi
|
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