Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion examples/build.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ _:
{
imports =
[
./pre-commit.nix
./haskell-flake-project/build.nix
./rust-flake-project/build.nix
./typescript-flake-project/build.nix
Expand Down
15 changes: 0 additions & 15 deletions examples/pre-commit.nix

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@
},
"author": "Jared Pon",
"license": "ISC",
"files":
[ "./dist/**/*"
, "./.extra-dependencies/**/*"
],
"files": ["./dist/**/*", "./.extra-dependencies/**/*"],
"dependencies": {
"typescript": "^5.3.3",
"typescript-flake-project": "file:.extra-dependencies/typescript-flake-project-1.0.0.tgz"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as TsFlakeProject from 'typescript-flake-project'
import * as TsFlakeProject from "typescript-flake-project";

export function helloWorld() {
TsFlakeProject.helloWorld();
TsFlakeProject.helloWorld();
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import * as TsFlakeProject from 'typescript-flake-project'
import * as TsFlakeProject from "typescript-flake-project";

export function helloWorld() {
TsFlakeProject.helloWorld();
TsFlakeProject.helloWorld();
}



helloWorld();
5 changes: 1 addition & 4 deletions examples/typescript-flake-project/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@
},
"author": "Jared Pon",
"license": "ISC",
"files":
[ "./dist/**/*"
, "./.extra-dependencies/**/*"
],
"files": ["./dist/**/*", "./.extra-dependencies/**/*"],
"dependencies": {
"typescript": "^5.3.3"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/typescript-flake-project/src/MyLib/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export function helloWorld() {
console.log("Hello world!");
console.log("Hello world!");
}
39 changes: 23 additions & 16 deletions flake-lang/build.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
# typescriptFlake = ...
# ...
# };
# flakeModule = {
# rustMonorepoPreCommit = ...
# };
# ```
# This is unfortunately not super easy to do with flake-parts! Some useful
# links + examples are as follows.
Expand All @@ -16,11 +19,31 @@
{ config, inputs, flake-parts-lib, lib, ... }: {
options = {
flake = flake-parts-lib.mkSubmoduleOptions {
# Expose attributes which are generated by the `perSystem` `lib` options
# e.g. it gives an option for things like
# ```
# lib.<system>.haskellFlake = ..
# ```
lib = lib.mkOption {
type = lib.types.lazyAttrsOf (lib.types.lazyAttrsOf (lib.types.functionTo lib.types.attrs));
default = { };
visible = false;
};

# Expose attributes like
# ```
# flakeModule.rustMonorepoPreCommit = ..
# ```
flakeModule = {
rustMonorepoPreCommit = lib.mkOption {
type = lib.types.lazyAttrsOf lib.types.unspecified;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be a flakeModule type if there is such a thing?

default = ./pre-commit-hooks/rust-monorepo.nix;
readOnly = true;
description = lib.mdDoc ''pre-commit-hooks.nix hook for Rust in a monorepo setting'';
example = lib.mdDoc ''TODO(bladyjoker)'';
};

};
};
perSystem = flake-parts-lib.mkPerSystemOption ({ pkgs, pkgsForCtl, pkgsForHaskellNix, pkgsForRust, ... }: {
options = {
Expand Down Expand Up @@ -81,22 +104,6 @@
example = lib.mdDoc ''TODO(jaredponn)'';
};

rustMonorepoPreCommit = lib.mkOption {
type = lib.types.flakeModule;
default = ./pre-commit-hooks/rust-monorepo.nix;
readOnly = true;
description = lib.mdDoc ''pre-commit-hooks.nix hook for Rust in a monorepo setting'';
example = lib.mdDoc ''TODO(bladyjoker)'';
};

denoPreCommit = lib.mkOption {
type = lib.types.flakeModule;
default = ./pre-commit-hooks/deno.nix;
readOnly = true;
description = lib.mdDoc ''pre-commit-hooks.nix hook for Deno in a monorepo setting'';
example = lib.mdDoc ''TODO(bladyjoker)'';
};

Comment on lines -92 to -99
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to roll our own deno anymore. They fixed this in the main repo

Copy link
Contributor Author

@jaredponn jaredponn Feb 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although this prompts some discussion. In Rust, it seems we want to export a module which does all the formatting -- do we want to provide this feature for all languages (or none)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what you mean...

AFAIK this is about providing Rust formatting with pre-commit-checks.nix, there were reasons why we had to roll our own. @szg251 any comments?

};
};
});
Expand Down
33 changes: 0 additions & 33 deletions flake-lang/pre-commit-hooks/deno.nix

This file was deleted.

31 changes: 12 additions & 19 deletions flake-lang/pre-commit-hooks/tools.nix
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very lovely, thanks!

Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
{ flake-parts-lib, lib, ... }: {
perSystem = flake-parts-lib.mkPerSystemOption ({ pkgs, pkgsForRust, ... }: {
options = {
flake-lang.pre-commit-hooks.tools = {

rustfmt = lib.mkOption {
type = lib.types.derivation;
default = pkgsForRust.rustfmt;
readOnly = false;
description = lib.mdDoc ''Rust formatter to use for pre-commit hooks'';
options = {
perSystem = flake-parts-lib.mkPerSystemOption ({ pkgsForRust, ... }: {
options = {
flake-lang.pre-commit-hooks.tools = {
rustfmt = lib.mkOption {
type = lib.types.package;
default = pkgsForRust.rustfmt;
readOnly = false;
description = lib.mdDoc ''Rust formatter to use for pre-commit hooks'';
};
};

deno = lib.mkOption {
type = lib.types.derivation;
default = pkgs.deno;
readOnly = false;
description = lib.mdDoc ''Deno tool to use for pre-commit hooks'';
};

};
};
});
});
};
}
14 changes: 14 additions & 0 deletions pre-commit.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{ inputs, ... }: {
imports = [
inputs.pre-commit-hooks.flakeModule
./flake-lang/pre-commit-hooks/rust-monorepo.nix
];
perSystem = { config, ... }: {
devShells.default = config.pre-commit.devShell;
Expand All @@ -20,6 +21,19 @@
cabal-fmt.enable = true;
hlint.enable = true;
fourmolu.enable = true;

# Typescript
denofmt = {
enable = true;
# NOTE(jaredponn): We follow the default files deno formats, except
# we exclude markdown files. See:
# [1] https://docs.deno.com/runtime/manual/tools/formatter
files = ''^.*\.(js|ts|jsx|tsx|json|jsonc)$'';
};
denolint.enable = true;

# Rust
rustfmt-monorepo.enable = true;
};
};
};
Expand Down