From 279936f1e3fd32ea0d880e4644f35401956d10a7 Mon Sep 17 00:00:00 2001 From: Luc Perkins Date: Fri, 8 Sep 2023 14:30:30 +0200 Subject: [PATCH] Update Nix inputs and fix some type issues in builder.nu --- flake.lock | 12 ++++++------ flake.nix | 11 ++++++++++- nuenv/builder.nu | 16 ++++++++-------- 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/flake.lock b/flake.lock index b04358b..a2eeaf9 100644 --- a/flake.lock +++ b/flake.lock @@ -20,11 +20,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1690927903, - "narHash": "sha256-D5gCaCROnjEKDOel//8TO/pOP87pAEtT0uT8X+0Bj/U=", + "lastModified": 1694048570, + "narHash": "sha256-PEQptwFCVaJ+jLFJgrZll2shQ9VI/7xVhrCYkJo8iIw=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "bd836ac5e5a7358dea73cb74a013ca32864ccb86", + "rev": "4f77ea639305f1de0a14d9d41eef83313360638c", "type": "github" }, "original": { @@ -48,11 +48,11 @@ ] }, "locked": { - "lastModified": 1691029059, - "narHash": "sha256-QwVeE9YTgH3LmL7yw2V/hgswL6yorIvYSp4YGI8lZYM=", + "lastModified": 1694139063, + "narHash": "sha256-M2dhhe6IzHmS0zQkmnzbcG98jEQGZ4UcS3VcT+rG/Do=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "99df4908445be37ddb2d332580365fce512a7dcf", + "rev": "46dbbcaf435b0d22b149684589b9b059f73f4ffc", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 71b043f..beaf411 100644 --- a/flake.nix +++ b/flake.nix @@ -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"; }; diff --git a/nuenv/builder.nu b/nuenv/builder.nu index 3156f46..6f38a1d 100644 --- a/nuenv/builder.nu +++ b/nuenv/builder.nu @@ -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) @@ -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)\"" } @@ -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) @@ -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 } } @@ -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 {