From ff4b42e6a8c68b559c40c38bbe9e189b0c2d9f51 Mon Sep 17 00:00:00 2001 From: phanirithvij Date: Mon, 19 Jan 2026 11:54:55 +0530 Subject: [PATCH 1/3] fix: use cat from coreutils Signed-off-by: phanirithvij --- extra/git/hooks.nix | 2 +- modules/commands.nix | 2 +- modules/devshell.nix | 4 ++-- modules/services.nix | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/extra/git/hooks.nix b/extra/git/hooks.nix index 8196e33..15d0025 100644 --- a/extra/git/hooks.nix +++ b/extra/git/hooks.nix @@ -39,7 +39,7 @@ let mkdir -p $out/bin ${lib.concatMapStringsSep "\n" (k: '' - cat <<'WRAPPER' > $out/bin/${k} + ${pkgs.coreutils}/bin/cat <<'WRAPPER' > $out/bin/${k} #!${pkgs.bash}/bin/bash set -euo pipefail diff --git a/modules/commands.nix b/modules/commands.nix index 36b2e4f..4f5b777 100644 --- a/modules/commands.nix +++ b/modules/commands.nix @@ -179,7 +179,7 @@ in help = "prints this menu"; name = "menu"; command = '' - cat <<'DEVSHELL_MENU' + ${pkgs.coreutils}/bin/cat <<'DEVSHELL_MENU' ${commandsToMenu config.commands} DEVSHELL_MENU ''; diff --git a/modules/devshell.nix b/modules/devshell.nix index 2da36ef..608b3ba 100644 --- a/modules/devshell.nix +++ b/modules/devshell.nix @@ -173,7 +173,7 @@ let done if [[ -n "''${help:-}" ]]; then - cat < Date: Mon, 19 Jan 2026 13:05:23 +0530 Subject: [PATCH 2/3] fix: make coreutils (rm) available in the shell in pure mode Signed-off-by: phanirithvij --- nix/mkNakedShell.nix | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/nix/mkNakedShell.nix b/nix/mkNakedShell.nix index 437efc4..e5543aa 100644 --- a/nix/mkNakedShell.nix +++ b/nix/mkNakedShell.nix @@ -1,4 +1,6 @@ { + lib, + runCommand, bashInteractive, coreutils, stdenv, @@ -6,6 +8,10 @@ }: let bashPath = "${bashInteractive}/bin/bash"; + rmCommand = runCommand "coreutils-rm" { } '' + mkdir -p $out/bin + ln -s ${coreutils}/bin/rm $out/bin/rm + ''; nakedStdenv = writeTextFile { name = "naked-stdenv"; destination = "/setup"; @@ -13,6 +19,12 @@ let # Fix for `nix develop` : ''${outputs:=out} + # Fix for `nix-shell --pure` line 1: rm: command not found + # occurs at `_nix_shell_clean_tmpdir` in `nixos/nix` + ${lib.optionalString (builtins.getEnv "IN_NIX_SHELL" == "pure") '' + export PATH=${rmCommand}/bin:$PATH + ''} + runHook() { eval "$shellHook" unset runHook From a41d4f419bd893ddcaadb45d5c81b3d599a89d4d Mon Sep 17 00:00:00 2001 From: phanirithvij Date: Mon, 19 Jan 2026 15:12:00 +0530 Subject: [PATCH 3/3] chore: fmt tree with nixfmt Signed-off-by: phanirithvij --- extra/language/c.nix | 13 +++--- extra/language/rust.nix | 95 ++++++++++++++++++++--------------------- flake.nix | 4 +- modules/back-compat.nix | 17 ++++---- modules/devshell.nix | 74 ++++++++++++++++---------------- modules/env.nix | 4 +- modules/eval-args.nix | 3 +- 7 files changed, 105 insertions(+), 105 deletions(-) diff --git a/extra/language/c.nix b/extra/language/c.nix index f50bd2e..8b40aed 100644 --- a/extra/language/c.nix +++ b/extra/language/c.nix @@ -34,12 +34,13 @@ in }; config = { - devshell.packages = - [ cfg.compiler ] - ++ (lib.optionals hasLibraries (map lib.getLib cfg.libraries)) - ++ - # Assume we want pkg-config, because it's good - (lib.optionals hasIncludes ([ pkgs.pkg-config ] ++ (map lib.getDev cfg.includes))); + devshell.packages = [ + cfg.compiler + ] + ++ (lib.optionals hasLibraries (map lib.getLib cfg.libraries)) + ++ + # Assume we want pkg-config, because it's good + (lib.optionals hasIncludes ([ pkgs.pkg-config ] ++ (map lib.getDev cfg.includes))); env = (lib.optionals hasLibraries [ diff --git a/extra/language/rust.nix b/extra/language/rust.nix index 6e6472f..2b1f433 100644 --- a/extra/language/rust.nix +++ b/extra/language/rust.nix @@ -37,53 +37,52 @@ in config = { devshell.packages = if cfg.enableDefaultToolchain then (map (tool: cfg.packageSet.${tool}) cfg.tools) else [ ]; - env = - [ - { - # On darwin for example enables finding of libiconv - name = "LIBRARY_PATH"; - # append in case it needs to be modified - eval = "$DEVSHELL_DIR/lib"; - } - { - # some *-sys crates require additional includes - name = "CFLAGS"; - # append in case it needs to be modified - eval = "\"-I $DEVSHELL_DIR/include ${lib.optionalString pkgs.stdenv.isDarwin "-iframework $DEVSHELL_DIR/Library/Frameworks"}\""; - } - ] - ++ lib.optionals pkgs.stdenv.isDarwin [ - { - # On darwin for example required for some *-sys crate compilation - name = "RUSTFLAGS"; - # append in case it needs to be modified - eval = "\"-L framework=$DEVSHELL_DIR/Library/Frameworks\""; - } - { - # rustdoc uses a different set of flags - name = "RUSTDOCFLAGS"; - # append in case it needs to be modified - eval = "\"-L framework=$DEVSHELL_DIR/Library/Frameworks\""; - } - { - name = "PATH"; - prefix = - let - inherit (pkgs) xcbuild; - in - lib.makeBinPath [ - xcbuild - "${xcbuild}/Toolchains/XcodeDefault.xctoolchain" - ]; - } - ] - # fenix provides '.rust-src' in the 'complete' toolchain configuration - ++ lib.optionals (cfg.enableDefaultToolchain && cfg.packageSet ? rust-src) [ - { - # rust-analyzer may use this to quicker find the rust source - name = "RUST_SRC_PATH"; - value = "${cfg.packageSet.rust-src}/lib/rustlib/src/rust/library"; - } - ]; + env = [ + { + # On darwin for example enables finding of libiconv + name = "LIBRARY_PATH"; + # append in case it needs to be modified + eval = "$DEVSHELL_DIR/lib"; + } + { + # some *-sys crates require additional includes + name = "CFLAGS"; + # append in case it needs to be modified + eval = "\"-I $DEVSHELL_DIR/include ${lib.optionalString pkgs.stdenv.isDarwin "-iframework $DEVSHELL_DIR/Library/Frameworks"}\""; + } + ] + ++ lib.optionals pkgs.stdenv.isDarwin [ + { + # On darwin for example required for some *-sys crate compilation + name = "RUSTFLAGS"; + # append in case it needs to be modified + eval = "\"-L framework=$DEVSHELL_DIR/Library/Frameworks\""; + } + { + # rustdoc uses a different set of flags + name = "RUSTDOCFLAGS"; + # append in case it needs to be modified + eval = "\"-L framework=$DEVSHELL_DIR/Library/Frameworks\""; + } + { + name = "PATH"; + prefix = + let + inherit (pkgs) xcbuild; + in + lib.makeBinPath [ + xcbuild + "${xcbuild}/Toolchains/XcodeDefault.xctoolchain" + ]; + } + ] + # fenix provides '.rust-src' in the 'complete' toolchain configuration + ++ lib.optionals (cfg.enableDefaultToolchain && cfg.packageSet ? rust-src) [ + { + # rust-analyzer may use this to quicker find the rust source + name = "RUST_SRC_PATH"; + value = "${cfg.packageSet.rust-src}/lib/rustlib/src/rust/library"; + } + ]; }; } diff --git a/flake.nix b/flake.nix index 7baec94..103a805 100644 --- a/flake.nix +++ b/flake.nix @@ -36,7 +36,7 @@ { docs = pkgs.writeShellApplication { name = "docs"; - meta.description = ''Run mdBook server at http://localhost:3000''; + meta.description = "Run mdBook server at http://localhost:3000"; runtimeInputs = [ pkgs.mdbook ]; text = '' cd docs @@ -46,7 +46,7 @@ }; bench = pkgs.writeShellApplication { name = "benchmark"; - meta.description = ''Run benchmark''; + meta.description = "Run benchmark"; runtimeInputs = [ pkgs.hyperfine ]; text = '' cd benchmark diff --git a/modules/back-compat.nix b/modules/back-compat.nix index 88b1f95..5a71d0a 100644 --- a/modules/back-compat.nix +++ b/modules/back-compat.nix @@ -56,13 +56,12 @@ in }; # Copy the values over to the devshell module - config.devshell = - { - packages = config.packages; - packagesFrom = config.packagesFrom; - startup.bash_extra = noDepEntry config.bash.extra; - interactive.bash_interactive = noDepEntry config.bash.interactive; - } - // (lib.optionalAttrs (config.motd != null) { motd = config.motd; }) - // (lib.optionalAttrs (config.name != null) { name = config.name; }); + config.devshell = { + packages = config.packages; + packagesFrom = config.packagesFrom; + startup.bash_extra = noDepEntry config.bash.extra; + interactive.bash_interactive = noDepEntry config.bash.interactive; + } + // (lib.optionalAttrs (config.motd != null) { motd = config.motd; }) + // (lib.optionalAttrs (config.name != null) { name = config.name; }); } diff --git a/modules/devshell.nix b/modules/devshell.nix index 608b3ba..68d6e95 100644 --- a/modules/devshell.nix +++ b/modules/devshell.nix @@ -393,43 +393,42 @@ in packages = lib.foldl' (sum: drv: sum ++ (inputsOf drv)) [ ] cfg.packagesFrom; - startup = - { - motd = lib.noDepEntry '' - __devshell-motd() { - ${pkgs.coreutils}/bin/cat <