Skip to content

Commit 024da4e

Browse files
committed
Introduces statix and nil
1 parent 099ff8a commit 024da4e

File tree

19 files changed

+107
-87
lines changed

19 files changed

+107
-87
lines changed

extras/.envrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use flake .#dev-nix

extras/build.nix

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,17 @@
77
};
88

99
# Makes it available in the system agnostic `lib` argument.
10-
config._module.args.lib = config.flake.lib // {
11-
inherit (config) lbf-nix;
12-
};
10+
config = {
11+
_module.args.lib = config.flake.lib // {
12+
inherit (config) lbf-nix;
13+
};
1314

14-
# Sets the above set option to system ones.
15-
config.lbf-nix = lib.genAttrs config.systems (system: (config.perSystem system).lbf-nix);
15+
# Sets the above set option to system ones.
16+
lbf-nix = lib.genAttrs config.systems (system: (config.perSystem system).lbf-nix);
1617

17-
# Makes `lib.x86_64-linux.xyz` available
18-
config.flake.lib = config.lbf-nix;
18+
# Makes `lib.x86_64-linux.xyz` available
19+
flake.lib = config.lbf-nix;
20+
};
1921

2022
options = {
2123

@@ -30,6 +32,12 @@
3032

3133
# Sets a per system `lbf-nix` option.
3234
config = {
35+
devShells.dev-nix = pkgs.mkShell {
36+
name = "dev-nix";
37+
shellHook = config.settings.shell.hook;
38+
buildInputs = config.settings.shell.tools;
39+
};
40+
3341
lbf-nix = {
3442
# NOTE(bladyjoker): If you need to add a function the export externally and use internally via config.lbf-nix, add it here.
3543

extras/flake-haskell.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ let
4444
hlint = { };
4545
cabal-fmt = { };
4646
fourmolu = { };
47+
weeder = { };
4748
};
4849

4950
shellHook = lib.mkForce devShellHook;

extras/flake-purescript.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ let
3636
};
3737
};
3838

39-
devShell = purs.devShell;
39+
inherit (purs) devShell;
4040
};
4141
in
4242
mkFlake pursProjOpts.projectName (pkgs.purescriptProject pursProjOpts)

extras/flake-rust.nix

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -84,22 +84,26 @@ in
8484
'';
8585
};
8686

87-
packages."${crateName}-rust" = craneLib.buildPackage (commonArgs // {
88-
inherit cargoArtifacts;
89-
doCheck = false;
90-
doInstallCargoArtifacts = true;
91-
});
87+
packages = {
88+
"${crateName}-rust" = craneLib.buildPackage (commonArgs // {
89+
inherit cargoArtifacts;
90+
doCheck = false;
91+
doInstallCargoArtifacts = true;
92+
});
9293

93-
packages."${crateName}-rust-src" = vendoredSrc;
94+
"${crateName}-rust-src" = vendoredSrc;
9495

95-
packages."${crateName}-rust-build-env" = buildEnv;
96+
"${crateName}-rust-build-env" = buildEnv;
97+
};
9698

97-
checks."${crateName}-rust-test" = craneLib.cargoNextest (commonArgs // {
98-
inherit cargoArtifacts;
99-
nativeBuildInputs = testTools;
100-
});
99+
checks = {
100+
"${crateName}-rust-test" = craneLib.cargoNextest (commonArgs // {
101+
inherit cargoArtifacts;
102+
nativeBuildInputs = testTools;
103+
});
101104

102-
checks."${crateName}-rust-clippy" = craneLib.cargoClippy (commonArgs // {
103-
inherit cargoArtifacts;
104-
});
105+
"${crateName}-rust-clippy" = craneLib.cargoClippy (commonArgs // {
106+
inherit cargoArtifacts;
107+
});
108+
};
105109
}

extras/flake-typescript.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ let
146146
'';
147147

148148
node2nixDevelop = node2nixExprs { extraFlags = [ "--development" ]; };
149-
node2nixDevelopAttrs = ((import node2nixDevelop) { inherit nodejs pkgs; inherit (pkgs) system; });
149+
node2nixDevelopAttrs = (import node2nixDevelop) { inherit nodejs pkgs; inherit (pkgs) system; };
150150

151151
# Build the project (runs `npm run build`), and puts the entire output in the
152152
# nix store

extras/haskell.nix/plutus.nix

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ let
2727
packages = builtins.listToAttrs (builtins.map
2828
(name: {
2929
inherit name;
30-
value.components.library.setupHaddockFlags = [ "--haddock-options=@${responseFile}" ];
31-
value.components.library.ghcOptions = [ "-XFlexibleContexts" "-Wwarn" "-fplugin-opt=PlutusTx.Plugin:defer-errors" ];
32-
value.components.library.extraSrcFiles = [ responseFile ];
30+
value.components.library = {
31+
setupHaddockFlags = [ "--haddock-options=@${responseFile}" ];
32+
ghcOptions = [ "-XFlexibleContexts" "-Wwarn" "-fplugin-opt=PlutusTx.Plugin:defer-errors" ];
33+
extraSrcFiles = [ responseFile ];
34+
};
3335
})
3436
l);
3537
};

extras/lbf-nix/utils.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ let
77
then overrides.${name}.override val
88
else val
99
)
10-
((builtins.mapAttrs (name: val: if attrs?${name} then attrs.${name} else val.default) overrides) // attrs);
10+
((builtins.mapAttrs (name: val: attrs.${name} or val.default) overrides) // attrs);
1111
# Makes a shell flag
1212
# Example: `mkFlag "foo" "bar" = "--foo='bar'"`
1313
mkFlag = key: value: "--${key}=${pkgs.lib.escapeShellArg "${value}"}";

extras/pre-commit-hooks-extra.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
];
55
perSystem = { pkgs, ... }:
66
let
7-
rustfmt = pkgs.rust-bin.stable.latest.rustfmt;
8-
deno = pkgs.deno;
7+
inherit (pkgs.rust-bin.stable.latest) rustfmt;
8+
inherit (pkgs) deno;
99
in
1010
{
1111
pre-commit.settings.hooks = {

pre-commit.nix

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,31 @@
33
./extras/pre-commit-hooks-extra.nix
44
inputs.proto-nix.lib.preCommitModule
55
];
6-
perSystem = { config, ... }:
6+
perSystem = { config, pkgs, ... }:
77
{
8-
devShells.dev-pre-commit = config.pre-commit.devShell;
9-
devShells.default = config.pre-commit.devShell;
8+
devShells.default = pkgs.mkShell {
9+
name = "dev-default";
10+
buildInputs = config.settings.shell.tools;
11+
shellHook = config.settings.shell.hook;
12+
};
1013

1114
pre-commit = {
1215
settings = {
1316
excludes = [
17+
".*spago-packages.nix$"
1418
"lambda-buffers-codegen/data/goldens/.*"
1519
"lambda-buffers-codegen/data/lamval-cases/.*"
1620
"experimental/archive/.*"
1721
"experimental/ctl-env/autogen/.*"
1822
"experimental/plutustx-env/autogen/.*"
19-
"experimental/ctl-env/spago-packages.nix"
2023
"lambda-buffers-frontend/data/goldens/good/work-dir/.*"
21-
"docs/compiler-api.md"
2224
"lambda-buffers-testsuite/lbt-prelude/goldens/.*"
23-
"runtimes/purescript/lbr-prelude/spago-packages.nix"
24-
".*/spago-packages.nix$"
2525
];
2626

2727
hooks = {
2828
nixpkgs-fmt.enable = true;
2929
deadnix.enable = true;
30+
statix.enable = true;
3031
cabal-fmt.enable = true;
3132
fourmolu.enable = true;
3233
shellcheck.enable = true;
@@ -45,6 +46,7 @@
4546

4647
settings = {
4748
ormolu.cabalDefaultExtensions = true;
49+
statix.ignore = [ "**spago-packages.nix" ];
4850
};
4951
};
5052
};

0 commit comments

Comments
 (0)