diff --git a/examples/c-hello-world/project.ncl b/examples/c-hello-world/project.ncl index 9aca4def..84435bf6 100644 --- a/examples/c-hello-world/project.ncl +++ b/examples/c-hello-world/project.ncl @@ -4,7 +4,8 @@ let organist = inputs.organist in organist.OrganistExpression & { Schema, - config | Schema = { + config | Schema + = { flake.packages."default" = flake.packages.hello, flake.packages.hello = organist.nix.builders.NixpkgsPkg diff --git a/examples/direnv/project.ncl b/examples/direnv/project.ncl index cfd0971d..36b79163 100644 --- a/examples/direnv/project.ncl +++ b/examples/direnv/project.ncl @@ -5,7 +5,8 @@ organist.OrganistExpression & organist.tools.direnv & { Schema, - config | Schema = { + config | Schema + = { shells = organist.shells.Bash, shells.build = { diff --git a/examples/filegen/project.ncl b/examples/filegen/project.ncl index dd385795..71035d0d 100644 --- a/examples/filegen/project.ncl +++ b/examples/filegen/project.ncl @@ -5,7 +5,8 @@ organist.OrganistExpression & organist.tools.editorconfig & { Schema, - config | Schema = { + config | Schema + = { shells = organist.shells.Bash, shells.build = { diff --git a/examples/raw_nix_expression/project.ncl b/examples/raw_nix_expression/project.ncl index 04265a00..8f860b65 100644 --- a/examples/raw_nix_expression/project.ncl +++ b/examples/raw_nix_expression/project.ncl @@ -4,7 +4,8 @@ let organist = inputs.organist in organist.OrganistExpression & { Schema, - config | Schema = { + config | Schema + = { shells = organist.shells.Bash, shells.build = { diff --git a/examples/services/project.ncl b/examples/services/project.ncl index 37656acc..c853406e 100644 --- a/examples/services/project.ncl +++ b/examples/services/project.ncl @@ -10,7 +10,8 @@ organist.OrganistExpression & { Schema, - config | Schema = { + config | Schema + = { shells = organist.shells.Bash, shells.build = { diff --git a/flake.lock b/flake.lock index fc7fa54b..0f6874c8 100644 --- a/flake.lock +++ b/flake.lock @@ -36,11 +36,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1710806803, - "narHash": "sha256-qrxvLS888pNJFwJdK+hf1wpRCSQcqA6W5+Ox202NDa0=", + "lastModified": 1719075281, + "narHash": "sha256-CyyxvOwFf12I91PBWz43iGT1kjsf5oi6ax7CrvaMyAo=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "b06025f1533a1e07b6db3e75151caa155d1c7eb3", + "rev": "a71e967ef3694799d0c418c98332f7ff4cc5f6af", "type": "github" }, "original": { diff --git a/future/prototype/builders.ncl b/future/prototype/builders.ncl index b8aef6ea..d391d436 100644 --- a/future/prototype/builders.ncl +++ b/future/prototype/builders.ncl @@ -49,7 +49,8 @@ let Drv = Dyn in build_inputs | default = {}, install_phase | String | default = "", build_phase | String | default = "", - build_script | String = m%" + build_script | String + = m%" %{build_phase} %{install_phase} "%, diff --git a/future/prototype/nickelpkgs.ncl b/future/prototype/nickelpkgs.ncl index 7d454c6c..0728449d 100644 --- a/future/prototype/nickelpkgs.ncl +++ b/future/prototype/nickelpkgs.ncl @@ -16,11 +16,13 @@ in { get_all_defs | Effect (Array PackageDef) = [ import "pkgs/hello-world.ncl"], - defs_with_name | Array PackageDef -> { _ : PackageDef } = fun _pkgs => + defs_with_name | Array PackageDef -> { _ : PackageDef } + = fun _pkgs => { hello-world = import "pkgs/hello-world.ncl", }, - combine | { _ : PackageDef } -> { _ : Package } = fun pkgs => + combine | { _ : PackageDef } -> { _ : Package } + = fun pkgs => # Bind the derivation field to the others. Using merging and not a contract # to avoid redoing the computation again and again let base = record.map (fun _k pkg => pkgs & drv_builder) in @@ -39,7 +41,8 @@ in base in res, - make | Effect { _ : Derivation } = + make | Effect { _ : Derivation } + = get_all_defs |> defs_with_name |> combine, diff --git a/future/prototype/nix_builtins.ncl b/future/prototype/nix_builtins.ncl index 0a08651a..462d064e 100644 --- a/future/prototype/nix_builtins.ncl +++ b/future/prototype/nix_builtins.ncl @@ -1,5 +1,6 @@ { - derivation | String -> String -> { .. } -> String -> { .. } = fun name_ version_ system_ build_command_ => + derivation | String -> String -> { .. } -> String -> { .. } + = fun name_ version_ system_ build_command_ => { name = name_, version = version_, @@ -9,7 +10,8 @@ }, # we should return a derivation, but let's avoid circular imports for now, and # restructure contracts/functions later. - write_text | String -> String -> { .. } = fun name_ text => + write_text | String -> String -> { .. } + = fun name_ text => { name = name_, version = "1.0", diff --git a/lib/direnv.ncl b/lib/direnv.ncl index 3707f44c..e2503f3a 100644 --- a/lib/direnv.ncl +++ b/lib/direnv.ncl @@ -12,7 +12,8 @@ files = true, }, }, - config | Schema = { + config | Schema + = { direnv, files = if direnv.enable then diff --git a/lib/editorconfig.ncl b/lib/editorconfig.ncl index c4d04c4f..99efc30c 100644 --- a/lib/editorconfig.ncl +++ b/lib/editorconfig.ncl @@ -16,7 +16,8 @@ let ConfigEntry = { } in let Config = { _ : ConfigEntry } in -let showConfigEntry | String -> ConfigEntry -> String = fun section_name entry => +let showConfigEntry | String -> ConfigEntry -> String + = fun section_name entry => let content = entry |> std.record.map (fun key value => "%{key} = %{std.to_string value}") @@ -80,7 +81,8 @@ files | default = {}, }, - config | Schema = { + config | Schema + = { editorconfig, files = if editorconfig.sections != {} then diff --git a/lib/files.ncl b/lib/files.ncl index 42b3c393..15414367 100644 --- a/lib/files.ncl +++ b/lib/files.ncl @@ -31,8 +31,10 @@ let NormaliseTargets = fun label files => files |> std.record.map (fun name file_descr => file_descr & { target | default = name }) in -let regenerate_files | Files -> nix.derivation.Derivation = fun files_to_generate => - let regnerate_one | String -> File -> nix.derivation.NixString = fun key file_descr => +let regenerate_files | Files -> nix.derivation.Derivation + = fun files_to_generate => + let regnerate_one | String -> File -> nix.derivation.NixString + = fun key file_descr => let file_content = file_descr.content in let target = file_descr.target in let copy_command = @@ -84,7 +86,8 @@ let regenerate_files | Files -> nix.derivation.Derivation = fun files_to_generat = {}, flake.apps, # Forward declaration. Not great but would need some refactor to fix }, - config | Schema = { + config | Schema + = { files, flake.apps.regenerate-files.program = nix-s%"%{regenerate_files files}/bin/regenerate-files"%, }, diff --git a/lib/nix-interop/shells/haskell.ncl b/lib/nix-interop/shells/haskell.ncl index 6520470e..5b56cc17 100644 --- a/lib/nix-interop/shells/haskell.ncl +++ b/lib/nix-interop/shells/haskell.ncl @@ -19,9 +19,19 @@ ormoluFromHls = fun hls => (map (dependency: { name = dependency.pname; value = dependency; }) p.passthru.getBuildInputs.haskellBuildInputs); hlsDependencies = getDependencies hls; - hlsOrmoluPluginDependencies = getDependencies hlsDependencies.hls-ormolu-plugin; + + noOrmoluFound = + builtins.trace + "Couldn't find `ormolu` in the dependencies of `haskell-language-server`. It won't be available in the shell" + null; in - hlsOrmoluPluginDependencies.ormolu.bin + if hlsDependencies ? ormolu then + hlsDependencies.ormolu.bin or noOrmoluFound + else if hlsDependencies ? hls-ormolu-plugin then + let hlsOrmoluPluginDependencies = getDependencies hlsDependencies.hls-ormolu-plugin; in + hlsOrmoluPluginDependencies.ormolu.bin or noOrmoluFound + else + noOrmoluFound "%, args = hls, } diff --git a/lib/schema.ncl b/lib/schema.ncl index 207b05d7..d562cb30 100644 --- a/lib/schema.ncl +++ b/lib/schema.ncl @@ -64,7 +64,8 @@ let filegen = import "files.ncl" in | FlakeOutputs = {}, }, - config | Schema = { + config | Schema + = { shells, flake.devShells = shells, }, diff --git a/lib/services.ncl b/lib/services.ncl index 39404ddb..b86df6c9 100644 --- a/lib/services.ncl +++ b/lib/services.ncl @@ -3,7 +3,8 @@ let ProcfileCommand = nix.derivation.NixString in let ProcfileSchema = { _ : ProcfileCommand } in -let generate_procfile | ProcfileSchema -> nix.derivation.NixString = fun schema => +let generate_procfile | ProcfileSchema -> nix.derivation.NixString + = fun schema => schema |> std.record.to_array |> std.array.fold_left @@ -38,14 +39,16 @@ let generate_procfile | ProcfileSchema -> nix.derivation.NixString = fun schema = {}, flake.apps, }, - config | Schema = { + config | Schema + = { services, flake.apps = if services != {} then let procfile = nix.builtins.to_file "Procfile" (generate_procfile services) in { start-services.type = "app", - start-services.program | nix.derivation.NixString = + start-services.program | nix.derivation.NixString + = let run = nix.builders.ShellApplication & { diff --git a/lib/shell-tests.ncl b/lib/shell-tests.ncl index 9d6c1c56..47aaeeba 100644 --- a/lib/shell-tests.ncl +++ b/lib/shell-tests.ncl @@ -34,7 +34,8 @@ std.record.map (import "./organist.ncl").shells | { _ : { - script | String | default = + script | String | default + = # Enable all usual bash error handling options # Also redirect stdout to stderr to avoid it interleaving when going through `parallel` let lines = std.string.join "\n" (std.record.values tests) in diff --git a/notes/builder-draft.ncl b/notes/builder-draft.ncl index 677c7f41..832cc3ff 100644 --- a/notes/builder-draft.ncl +++ b/notes/builder-draft.ncl @@ -43,7 +43,8 @@ build_inputs | default = {}, install_phase | Str | default = "", build_phase | Str | default = "", - build_script | Str = + build_script | Str + = m%" %{build_phase} %{install_phase} diff --git a/project.ncl b/project.ncl index 1ba551e4..197fa24d 100644 --- a/project.ncl +++ b/project.ncl @@ -5,7 +5,8 @@ let import_nix = organist.nix.import_nix in organist.OrganistExpression & { Schema, - config | Schema = { + config | Schema + = { shells = organist.shells.Bash @@ -18,7 +19,8 @@ organist.OrganistExpression }, flake.apps.run-test = - let testScript | organist.nix.builders.ShellApplication = { + let testScript | organist.nix.builders.ShellApplication + = { name = "run-test.sh", content.file = organist.nix.builtins.import_file "run-test.sh", runtime_inputs = { diff --git a/templates/default/project.ncl b/templates/default/project.ncl index 82840353..c557dd84 100644 --- a/templates/default/project.ncl +++ b/templates/default/project.ncl @@ -4,7 +4,8 @@ let organist = inputs.organist in organist.OrganistExpression & { Schema, - config | Schema = { + config | Schema + = { shells = organist.shells.Bash, shells.build = { diff --git a/tests/to_file.ncl b/tests/to_file.ncl index 3c667f36..77dd9318 100644 --- a/tests/to_file.ncl +++ b/tests/to_file.ncl @@ -9,7 +9,7 @@ organist.nix.builders.NixpkgsPkg [[ $(cat %{file1}) == "important data" ]] # Note that this line changes every time we update nixpkgs. # Keep it pointing to x86_64-linux version to keep CI happy. - [[ $(cat %{file2}) == "see /nix/store/iqhv7kvml0bldcv6vv39kky17s8x6apk-file1" ]] + [[ $(cat %{file2}) == "see /nix/store/bzggifmjzdsyqffyvyn516p8rxhh609x-file1" ]] echo OK > $out "%, }