Skip to content

Commit 45439a6

Browse files
committed
feat: re-enable use flags and link flags
1 parent 58a9183 commit 45439a6

File tree

2 files changed

+76
-1
lines changed

2 files changed

+76
-1
lines changed

flake.nix

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,30 @@
321321
hash = "sha256-eAiCtSJUqLASapxnYCyq1UCiGz6QmKQum7Vs3MoU1s8=";
322322
};
323323
});
324+
instructor = python-prev.instructor.overridePythonAttrs (old: {
325+
src = final.fetchFromGitHub {
326+
owner = "jxnl";
327+
repo = "instructor";
328+
tag = "v1.11.3";
329+
hash = "sha256-VWFrMgfe92bHUK1hueqJLHQ7G7ATCgK7wXr+eqrVWcw=";
330+
};
331+
});
332+
pypng = python-prev.pypng.overridePythonAttrs (old: {
333+
src = final.fetchFromGitLab {
334+
owner = "drj11";
335+
repo = "pypng";
336+
tag = "pypng-0.20231004.0";
337+
hash = "sha256-xNUI3yGfwmaccCxgljIZzgJ6YgNxcuOzCXDE7RFJP2I=";
338+
};
339+
});
340+
rank-bm25 = python-prev.rank-bm25.overridePythonAttrs (old: {
341+
src = final.fetchFromGitHub {
342+
owner = "dorianbrown";
343+
repo = "rank_bm25"; # Corrected from hyphen to underscore
344+
tag = old.version; # Often tags are prefixed with 'v'
345+
hash = "sha256-+BxQBflMm2AvCLAFFj52Jpkqn+KErwYXU1wztintgOg="; # Updated hash
346+
};
347+
});
324348
})
325349
];
326350
haskellPackages = prev.haskellPackages.extend (

utility-functions.nix

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,58 @@ in
4141
warnUndeclaredOptions = true;
4242
fetchedSourceNameDefault = "full";
4343
doCheckByDefault = false;
44-
# replaceStdenv = ({ pkgs }: pkgs.clangStdenv);
44+
replaceStdenv =
45+
{ pkgs }:
46+
let
47+
customStdenv =
48+
stdenv:
49+
stdenv.override (old: {
50+
allowedRequisites = null;
51+
mkDerivationFromStdenv =
52+
stdenvSelf:
53+
let
54+
defaultMkDerivationFromStdenv =
55+
stdenv:
56+
(import (pkgs.path + "/pkgs/stdenv/generic/make-derivation.nix") {
57+
inherit (pkgs) lib config;
58+
} stdenv).mkDerivation;
59+
mkDerivationSuper = (old.mkDerivationFromStdenv or defaultMkDerivationFromStdenv) stdenvSelf;
60+
in
61+
args:
62+
let
63+
extraCompile = " -pipe";
64+
extraLink = " -Wl,-z,pack-relative-relocs";
65+
66+
# Function to apply flags to either env.FLAG or top-level FLAG
67+
applyFlags = currentAttrs: flagName: flagsToAdd:
68+
let
69+
valEnv = if currentAttrs ? env then (currentAttrs.env.${flagName} or "") else "";
70+
valTop = if currentAttrs ? ${flagName} then (currentAttrs.${flagName}) else "";
71+
# Combine existing env + top-level + new flags
72+
combined = toString valEnv + " " + toString valTop + flagsToAdd;
73+
in
74+
# ALWAYS put flags in env and remove from top-level.
75+
# This avoids conflicts if overrideAttrs later introduces env/structured attrs.
76+
# Legacy mkDerivation supports env vars too.
77+
(builtins.removeAttrs currentAttrs [ flagName ]) // {
78+
env = (currentAttrs.env or {}) // {
79+
${flagName} = combined;
80+
};
81+
};
82+
83+
processArgs = attrs:
84+
let
85+
attrsWithCompileFlags = applyFlags attrs "NIX_CFLAGS_COMPILE" extraCompile;
86+
in
87+
applyFlags attrsWithCompileFlags "NIX_CFLAGS_LINK" extraLink;
88+
in
89+
if builtins.isFunction args then
90+
mkDerivationSuper (self: processArgs (args self))
91+
else
92+
mkDerivationSuper (processArgs args);
93+
});
94+
in
95+
customStdenv pkgs.stdenv;
4596

4697
# RUSTFLAGS = "-C target-cpu=znver3 ";
4798
# permittedInsecurePackages = [ "nix-2.15.3" ];

0 commit comments

Comments
 (0)