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 16, 2024
1 parent 7667a17 commit cfc3da7
Show file tree
Hide file tree
Showing 3 changed files with 31 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 @@ -18,7 +18,7 @@
"nix.serverSettings": {
"nil": {
"formatting": {
"command": ["nixpkgs-fmt"]
"command": ["nixfmt"]
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -142,5 +142,6 @@ task :check_non_ruby do
Rake::Task['dprint'].invoke
sh('typos . .github .vscode')
sh('yamlfmt -lint .')
sh('nixpkgs-fmt --check ./*.nix')
# nix fmt doesn't have check: https://github.com/NixOS/nix/issues/6918
sh("git ls-files '*.nix' | xargs nixfmt --check")
end
51 changes: 28 additions & 23 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,21 @@
flake-utils.url = "github:numtide/flake-utils";
};

outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
outputs =
{
self,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
rec {
devShells.default = with pkgs;
formatter = pkgs.nixfmt-rfc-style;
devShells.default =
with pkgs;
mkShell {
buildInputs = [
# https://github.com/NixOS/nix/issues/730#issuecomment-162323824
Expand All @@ -30,35 +38,31 @@
dprint
tree
nil
nixpkgs-fmt
nixfmt-rfc-style
typos
yamlfmt
];
};

packages.ruby-ulid = pkgs.stdenv.mkDerivation
{
name = "ruby-ulid";
src = self;
installPhase = ''
mkdir -p $out/bin
cp -rf ./lib $out
'';
runtimeDependencies = [
pkgs.ruby_3_3
];
};
packages.ruby-ulid = pkgs.stdenv.mkDerivation {
name = "ruby-ulid";
src = self;
installPhase = ''
mkdir -p $out/bin
cp -rf ./lib $out
'';
runtimeDependencies = [ pkgs.ruby_3_3 ];
};

# `nix run`
apps = {
ruby = {
type = "app";
program = with pkgs; lib.getExe (writeShellApplication
{
program =
with pkgs;
lib.getExe (writeShellApplication {
name = "ruby-with-ulid";
runtimeInputs = [
ruby_3_3
];
runtimeInputs = [ ruby_3_3 ];
text = ''
ruby -r"${packages.ruby-ulid}/lib/ulid" "$@"
'';
Expand All @@ -67,8 +71,9 @@

irb = {
type = "app";
program = with pkgs; lib.getExe (writeShellApplication
{
program =
with pkgs;
lib.getExe (writeShellApplication {
name = "irb-with-ulid";
runtimeInputs = [
ruby_3_3
Expand Down

0 comments on commit cfc3da7

Please sign in to comment.