Skip to content

Commit

Permalink
Merge pull request #217 from nickel-lang/update-nixpkgs
Browse files Browse the repository at this point in the history
Update the flake inputs
  • Loading branch information
yannham authored Jun 26, 2024
2 parents 879ca21 + 67c82b1 commit 4bfd9a9
Show file tree
Hide file tree
Showing 20 changed files with 68 additions and 32 deletions.
3 changes: 2 additions & 1 deletion examples/c-hello-world/project.ncl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion examples/direnv/project.ncl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ organist.OrganistExpression
& organist.tools.direnv
& {
Schema,
config | Schema = {
config | Schema
= {
shells = organist.shells.Bash,

shells.build = {
Expand Down
3 changes: 2 additions & 1 deletion examples/filegen/project.ncl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ organist.OrganistExpression
& organist.tools.editorconfig
& {
Schema,
config | Schema = {
config | Schema
= {
shells = organist.shells.Bash,

shells.build = {
Expand Down
3 changes: 2 additions & 1 deletion examples/raw_nix_expression/project.ncl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ let organist = inputs.organist in
organist.OrganistExpression
& {
Schema,
config | Schema = {
config | Schema
= {
shells = organist.shells.Bash,

shells.build = {
Expand Down
3 changes: 2 additions & 1 deletion examples/services/project.ncl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ organist.OrganistExpression
& {

Schema,
config | Schema = {
config | Schema
= {
shells = organist.shells.Bash,

shells.build = {
Expand Down
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion future/prototype/builders.ncl
Original file line number Diff line number Diff line change
Expand Up @@ -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}
"%,
Expand Down
9 changes: 6 additions & 3 deletions future/prototype/nickelpkgs.ncl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -39,7 +41,8 @@ in
base
in
res,
make | Effect { _ : Derivation } =
make | Effect { _ : Derivation }
=
get_all_defs
|> defs_with_name
|> combine,
Expand Down
6 changes: 4 additions & 2 deletions future/prototype/nix_builtins.ncl
Original file line number Diff line number Diff line change
@@ -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_,
Expand All @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion lib/direnv.ncl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ files
= true,
},
},
config | Schema = {
config | Schema
= {
direnv,
files =
if direnv.enable then
Expand Down
6 changes: 4 additions & 2 deletions lib/editorconfig.ncl
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down Expand Up @@ -80,7 +81,8 @@ files
| default
= {},
},
config | Schema = {
config | Schema
= {
editorconfig,
files =
if editorconfig.sections != {} then
Expand Down
9 changes: 6 additions & 3 deletions lib/files.ncl
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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"%,
},
Expand Down
14 changes: 12 additions & 2 deletions lib/nix-interop/shells/haskell.ncl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
3 changes: 2 additions & 1 deletion lib/schema.ncl
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ let filegen = import "files.ncl" in
| FlakeOutputs
= {},
},
config | Schema = {
config | Schema
= {
shells,
flake.devShells = shells,
},
Expand Down
9 changes: 6 additions & 3 deletions lib/services.ncl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
& {
Expand Down
3 changes: 2 additions & 1 deletion lib/shell-tests.ncl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion notes/builder-draft.ncl
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
6 changes: 4 additions & 2 deletions project.ncl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ let import_nix = organist.nix.import_nix in
organist.OrganistExpression
& {
Schema,
config | Schema = {
config | Schema
= {

shells =
organist.shells.Bash
Expand All @@ -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 = {
Expand Down
3 changes: 2 additions & 1 deletion templates/default/project.ncl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ let organist = inputs.organist in
organist.OrganistExpression
& {
Schema,
config | Schema = {
config | Schema
= {
shells = organist.shells.Bash,

shells.build = {
Expand Down
2 changes: 1 addition & 1 deletion tests/to_file.ncl
Original file line number Diff line number Diff line change
Expand Up @@ -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
"%,
}

0 comments on commit 4bfd9a9

Please sign in to comment.