Skip to content
This repository has been archived by the owner on Nov 7, 2024. It is now read-only.

Commit

Permalink
Update Nix inputs and fix some type issues in builder.nu
Browse files Browse the repository at this point in the history
  • Loading branch information
lucperkins committed Sep 8, 2023
1 parent 49d1c19 commit 279936f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 15 deletions.
12 changes: 6 additions & 6 deletions flake.lock

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

11 changes: 10 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,21 @@
${pkgs.nushell}/bin/nu --env-config ${./nuenv/user-env.nu} --commands "nuenvCommands"
'';

# An example Nushell-based derivation
# For NixCon
hello = pkgs.nuenv.mkDerivation {
name = "hello-nix-nushell";
packages = [ pkgs.hello ];
src = ./.;
build = builtins.readFile ./example/hello.nu;
MESSAGE = "Servus, grüezi, hallo, und hallöchen";
};

# An example Nushell-based derivation
nixcon = pkgs.nuenv.mkDerivation {
name = "hello-nixcon";
packages = [ pkgs.hello ];
src = ./.;
build = builtins.readFile ./example/hello.nu;
MESSAGE = "Hello from Nix + Bash";
};

Expand Down
16 changes: 8 additions & 8 deletions nuenv/builder.nu
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ if $nix.debug { banner "SETUP" }
if (not ($drv.initialPackages | is-empty)) and $nix.debug {
let numPackages = ($drv.initialPackages | length)

info $"Adding (blue $numPackages) package(plural $numPackages) to PATH:"
info $"Adding (blue ($numPackages | into string)) package(plural $numPackages) to PATH:"

for pkg in $drv.initialPackages {
let name = (getPkgName $nix.store $pkg)
Expand All @@ -92,7 +92,7 @@ let-env PATH = $packagesPath
let numAttrs = ($drv.extraAttrs | length)

if $numAttrs != 0 {
if $nix.debug { info $"Setting (blue $numAttrs) user-supplied environment variable(plural $numAttrs):" }
if $nix.debug { info $"Setting (blue ($numAttrs | into string)) user-supplied environment variable(plural $numAttrs):" }

for attr in $drv.extraAttrs {
if $nix.debug { item $"(yellow $attr.key) = \"($attr.value)\"" }
Expand All @@ -107,7 +107,7 @@ for src in $drv.src { cp -r $src $nix.sandbox }
# Set environment variables for all outputs
if $nix.debug {
let numOutputs = ($drv.outputs | length)
info $"Setting (blue $numOutputs) output environment variable(plural $numOutputs):"
info $"Setting (blue ($numOutputs | into string)) output environment variable(plural $numOutputs):"
}
for output in ($drv.outputs) {
let name = ($output | get key)
Expand All @@ -134,11 +134,11 @@ def runPhase [
# commands are registered. Right now there's a single env file but in
# principle there could be per-phase scripts.
do --capture-errors {
nu --env-config $nushell.userEnvFile --commands $phase
nu --log-level error --env-config $nushell.userEnvFile --commands $phase

let exitCode = $env.LAST_EXIT_CODE

if $exitCode != 0 {
if ($exitCode | into int) != 0 {
exit $exitCode
}
}
Expand All @@ -148,9 +148,9 @@ def runPhase [
}

# The available phases (just one for now)
for phase in [
"build"
] { runPhase $phase }
let phases = [ "build" ]

for phase in $phases { runPhase $phase }

## Run if realisation succeeds
if $nix.debug {
Expand Down

0 comments on commit 279936f

Please sign in to comment.