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
};

runtimes/rust/lbr-prelude-derive/build.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
rustFlake =
55
config.lbf-nix.rustFlake {
66
src = ./.;
7-
crane = inputs.crane;
7+
inherit (inputs) crane;
88
crateName = "lbr-prelude-derive";
99
extraSources = [
1010
{

runtimes/rust/lbr-prelude/build.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
rustFlake =
55
config.lbf-nix.rustFlake {
66
src = ./.;
7-
crane = inputs.crane;
7+
inherit (inputs) crane;
88
crateName = "lbr-prelude";
99
extraSources = [
1010
{

runtimes/typescript/lbr-plutus/build.nix

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{ ... }:
1+
_:
22
{
33
perSystem = { config, ... }:
44
let
@@ -15,17 +15,15 @@
1515
{
1616

1717
packages = {
18-
lbr-plutus-typescript = typescriptFlake.packages.lbr-plutus-typescript;
19-
lbr-plutus-typescript-tgz = typescriptFlake.packages.lbr-plutus-typescript-tgz;
20-
lbr-plutus-typescript-node2nix = typescriptFlake.packages.lbr-plutus-typescript-node2nix;
18+
inherit (typescriptFlake.packages) lbr-plutus-typescript lbr-plutus-typescript-tgz lbr-plutus-typescript-node2nix;
2119
};
2220

2321
devShells = {
24-
lbr-plutus-typescript = typescriptFlake.devShells.lbr-plutus-typescript;
22+
inherit (typescriptFlake.devShells) lbr-plutus-typescript;
2523
};
2624

2725
checks = {
28-
lbr-plutus-typescript-test = typescriptFlake.checks.lbr-plutus-typescript-test;
26+
inherit (typescriptFlake.checks) lbr-plutus-typescript-test;
2927
};
3028

3129
# TODO(jaredponn): for some reason, writing the more terse `inherit`

runtimes/typescript/lbr-prelude/build.nix

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{ ... }:
1+
_:
22
{
33
perSystem = { config, ... }:
44
let
@@ -13,18 +13,16 @@
1313
in
1414
{
1515
packages = {
16-
lbr-prelude-typescript = typescriptFlake.packages.lbr-prelude-typescript;
17-
lbr-prelude-typescript-tgz = typescriptFlake.packages.lbr-prelude-typescript-tgz;
18-
lbr-prelude-typescript-node2nix = typescriptFlake.packages.lbr-prelude-typescript-node2nix;
16+
inherit (typescriptFlake.packages) lbr-prelude-typescript lbr-prelude-typescript-tgz lbr-prelude-typescript-node2nix;
1917
};
2018

2119
devShells =
2220
{
23-
lbr-prelude-typescript = typescriptFlake.devShells.lbr-prelude-typescript;
21+
inherit (typescriptFlake.devShells) lbr-prelude-typescript;
2422
};
2523

2624
checks = {
27-
lbr-prelude-typescript-test = typescriptFlake.checks.lbr-prelude-typescript-test;
25+
inherit (typescriptFlake.checks) lbr-prelude-typescript-test;
2826
};
2927

3028
# TODO(jaredponn): for some reason, writing the more terse `inherit`

settings.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@
4949
shell = {
5050

5151
tools = [
52+
5253
pkgs.haskellPackages.apply-refact
5354

55+
pkgs.nil
5456
inputs.pre-commit-hooks.outputs.packages.${system}.deadnix
5557
inputs.pre-commit-hooks.outputs.packages.${system}.nixpkgs-fmt
5658

testsuites/lbt-plutus/api/build.nix

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,32 @@
11
_: {
22
perSystem = { config, ... }:
33
{
4-
packages.lbf-plutus-golden-api-haskell = config.lbf-nix.lbfPlutusHaskell {
5-
name = "lbf-plutus-golden-api";
6-
src = ./.;
7-
files = [ "Foo.lbf" "Foo/Bar.lbf" "Days.lbf" ];
8-
};
4+
packages = {
5+
lbf-plutus-golden-api-haskell = config.lbf-nix.lbfPlutusHaskell {
6+
name = "lbf-plutus-golden-api";
7+
src = ./.;
8+
files = [ "Foo.lbf" "Foo/Bar.lbf" "Days.lbf" ];
9+
};
910

10-
packages.lbf-plutus-golden-api-purescript = config.lbf-nix.lbfPlutusPurescript {
11-
name = "lbf-plutus-golden-api";
12-
src = ./.;
13-
files = [ "Foo.lbf" "Foo/Bar.lbf" "Days.lbf" ];
14-
};
11+
lbf-plutus-golden-api-purescript = config.lbf-nix.lbfPlutusPurescript {
12+
name = "lbf-plutus-golden-api";
13+
src = ./.;
14+
files = [ "Foo.lbf" "Foo/Bar.lbf" "Days.lbf" ];
15+
};
1516

16-
packages.lbf-plutus-golden-api-plutarch = config.lbf-nix.lbfPlutarch {
17-
name = "lbf-plutus-plutarch-golden-api";
18-
src = ./.;
19-
files = [ "Foo.lbf" "Foo/Bar.lbf" "Days.lbf" ];
20-
};
17+
lbf-plutus-golden-api-plutarch = config.lbf-nix.lbfPlutarch {
18+
name = "lbf-plutus-plutarch-golden-api";
19+
src = ./.;
20+
files = [ "Foo.lbf" "Foo/Bar.lbf" "Days.lbf" ];
21+
};
2122

22-
packages.lbf-plutus-golden-api-rust = config.lbf-nix.lbfPlutusRust {
23-
name = "lbf-plutus-rust-golden-api";
24-
src = ./.;
25-
files = [ "Foo.lbf" "Foo/Bar.lbf" "Days.lbf" ];
26-
};
23+
lbf-plutus-golden-api-rust = config.lbf-nix.lbfPlutusRust {
24+
name = "lbf-plutus-rust-golden-api";
25+
src = ./.;
26+
files = [ "Foo.lbf" "Foo/Bar.lbf" "Days.lbf" ];
27+
};
2728

29+
};
2830
};
2931
}
3032

testsuites/lbt-plutus/lbt-plutus-rust/build.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
let
55
rustFlake = config.lbf-nix.rustFlake {
66
src = ./.;
7-
crane = inputs.crane;
7+
inherit (inputs) crane;
88
crateName = "lbt-plutus";
99

1010
extraSources = [

testsuites/lbt-prelude/api/build.nix

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
11
_: {
22
perSystem = { config, ... }:
33
{
4-
packages.lbf-prelude-golden-api-haskell = config.lbf-nix.lbfPreludeHaskell {
5-
name = "lbf-prelude-golden-api";
6-
src = ./.;
7-
files = [ "Foo.lbf" "Foo/Bar.lbf" "Days.lbf" ];
8-
};
4+
packages = {
5+
lbf-prelude-golden-api-haskell = config.lbf-nix.lbfPreludeHaskell {
6+
name = "lbf-prelude-golden-api";
7+
src = ./.;
8+
files = [ "Foo.lbf" "Foo/Bar.lbf" "Days.lbf" ];
9+
};
910

10-
packages.lbf-prelude-golden-api-purescript = config.lbf-nix.lbfPreludePurescript {
11-
name = "lbf-prelude-golden-api";
12-
src = ./.;
13-
files = [ "Foo.lbf" "Foo/Bar.lbf" "Days.lbf" ];
14-
};
11+
lbf-prelude-golden-api-purescript = config.lbf-nix.lbfPreludePurescript {
12+
name = "lbf-prelude-golden-api";
13+
src = ./.;
14+
files = [ "Foo.lbf" "Foo/Bar.lbf" "Days.lbf" ];
15+
};
1516

16-
packages.lbf-prelude-golden-api-rust = config.lbf-nix.lbfPreludeRust {
17-
name = "lbf-prelude-golden-api";
18-
src = ./.;
19-
files = [ "Foo.lbf" "Foo/Bar.lbf" "Days.lbf" ];
20-
};
17+
lbf-prelude-golden-api-rust = config.lbf-nix.lbfPreludeRust {
18+
name = "lbf-prelude-golden-api";
19+
src = ./.;
20+
files = [ "Foo.lbf" "Foo/Bar.lbf" "Days.lbf" ];
21+
};
2122

23+
};
2224
};
2325
}
2426

testsuites/lbt-prelude/lbt-prelude-rust/build.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
let
55
rustFlake = config.lbf-nix.rustFlake {
66
src = ./.;
7-
crane = inputs.crane;
7+
inherit (inputs) crane;
88
crateName = "lbt-prelude";
99

1010
extraSources = [

0 commit comments

Comments
 (0)