Skip to content

Commit

Permalink
Replace nixpkgs-fmt with nixfmt-rfc-style
Browse files Browse the repository at this point in the history
  • Loading branch information
kachick committed May 9, 2024
1 parent 9b45b9b commit 1420cfb
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"nix.serverSettings": {
"nil": {
"formatting": {
"command": ["nixpkgs-fmt"]
"command": ["nixfmt"]
}
}
},
Expand Down
5 changes: 3 additions & 2 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ description = "Run formatters with changes"
script = [
"dprint fmt",
"typos . .github .vscode --write-changes",
"git ls-files '*.nix' | xargs nix fmt",
]

[tasks.lint]
Expand All @@ -25,6 +26,7 @@ script = [
"typos . .github .vscode",
"actionlint",
"gitleaks detect",
"git ls-files '*.nix' | xargs nixfmt --check",
]

[tasks.test]
Expand Down Expand Up @@ -70,8 +72,7 @@ script = [
"deno --version",
"makers --version",
"dprint --version",
# Returns NON 0, why...? :<
# "nixpkgs-fmt --version",
"nixfmt --version",
"actionlint --version",
"typos --version",
"gh --version",
Expand Down
62 changes: 40 additions & 22 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,30 @@
flake-utils.url = "github:numtide/flake-utils";
};

outputs = { self, nixpkgs, edge-nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
outputs =
{
self,
nixpkgs,
edge-nixpkgs,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
edge-pkgs = edge-nixpkgs.legacyPackages.${system};
in
{
devShells.default = with pkgs;
formatter = edge-pkgs.nixfmt-rfc-style;
devShells.default =
with pkgs;
mkShell {
buildInputs = [
# For Nix environments
# https://github.com/NixOS/nix/issues/730#issuecomment-162323824
bashInteractive
nil
nixpkgs-fmt
edge-pkgs.nixfmt-rfc-style

cargo-make
sd
Expand All @@ -50,26 +59,35 @@
apps = {
bump-nix-dependencies = {
type = "app";
program = with pkgs; lib.getExe (writeShellApplication {
name = "bump-nix-dependencies.bash";
runtimeInputs = [ nix git sd edge-pkgs.nodejs_20 edge-pkgs.nodejs_20.pkgs.pnpm ];
# Why --really-refresh?: https://stackoverflow.com/q/34807971
text = ''
set -x
program =
with pkgs;
lib.getExe (writeShellApplication {
name = "bump-nix-dependencies.bash";
runtimeInputs = [
nix
git
sd
edge-pkgs.nodejs_20
edge-pkgs.nodejs_20.pkgs.pnpm
];
# Why --really-refresh?: https://stackoverflow.com/q/34807971
text = ''
set -x
node --version | sd '^v?' "" > .node-version && git add .node-version
git update-index -q --really-refresh
git diff-index --quiet HEAD || git commit -m 'Sync .node-version with nixpkgs' .node-version
node --version | sd '^v?' "" > .node-version && git add .node-version
git update-index -q --really-refresh
git diff-index --quiet HEAD || git commit -m 'Sync .node-version with nixpkgs' .node-version
sd '("packageManager": "pnpm)@([0-9\.]+)' "\$1@$(pnpm --version)" package.json && git add package.json
git update-index -q --really-refresh
git diff-index --quiet HEAD || git commit -m 'Sync pnpm version with nixpkgs' package.json
'';
meta = {
description = "Bump dependency versions except managed by node package manager";
};
});
sd '("packageManager": "pnpm)@([0-9\.]+)' "\$1@$(pnpm --version)" package.json && git add package.json
git update-index -q --really-refresh
git diff-index --quiet HEAD || git commit -m 'Sync pnpm version with nixpkgs' package.json
'';
meta = {
description = "Bump dependency versions except managed by node package manager";
};
});
};
};
});
}
);
}

0 comments on commit 1420cfb

Please sign in to comment.