From 6bc9fe42a2cadc771c178f289207b914e8ec37a1 Mon Sep 17 00:00:00 2001 From: sinanmohd Date: Sat, 6 Sep 2025 09:31:20 +0530 Subject: fix(os/common/nix): nix develop interactive shell --- flake.lock | 60 +++++++++++++++++++-------------------- flake.nix | 2 +- os/common/configuration.nix | 2 +- os/common/modules/nix.nix | 33 --------------------- os/common/modules/nix/default.nix | 51 +++++++++++++++++++++++++++++++++ os/common/modules/nix/nix.patch | 53 ++++++++++++++++++++++++++++++++++ 6 files changed, 136 insertions(+), 65 deletions(-) delete mode 100644 os/common/modules/nix.nix create mode 100644 os/common/modules/nix/default.nix create mode 100644 os/common/modules/nix/nix.patch diff --git a/flake.lock b/flake.lock index f5d92be..f6ac1c3 100644 --- a/flake.lock +++ b/flake.lock @@ -33,12 +33,12 @@ "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1755716744, - "narHash": "sha256-QNc4TY7l/NIkPpuFSXGAUnAFpsz4GiYAwGFyYXEJ9lc=", - "rev": "8519a444f0b337d222c9a0e89eba4f531de5eace", - "revCount": 287, + "lastModified": 1757033802, + "narHash": "sha256-BLUHtWWoHFR6UJJJwkmivSv7RTjo92wlT0Y7kbCd2MY=", + "rev": "e154f8433851f8f2509490f33680e3285d553df4", + "revCount": 301, "type": "tarball", - "url": "https://api.flakehub.com/f/pinned/DeterminateSystems/determinate/3.8.6/0198c8e2-c539-7713-a109-3ff0e73574dd/source.tar.gz" + "url": "https://api.flakehub.com/f/pinned/DeterminateSystems/determinate/3.11.1/01991762-b4e5-7a3b-8bfc-5d0f1ed4965e/source.tar.gz" }, "original": { "type": "tarball", @@ -48,37 +48,37 @@ "determinate-nixd-aarch64-darwin": { "flake": false, "locked": { - "narHash": "sha256-TXc1t7wbUtzwyytrZMR9SoTsUdoXatDf45aoNndaonY=", + "narHash": "sha256-Dym4kTLMTxAxNyZcrHRKRVMBINQPA7qgr+7dHozNrps=", "type": "file", - "url": "https://install.determinate.systems/determinate-nixd/tag/v3.8.6/macOS" + "url": "https://install.determinate.systems/determinate-nixd/tag/v3.11.1/macOS" }, "original": { "type": "file", - "url": "https://install.determinate.systems/determinate-nixd/tag/v3.8.6/macOS" + "url": "https://install.determinate.systems/determinate-nixd/tag/v3.11.1/macOS" } }, "determinate-nixd-aarch64-linux": { "flake": false, "locked": { - "narHash": "sha256-MaD8woffmbfytD/1Ism5xLhonTlCzXyTU6TmVpin2vU=", + "narHash": "sha256-eYVSpk+ly2YRSYvgT47ABmFRwG0DliNO/8ntBkoRmjI=", "type": "file", - "url": "https://install.determinate.systems/determinate-nixd/tag/v3.8.6/aarch64-linux" + "url": "https://install.determinate.systems/determinate-nixd/tag/v3.11.1/aarch64-linux" }, "original": { "type": "file", - "url": "https://install.determinate.systems/determinate-nixd/tag/v3.8.6/aarch64-linux" + "url": "https://install.determinate.systems/determinate-nixd/tag/v3.11.1/aarch64-linux" } }, "determinate-nixd-x86_64-linux": { "flake": false, "locked": { - "narHash": "sha256-cAXTuExL/7cmdzXM0vJLuHvExpjmv39+vWwgJyKbZnA=", + "narHash": "sha256-ZvRoKG/v0WS2XrDgkV+/hq3ARGokGisyelncKwlefvk=", "type": "file", - "url": "https://install.determinate.systems/determinate-nixd/tag/v3.8.6/x86_64-linux" + "url": "https://install.determinate.systems/determinate-nixd/tag/v3.11.1/x86_64-linux" }, "original": { "type": "file", - "url": "https://install.determinate.systems/determinate-nixd/tag/v3.8.6/x86_64-linux" + "url": "https://install.determinate.systems/determinate-nixd/tag/v3.11.1/x86_64-linux" } }, "flake-compat": { @@ -174,12 +174,12 @@ "nixpkgs-regression": "nixpkgs-regression" }, "locked": { - "lastModified": 1755685428, - "narHash": "sha256-aHMByu8/6cJsUYffUgM4DnZRiLfBpQM0C9Wa3dCJ87o=", - "rev": "1dd83fd41461e2a4762544f8cd5ad2aa21c842cc", - "revCount": 21634, + "lastModified": 1757029043, + "narHash": "sha256-/XtKs/hpYXJPeT3WppFVFZH1WvPDmeTt11hMWt/Bwas=", + "rev": "7143558a0989008c8e08cc27c3cb6a031f30b356", + "revCount": 22309, "type": "tarball", - "url": "https://api.flakehub.com/f/pinned/DeterminateSystems/nix-src/3.8.6/0198c717-3128-706c-95f8-49294f65c4b7/source.tar.gz" + "url": "https://api.flakehub.com/f/pinned/DeterminateSystems/nix-src/3.11.1/01991737-661d-7932-b7c9-d3a0499b4c3f/source.tar.gz" }, "original": { "type": "tarball", @@ -204,16 +204,16 @@ }, "nixpkgs": { "locked": { - "lastModified": 1747179050, - "narHash": "sha256-qhFMmDkeJX9KJwr5H32f1r7Prs7XbQWtO0h3V0a0rFY=", - "rev": "adaa24fbf46737f3f1b5497bf64bae750f82942e", - "revCount": 799423, + "lastModified": 1755922037, + "narHash": "sha256-wY1+2JPH0ZZC4BQefoZw/k+3+DowFyfOxv17CN/idKs=", + "rev": "b1b3291469652d5a2edb0becc4ef0246fff97a7c", + "revCount": 808723, "type": "tarball", - "url": "https://api.flakehub.com/f/pinned/NixOS/nixpkgs/0.1.799423%2Brev-adaa24fbf46737f3f1b5497bf64bae750f82942e/0196d1c3-1974-7bf1-bcf6-06620ac40c8c/source.tar.gz" + "url": "https://api.flakehub.com/f/pinned/NixOS/nixpkgs/0.2505.808723%2Brev-b1b3291469652d5a2edb0becc4ef0246fff97a7c/0198daf7-011a-7703-95d7-57146e794342/source.tar.gz" }, "original": { "type": "tarball", - "url": "https://flakehub.com/f/NixOS/nixpkgs/%3D0.1.799423" + "url": "https://flakehub.com/f/NixOS/nixpkgs/0.2505" } }, "nixpkgs-23-11": { @@ -250,12 +250,12 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1755268003, - "narHash": "sha256-nNaeJjo861wFR0tjHDyCnHs1rbRtrMgxAKMoig9Sj/w=", - "rev": "32f313e49e42f715491e1ea7b306a87c16fe0388", - "revCount": 844992, + "lastModified": 1756696532, + "narHash": "sha256-6FWagzm0b7I/IGigOv9pr6LL7NQ86mextfE8g8Q6HBg=", + "rev": "58dcbf1ec551914c3756c267b8b9c8c86baa1b2f", + "revCount": 854745, "type": "tarball", - "url": "https://api.flakehub.com/f/pinned/DeterminateSystems/nixpkgs-weekly/0.1.844992%2Brev-32f313e49e42f715491e1ea7b306a87c16fe0388/0198c0d5-28e5-7154-af57-79569c924644/source.tar.gz" + "url": "https://api.flakehub.com/f/pinned/DeterminateSystems/nixpkgs-weekly/0.1.854745%2Brev-58dcbf1ec551914c3756c267b8b9c8c86baa1b2f/019908ed-e731-796e-b7c5-ea173f5d3b8d/source.tar.gz" }, "original": { "type": "tarball", diff --git a/flake.nix b/flake.nix index c1a8191..ec6258d 100644 --- a/flake.nix +++ b/flake.nix @@ -42,6 +42,7 @@ specialArgs = { inherit alina; + inherit determinate; inherit nixos-hardware; }; @@ -68,7 +69,6 @@ ./os/${host}/configuration.nix sops-nix.nixosModules.sops home-manager.nixosModules.home-manager - determinate.nixosModules.default ]; }); diff --git a/os/common/configuration.nix b/os/common/configuration.nix index 7b6b956..afa5de2 100644 --- a/os/common/configuration.nix +++ b/os/common/configuration.nix @@ -12,7 +12,7 @@ in "services/networking/pppd.nix" ]; imports = [ - ./modules/nix.nix + ./modules/nix ./modules/user.nix ./modules/environment.nix ./modules/pppd.nix diff --git a/os/common/modules/nix.nix b/os/common/modules/nix.nix deleted file mode 100644 index 711ead4..0000000 --- a/os/common/modules/nix.nix +++ /dev/null @@ -1,33 +0,0 @@ -{ config, ... }: -let - user = config.global.userdata.name; -in -{ - nix = { - gc = { - automatic = true; - dates = "weekly"; - options = "--delete-older-than 30d"; - }; - - settings = { - auto-optimise-store = true; - use-xdg-base-directories = true; - trusted-users = [ user ]; - - experimental-features = [ - "flakes" - "nix-command" - ]; - - substituters = [ - "https://nixbin.sinanmohd.com" - "https://nix-community.cachix.org" - ]; - trusted-public-keys = [ - "nixbin.sinanmohd.com:dXV3KDPVrm+cGJ2M1ZmTeQJqFGaEapqiVoWHgYDh03k=" - "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" - ]; - }; - }; -} diff --git a/os/common/modules/nix/default.nix b/os/common/modules/nix/default.nix new file mode 100644 index 0000000..bddf978 --- /dev/null +++ b/os/common/modules/nix/default.nix @@ -0,0 +1,51 @@ +{ + config, + pkgs, + determinate, + lib, + ... +}: +let + user = config.global.userdata.name; + + nixWithFix = determinate.inputs.nix.packages.${pkgs.stdenv.system}.nix-everything.override { + nix-cli = determinate.inputs.nix.packages.${pkgs.stdenv.system}.nix-cli.overrideAttrs (oldAttrs: { + patches = (oldAttrs.patches or [ ]) ++ [ + ./nix.patch + ]; + }); + }; +in +{ + imports = [ determinate.nixosModules.default ]; + + nix = { + package = lib.mkForce nixWithFix; + + gc = { + automatic = true; + dates = "weekly"; + options = "--delete-older-than 30d"; + }; + + settings = { + auto-optimise-store = true; + use-xdg-base-directories = true; + trusted-users = [ user ]; + + experimental-features = [ + "flakes" + "nix-command" + ]; + + substituters = [ + "https://nixbin.sinanmohd.com" + "https://nix-community.cachix.org" + ]; + trusted-public-keys = [ + "nixbin.sinanmohd.com:dXV3KDPVrm+cGJ2M1ZmTeQJqFGaEapqiVoWHgYDh03k=" + "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" + ]; + }; + }; +} diff --git a/os/common/modules/nix/nix.patch b/os/common/modules/nix/nix.patch new file mode 100644 index 0000000..4f565d8 --- /dev/null +++ b/os/common/modules/nix/nix.patch @@ -0,0 +1,53 @@ +diff --git a/develop.cc b/develop.cc +index ed25e655d8f..f78eee59abc 100644 +--- a/develop.cc ++++ b/develop.cc +@@ -627,13 +627,12 @@ struct CmdDevelop : Common, MixEnvironment + fmt("[ -n \"$PS1\" ] && PS1+=%s;\n", escapeShellArgAlways(developSettings.bashPromptSuffix.get())); + } + +- writeFull(rcFileFd.get(), script); +- + setEnviron(); + // prevent garbage collection until shell exits + setEnv("NIX_GCROOT", gcroot.c_str()); + + Path shell = "bash"; ++ bool foundInteractive = false; + + try { + auto state = getEvalState(); +@@ -656,19 +655,17 @@ struct CmdDevelop : Common, MixEnvironment + Strings{"legacyPackages." + settings.thisSystem.get() + "."}, + nixpkgsLockFlags); + +- bool found = false; +- + for (auto & path : Installable::toStorePathSet( + getEvalStore(), store, Realise::Outputs, OperateOn::Output, {bashInstallable})) { + auto s = store->printStorePath(path) + "/bin/bash"; + if (pathExists(s)) { + shell = s; +- found = true; ++ foundInteractive = true; + break; + } + } + +- if (!found) ++ if (!foundInteractive) + throw Error("package 'nixpkgs#bashInteractive' does not provide a 'bin/bash'"); + + } catch (Error &) { +@@ -678,6 +675,11 @@ struct CmdDevelop : Common, MixEnvironment + // Override SHELL with the one chosen for this environment. + // This is to make sure the system shell doesn't leak into the build environment. + setEnv("SHELL", shell.c_str()); ++ // https://github.com/NixOS/nix/issues/5873 ++ script += fmt("SHELL=\"%s\"\n", shell); ++ if (foundInteractive) ++ script += fmt("PATH=\"%s${PATH:+:$PATH}\"\n", std::filesystem::path(shell).parent_path()); ++ writeFull(rcFileFd.get(), script); + + #ifdef _WIN32 // TODO re-enable on Windows + throw UnimplementedError("Cannot yet spawn processes on Windows"); -- cgit v1.2.3