Skip to content

Commit

Permalink
Namespace the Nix-related things
Browse files Browse the repository at this point in the history
Organist isn't _just_ a Nix framework, so we want to make sure that it
is possible to add stuff that's not strictly Nix-related to it, and have
it feel first-class.
So move most of the Nix-related stuff in its own namespace to clear up
some real estate for the rest.
  • Loading branch information
Théophane Hufschmitt committed Oct 13, 2023
1 parent 6196a53 commit f70e53b
Show file tree
Hide file tree
Showing 20 changed files with 428 additions and 42 deletions.
2 changes: 1 addition & 1 deletion examples/c-hello-world/nickel.lock.ncl
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
organist = import "../../lib/nix.ncl",
organist = import "../../lib/organist.ncl",
}
12 changes: 6 additions & 6 deletions examples/c-hello-world/project.ncl
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ let organist = inputs.organist in
{
packages."default" = packages.hello,
packages.hello =
organist.builders.NixpkgsPkg
organist.nix.builders.NixpkgsPkg
& {
name = "hello",
version = "0.1",
nix_drv = {
buildInputs.gcc = organist.lib.import_nix "nixpkgs#gcc",
buildInputs.coreutils = organist.lib.import_nix "nixpkgs#coreutils",
buildInputs.bash = organist.lib.import_nix "nixpkgs#bash",
buildInputs.gcc = organist.import_nix "nixpkgs#gcc",
buildInputs.coreutils = organist.import_nix "nixpkgs#coreutils",
buildInputs.bash = organist.import_nix "nixpkgs#bash",
buildCommand =
nix-s%"
gcc %{organist.lib.import_file "hello.c"} -o hello
gcc %{organist.nix.builtins.import_file "hello.c"} -o hello
mkdir -p $out/bin
cp hello $out/bin/hello
"%
| organist.contracts.NixString,
| organist.nix.derivation.NixString,
},
}
}
4 changes: 2 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
outputsFromNickel = baseDir: flakeInputs: {
systems ? flake-utils.lib.defaultSystems,
lockFileContents ? {
organist = "${self}/lib/nix.ncl";
organist = "${self}/lib/organist.ncl";
},
}:
flake-utils.lib.eachSystem systems (system: let
Expand All @@ -56,7 +56,7 @@
});

computedOutputs = outputsFromNickel ./. inputs {
lockFileContents.organist = "./lib/nix.ncl";
lockFileContents.organist = "./lib/organist.ncl";
};
in
{
Expand Down
10 changes: 5 additions & 5 deletions lib/lib.nix
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@
# organist = {
# builders = "/nix/store/...-source/builders.ncl";
# contracts = "/nix/store/...-source/contracts.ncl";
# nix = "/nix/store/...-source/nix.ncl";
# nix = "/nix/store/...-source/organist.ncl";
# };
# }
# Result:
# {
# organist = {
# builders = import "/nix/store/...-source/builders.ncl",
# contracts = import "/nix/store/...-source/contracts.ncl",
# nix = import "/nix/store/...-source/nix.ncl",
# nix = import "/nix/store/...-source/organist.ncl",
# },
# }
buildLockFile = contents:
Expand Down Expand Up @@ -147,9 +147,9 @@
system = "${system}",
}
in
let nix = (import "${src}/nickel.lock.ncl").organist in
let organist = (import "${src}/nickel.lock.ncl").organist in
let nickel_expr | nix.contracts.OrganistExpression =
let nickel_expr | organist.OrganistExpression =
import "${src}/${nickelFile}" in
nickel_expr & params
Expand Down Expand Up @@ -197,7 +197,7 @@
nixpkgs = pkgs;
},
lockFileContents ? {
organist = "${organistSrc}/lib/nix.ncl";
organist = "${organistSrc}/lib/organist.ncl";
},
}: let
nickelResult = callNickel {
Expand Down
4 changes: 2 additions & 2 deletions lib/builders.ncl → lib/nix-interop/builders.ncl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
let { NickelDerivation, Derivation, NixString, NixEnvironmentVariable, .. } = import "contracts.ncl" in
let { NickelDerivation, Derivation, NixString, NixEnvironmentVariable, .. } = import "derivation.ncl" in

let lib = import "lib.ncl" in
let lib = import "builtins.ncl" in

let concat_strings_sep = fun sep values =>
if std.array.length values == 0 then
Expand Down
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit f70e53b

Please sign in to comment.