Nix-shell shebang: Difference between revisions

YoshiRulz (talk | contribs)
C#: New section
N0099 (talk | contribs)
 
(2 intermediate revisions by one other user not shown)
Line 36: Line 36:
=== C# ===
=== C# ===


Using <code>dotnet run app.cs</code>, new in .NET 10:
Using file-based apps, new in .NET 10:


<syntaxHighlight lang="csharp">
<syntaxHighlight lang="csharp">
#!/usr/bin/env nix-shell
#!/usr/bin/env nix-shell
/*
/*
#! nix-shell -i "dotnet run" -p dotnetCorePackages.dotnet_10.sdk
#! nix-shell -i dotnet -p dotnetCorePackages.dotnet_10.sdk
*/
*/
#:package Humanizer@2.14.1
#:package Humanizer@2.14.1


using Humanizer;
using Humanizer;
Environment.CurrentDirectory = (string) AppContext.GetData("EntryPointFileDirectoryPath")!; // equivalent of `cd $(dirname $0)`


var dotNet9Released = DateTimeOffset.Parse("2024-12-03");
var dotNet9Released = DateTimeOffset.Parse("2024-12-03");
Line 165: Line 167:
== See also ==
== See also ==


* [https://nixos.org/manual/nix/unstable/command-ref/nix-shell.html?highlight=shebang#use-as-a--interpreter nix-shell: Use As a #!-Interpreter] in nix manual
* [https://nix.dev/manual/nix/stable/command-ref/nix-shell.html?highlight=shebang#use-as-a--interpreter nix-shell: Use As a #!-Interpreter] man page
* [https://www.mankier.com/1/nix-shell#Use_As_a_%23!-Interpreter nix-shell: Use As a #!-Interpreter] man page
* [https://gist.github.com/travisbhartwell/f972aab227306edfcfea nix-shell and Shebang Lines]
* [https://gist.github.com/travisbhartwell/f972aab227306edfcfea nix-shell and Shebang Lines]
* [https://notes.yukiisbo.red/posts/2021/07/Spice_up_with_Nix_Scripts.html Spice up with Nix: Scripts with magical dependencies]
* [https://notes.yukiisbo.red/posts/2021/07/Spice_up_with_Nix_Scripts.html Spice up with Nix: Scripts with magical dependencies]