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
2 changes: 1 addition & 1 deletion docs/build.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ _: {
devShells.dev-docs = pkgs.mkShell {
name = "docs-env";
packages = [ pkgs.mdbook ];
shellHook = config.pre-commit.installationScript;
shellHook = config.settings.shell.hook;
};

packages.lambda-buffers-book = pkgs.stdenv.mkDerivation {
Expand Down
1 change: 1 addition & 0 deletions extras/.envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake .#dev-nix
22 changes: 15 additions & 7 deletions extras/build.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@
};

# Makes it available in the system agnostic `lib` argument.
config._module.args.lib = config.flake.lib // {
inherit (config) lbf-nix;
};
config = {
_module.args.lib = config.flake.lib // {
inherit (config) lbf-nix;
};

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

# Makes `lib.x86_64-linux.xyz` available
config.flake.lib = config.lbf-nix;
# Makes `lib.x86_64-linux.xyz` available
flake.lib = config.lbf-nix;
};

options = {

Expand All @@ -30,6 +32,12 @@

# Sets a per system `lbf-nix` option.
config = {
devShells.dev-nix = pkgs.mkShell {
name = "dev-nix";
shellHook = config.settings.shell.hook;
buildInputs = config.settings.shell.tools;
};

lbf-nix = {
# NOTE(bladyjoker): If you need to add a function the export externally and use internally via config.lbf-nix, add it here.

Expand Down
2 changes: 1 addition & 1 deletion extras/flake-purescript.nix
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ let
};
};

devShell = purs.devShell;
inherit (purs) devShell;
};
in
mkFlake pursProjOpts.projectName (pkgs.purescriptProject pursProjOpts)
32 changes: 18 additions & 14 deletions extras/flake-rust.nix
Original file line number Diff line number Diff line change
Expand Up @@ -84,22 +84,26 @@ in
'';
};

packages."${crateName}-rust" = craneLib.buildPackage (commonArgs // {
inherit cargoArtifacts;
doCheck = false;
doInstallCargoArtifacts = true;
});
packages = {
"${crateName}-rust" = craneLib.buildPackage (commonArgs // {
inherit cargoArtifacts;
doCheck = false;
doInstallCargoArtifacts = true;
});

packages."${crateName}-rust-src" = vendoredSrc;
"${crateName}-rust-src" = vendoredSrc;

packages."${crateName}-rust-build-env" = buildEnv;
"${crateName}-rust-build-env" = buildEnv;
};

checks."${crateName}-rust-test" = craneLib.cargoNextest (commonArgs // {
inherit cargoArtifacts;
nativeBuildInputs = testTools;
});
checks = {
"${crateName}-rust-test" = craneLib.cargoNextest (commonArgs // {
inherit cargoArtifacts;
nativeBuildInputs = testTools;
});

checks."${crateName}-rust-clippy" = craneLib.cargoClippy (commonArgs // {
inherit cargoArtifacts;
});
"${crateName}-rust-clippy" = craneLib.cargoClippy (commonArgs // {
inherit cargoArtifacts;
});
};
}
2 changes: 1 addition & 1 deletion extras/flake-typescript.nix
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ let
'';

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

# Build the project (runs `npm run build`), and puts the entire output in the
# nix store
Expand Down
8 changes: 5 additions & 3 deletions extras/haskell.nix/plutus.nix
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ let
packages = builtins.listToAttrs (builtins.map
(name: {
inherit name;
value.components.library.setupHaddockFlags = [ "--haddock-options=@${responseFile}" ];
value.components.library.ghcOptions = [ "-XFlexibleContexts" "-Wwarn" "-fplugin-opt=PlutusTx.Plugin:defer-errors" ];
value.components.library.extraSrcFiles = [ responseFile ];
value.components.library = {
setupHaddockFlags = [ "--haddock-options=@${responseFile}" ];
ghcOptions = [ "-XFlexibleContexts" "-Wwarn" "-fplugin-opt=PlutusTx.Plugin:defer-errors" ];
extraSrcFiles = [ responseFile ];
};
})
l);
};
Expand Down
2 changes: 1 addition & 1 deletion extras/lbf-nix/utils.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ let
then overrides.${name}.override val
else val
)
((builtins.mapAttrs (name: val: if attrs?${name} then attrs.${name} else val.default) overrides) // attrs);
((builtins.mapAttrs (name: val: attrs.${name} or val.default) overrides) // attrs);
# Makes a shell flag
# Example: `mkFlag "foo" "bar" = "--foo='bar'"`
mkFlag = key: value: "--${key}=${pkgs.lib.escapeShellArg "${value}"}";
Expand Down
4 changes: 2 additions & 2 deletions extras/pre-commit-hooks-extra.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
];
perSystem = { pkgs, ... }:
let
rustfmt = pkgs.rust-bin.stable.latest.rustfmt;
deno = pkgs.deno;
inherit (pkgs.rust-bin.stable.latest) rustfmt;
inherit (pkgs) deno;
in
{
pre-commit.settings.hooks = {
Expand Down
16 changes: 9 additions & 7 deletions pre-commit.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,31 @@
./extras/pre-commit-hooks-extra.nix
inputs.proto-nix.lib.preCommitModule
];
perSystem = { config, ... }:
perSystem = { config, pkgs, ... }:
{
devShells.dev-pre-commit = config.pre-commit.devShell;
devShells.default = config.pre-commit.devShell;
devShells.default = pkgs.mkShell {
name = "dev-default";
buildInputs = config.settings.shell.tools;
shellHook = config.settings.shell.hook;
};

pre-commit = {
settings = {
excludes = [
".*spago-packages.nix$"
"lambda-buffers-codegen/data/goldens/.*"
"lambda-buffers-codegen/data/lamval-cases/.*"
"experimental/archive/.*"
"experimental/ctl-env/autogen/.*"
"experimental/plutustx-env/autogen/.*"
"experimental/ctl-env/spago-packages.nix"
"lambda-buffers-frontend/data/goldens/good/work-dir/.*"
"docs/compiler-api.md"
"lambda-buffers-testsuite/lbt-prelude/goldens/.*"
"runtimes/purescript/lbr-prelude/spago-packages.nix"
".*/spago-packages.nix$"
];

hooks = {
nixpkgs-fmt.enable = true;
deadnix.enable = true;
statix.enable = true;
cabal-fmt.enable = true;
fourmolu.enable = true;
shellcheck.enable = true;
Expand All @@ -45,6 +46,7 @@

settings = {
ormolu.cabalDefaultExtensions = true;
statix.ignore = [ "**spago-packages.nix" ];
};
};
};
Expand Down
2 changes: 1 addition & 1 deletion runtimes/rust/lbr-prelude-derive/build.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
rustFlake =
config.lbf-nix.rustFlake {
src = ./.;
crane = inputs.crane;
inherit (inputs) crane;
crateName = "lbr-prelude-derive";
extraSources = [
{
Expand Down
2 changes: 1 addition & 1 deletion runtimes/rust/lbr-prelude/build.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
rustFlake =
config.lbf-nix.rustFlake {
src = ./.;
crane = inputs.crane;
inherit (inputs) crane;
crateName = "lbr-prelude";
extraSources = [
{
Expand Down
10 changes: 4 additions & 6 deletions runtimes/typescript/lbr-plutus/build.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ ... }:
_:
{
perSystem = { config, ... }:
let
Expand All @@ -15,17 +15,15 @@
{

packages = {
lbr-plutus-typescript = typescriptFlake.packages.lbr-plutus-typescript;
lbr-plutus-typescript-tgz = typescriptFlake.packages.lbr-plutus-typescript-tgz;
lbr-plutus-typescript-node2nix = typescriptFlake.packages.lbr-plutus-typescript-node2nix;
inherit (typescriptFlake.packages) lbr-plutus-typescript lbr-plutus-typescript-tgz lbr-plutus-typescript-node2nix;
};

devShells = {
lbr-plutus-typescript = typescriptFlake.devShells.lbr-plutus-typescript;
inherit (typescriptFlake.devShells) lbr-plutus-typescript;
};

checks = {
lbr-plutus-typescript-test = typescriptFlake.checks.lbr-plutus-typescript-test;
inherit (typescriptFlake.checks) lbr-plutus-typescript-test;
};

# TODO(jaredponn): for some reason, writing the more terse `inherit`
Expand Down
10 changes: 4 additions & 6 deletions runtimes/typescript/lbr-prelude/build.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ ... }:
_:
{
perSystem = { config, ... }:
let
Expand All @@ -13,18 +13,16 @@
in
{
packages = {
lbr-prelude-typescript = typescriptFlake.packages.lbr-prelude-typescript;
lbr-prelude-typescript-tgz = typescriptFlake.packages.lbr-prelude-typescript-tgz;
lbr-prelude-typescript-node2nix = typescriptFlake.packages.lbr-prelude-typescript-node2nix;
inherit (typescriptFlake.packages) lbr-prelude-typescript lbr-prelude-typescript-tgz lbr-prelude-typescript-node2nix;
};

devShells =
{
lbr-prelude-typescript = typescriptFlake.devShells.lbr-prelude-typescript;
inherit (typescriptFlake.devShells) lbr-prelude-typescript;
};

checks = {
lbr-prelude-typescript-test = typescriptFlake.checks.lbr-prelude-typescript-test;
inherit (typescriptFlake.checks) lbr-prelude-typescript-test;
};

# TODO(jaredponn): for some reason, writing the more terse `inherit`
Expand Down
2 changes: 2 additions & 0 deletions settings.nix
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@
shell = {

tools = [

pkgs.haskellPackages.apply-refact

pkgs.nil
inputs.pre-commit-hooks.outputs.packages.${system}.deadnix
inputs.pre-commit-hooks.outputs.packages.${system}.nixpkgs-fmt

Expand Down
42 changes: 22 additions & 20 deletions testsuites/lbt-plutus/api/build.nix
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
_: {
perSystem = { config, ... }:
{
packages.lbf-plutus-golden-api-haskell = config.lbf-nix.lbfPlutusHaskell {
name = "lbf-plutus-golden-api";
src = ./.;
files = [ "Foo.lbf" "Foo/Bar.lbf" "Days.lbf" ];
};
packages = {
lbf-plutus-golden-api-haskell = config.lbf-nix.lbfPlutusHaskell {
name = "lbf-plutus-golden-api";
src = ./.;
files = [ "Foo.lbf" "Foo/Bar.lbf" "Days.lbf" ];
};

packages.lbf-plutus-golden-api-purescript = config.lbf-nix.lbfPlutusPurescript {
name = "lbf-plutus-golden-api";
src = ./.;
files = [ "Foo.lbf" "Foo/Bar.lbf" "Days.lbf" ];
};
lbf-plutus-golden-api-purescript = config.lbf-nix.lbfPlutusPurescript {
name = "lbf-plutus-golden-api";
src = ./.;
files = [ "Foo.lbf" "Foo/Bar.lbf" "Days.lbf" ];
};

packages.lbf-plutus-golden-api-plutarch = config.lbf-nix.lbfPlutarch {
name = "lbf-plutus-plutarch-golden-api";
src = ./.;
files = [ "Foo.lbf" "Foo/Bar.lbf" "Days.lbf" ];
};
lbf-plutus-golden-api-plutarch = config.lbf-nix.lbfPlutarch {
name = "lbf-plutus-plutarch-golden-api";
src = ./.;
files = [ "Foo.lbf" "Foo/Bar.lbf" "Days.lbf" ];
};

packages.lbf-plutus-golden-api-rust = config.lbf-nix.lbfPlutusRust {
name = "lbf-plutus-rust-golden-api";
src = ./.;
files = [ "Foo.lbf" "Foo/Bar.lbf" "Days.lbf" ];
};
lbf-plutus-golden-api-rust = config.lbf-nix.lbfPlutusRust {
name = "lbf-plutus-rust-golden-api";
src = ./.;
files = [ "Foo.lbf" "Foo/Bar.lbf" "Days.lbf" ];
};

};
};
}

2 changes: 1 addition & 1 deletion testsuites/lbt-plutus/lbt-plutus-rust/build.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
let
rustFlake = config.lbf-nix.rustFlake {
src = ./.;
crane = inputs.crane;
inherit (inputs) crane;
crateName = "lbt-plutus";

extraSources = [
Expand Down
32 changes: 17 additions & 15 deletions testsuites/lbt-prelude/api/build.nix
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
_: {
perSystem = { config, ... }:
{
packages.lbf-prelude-golden-api-haskell = config.lbf-nix.lbfPreludeHaskell {
name = "lbf-prelude-golden-api";
src = ./.;
files = [ "Foo.lbf" "Foo/Bar.lbf" "Days.lbf" ];
};
packages = {
lbf-prelude-golden-api-haskell = config.lbf-nix.lbfPreludeHaskell {
name = "lbf-prelude-golden-api";
src = ./.;
files = [ "Foo.lbf" "Foo/Bar.lbf" "Days.lbf" ];
};

packages.lbf-prelude-golden-api-purescript = config.lbf-nix.lbfPreludePurescript {
name = "lbf-prelude-golden-api";
src = ./.;
files = [ "Foo.lbf" "Foo/Bar.lbf" "Days.lbf" ];
};
lbf-prelude-golden-api-purescript = config.lbf-nix.lbfPreludePurescript {
name = "lbf-prelude-golden-api";
src = ./.;
files = [ "Foo.lbf" "Foo/Bar.lbf" "Days.lbf" ];
};

packages.lbf-prelude-golden-api-rust = config.lbf-nix.lbfPreludeRust {
name = "lbf-prelude-golden-api";
src = ./.;
files = [ "Foo.lbf" "Foo/Bar.lbf" "Days.lbf" ];
};
lbf-prelude-golden-api-rust = config.lbf-nix.lbfPreludeRust {
name = "lbf-prelude-golden-api";
src = ./.;
files = [ "Foo.lbf" "Foo/Bar.lbf" "Days.lbf" ];
};

};
};
}

2 changes: 1 addition & 1 deletion testsuites/lbt-prelude/golden/build.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ _:
{
perSystem = { pkgs, config, ... }:
{
devShells.dev-lbt-prelude-golden = config.devShells.dev-pre-commit;
devShells.dev-lbt-prelude-golden = config.devShells.default;

packages = {
lbt-prelude-golden-haskell = config.lbf-nix.haskellData {
Expand Down
2 changes: 1 addition & 1 deletion testsuites/lbt-prelude/lbt-prelude-rust/build.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
let
rustFlake = config.lbf-nix.rustFlake {
src = ./.;
crane = inputs.crane;
inherit (inputs) crane;
crateName = "lbt-prelude";

extraSources = [
Expand Down