Skip to content

Commit

Permalink
Only export the flake field of the nickel config
Browse files Browse the repository at this point in the history
Makes it clear what Nix has (or not) access to.

Also makes it possible in the future to fearlessly use enums in the
config, as they won't be exported
  • Loading branch information
Théophane Hufschmitt committed Jun 17, 2024
1 parent 6490d56 commit 09a9f68
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
10 changes: 4 additions & 6 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,15 @@
then {}
else {
inherit nickelOutputs;
packages = nickelOutputs.packages or {} // nickelOutputs.flake.packages or {};
checks = nickelOutputs.flake.checks or {};
packages = nickelOutputs.packages or {};
checks = nickelOutputs.checks or {};
# Can't define this app in Nickel, yet
apps =
{
regenerate-lockfile = lib.regenerateLockFileApp lockFileContents;
}
// nickelOutputs.flake.apps or {};
# We can't just copy `shells` to `flake.devShells` in the contract
# because of a bug in Nickel: https://github.com/tweag/nickel/issues/1630
devShells = nickelOutputs.shells or {} // nickelOutputs.flake.devShells or {};
// nickelOutputs.apps or {};
devShells = nickelOutputs.devShells or {};
});

computedOutputs = outputsFromNickel ./. (inputs // {organist = self;}) {
Expand Down
6 changes: 3 additions & 3 deletions lib/lib.nix
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
in
let organist = (import "${src}/nickel.lock.ncl").organist in
let nickel_expr | (organist.OrganistExpression & {..}) =
let nickel_expr =
import "${src}/${nickelFile}" in
nickel_expr & params
Expand All @@ -184,13 +184,13 @@
cat > eval.ncl <<EOF
${nickelWithImports "sources"}
EOF
${nickel}/bin/nickel export eval.ncl > $out
${nickel}/bin/nickel export eval.ncl --field config.flake > $out
''
else ''
cat > eval.ncl <<EOF
${nickelWithImports sources}
EOF
${nickel}/bin/nickel export eval.ncl > $out
${nickel}/bin/nickel export eval.ncl --field config.flake > $out
''
);

Expand Down
4 changes: 4 additions & 0 deletions lib/schema.ncl
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ let filegen = import "files.ncl" in
| FlakeOutputs
= {},
},
config | Schema = {
shells,
flake.devShells = shells,
},
}
& filegen
}

0 comments on commit 09a9f68

Please sign in to comment.