Hi,
I recently started migrating my development environment to Nix flakes. Previously, I relied on nix-shell
with the following shell.nix
:
# This commit is from NixOS 24.05 (28-06-2024)
with (import (fetchTarball https://github.com/NixOS/nixpkgs/archive/89c49874fb15f4124bf71ca5f42a04f2ee5825fd.tar.gz) { config.allowUnfree = true; });
let
dotnet_sdk = (with dotnetCorePackages; combinePackages [
# Install all the .NET versions needed here...
sdk_8_0
]);
in
mkShell {
name = "dotnet-env";
packages = [
# .NET SDK
dotnet_sdk
# Run PowerShell scripts, which are sometimes included in NuGet packages like Playwright
powershell
# Timezones
tzdata
# Locales
glibcLocales
];
shellHook = ''
# Bunch of `exports` commands...
(...)
'';
# Without this, there are warnings about LANG, LC_ALL and locales.
# Many tests fail due those warnings showing up in test outputs too...
# This solution is from: https://gist.github.com/aabs/fba5cd1a8038fb84a46909250d34a5c1
LOCALE_ARCHIVE = "${glibcLocales}/lib/locale/locale-archive";
}
As for my Nix flakes setup, here it is flake.nix
:
{
description = ".NET development environment based on the Filesystem Hierarchy Standard (FHS)";
# https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
};
outputs = { nixpkgs, ... } @ inputs:
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
dotnet_sdk = (with pkgs.dotnetCorePackages; combinePackages [
# Install all the .NET SDK versions needed here...
sdk_8_0
]);
in
{
# Create development shell based on the Filesystem Hierarchy Standard (FHS) with a set of
# standard packages based on the list maintained by the appimagetools package
#
# buildFHSEnv -> https://nixos.org/manual/nixpkgs/stable/#sec-fhs-environments
#
# The packages included in appimagetools.defaultFhsEnvArgs are:
# https://github.com/NixOS/nixpkgs/blob/fd6a510ec7e84ccd7f38c2ad9a55a18bf076f738/pkgs/build-support/appimage/default.nix#L72-L208
devShells.${system}.default = (pkgs.buildFHSEnv (pkgs.appimageTools.defaultFhsEnvArgs // {
name = "dotnet-development-environment";
# Packages installed in the development shell
targetPkgs = pkgs: with pkgs; [
# .NET SDK
dotnet_sdk
# Run PowerShell scripts, which are sometimes included in NuGet packages like Playwright
powershell
# Timezones
tzdata
# Locales
glibcLocales
];
# Commands to be executed in the development shell
profile = ''
# Bunch of `export` commands...
(...)
'';
})).env;
};
}
To launch my IDE, I would run nix-shell --run 'nohup IDE_COMMAND &'
which I am now trying to replicate with nix develop --command 'nohup IDE_COMMAND &'
, but I’m simply taken into the interactive shell and the command is ignored.
What am I doing wrong here? Thank you very much for your help!