static talloc overlay

This commit is contained in:
Sebastian Moser
2024-04-03 10:20:29 +02:00
parent 6996146302
commit 80405f4584
5 changed files with 231 additions and 19 deletions

68
flake.lock generated
View File

@@ -3,7 +3,7 @@
"androidPkgs": {
"inputs": {
"devshell": "devshell",
"flake-utils": "flake-utils_6",
"flake-utils": "flake-utils_7",
"nixpkgs": "nixpkgs_7"
},
"locked": {
@@ -327,6 +327,24 @@
"inputs": {
"systems": "systems_2"
},
"locked": {
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_4": {
"inputs": {
"systems": "systems_3"
},
"locked": {
"lastModified": 1694529238,
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
@@ -341,9 +359,9 @@
"type": "github"
}
},
"flake-utils_4": {
"flake-utils_5": {
"inputs": {
"systems": "systems_3"
"systems": "systems_4"
},
"locked": {
"lastModified": 1701680307,
@@ -359,7 +377,7 @@
"type": "github"
}
},
"flake-utils_5": {
"flake-utils_6": {
"locked": {
"lastModified": 1610051610,
"narHash": "sha256-U9rPz/usA1/Aohhk7Cmc2gBrEEKRzcW4nwPWMPwja4Y=",
@@ -374,7 +392,7 @@
"type": "github"
}
},
"flake-utils_6": {
"flake-utils_7": {
"locked": {
"lastModified": 1638122382,
"narHash": "sha256-sQzZzAbvKEqN9s0bzWuYmRaA03v40gaJ4+iL1LXjaeI=",
@@ -504,7 +522,7 @@
"evil-quick-diff": "evil-quick-diff",
"explain-pause-mode": "explain-pause-mode",
"flake-compat": "flake-compat_2",
"flake-utils": "flake-utils_3",
"flake-utils": "flake-utils_4",
"format-all": "format-all",
"nix-straight": "nix-straight",
"nixpkgs": "nixpkgs_3",
@@ -623,7 +641,7 @@
"nix-wsl": {
"inputs": {
"flake-compat": "flake-compat_3",
"flake-utils": "flake-utils_4",
"flake-utils": "flake-utils_5",
"nixpkgs": "nixpkgs_4"
},
"locked": {
@@ -1041,7 +1059,7 @@
},
"podman": {
"inputs": {
"flake-utils": "flake-utils_5",
"flake-utils": "flake-utils_6",
"nixpkgs": "nixpkgs_6"
},
"locked": {
@@ -1098,6 +1116,7 @@
"inputs": {
"firefox": "firefox",
"firefox-addons": "firefox-addons",
"flake-utils": "flake-utils_3",
"home-manager": "home-manager",
"my-log": "my-log",
"networkmanager": "networkmanager",
@@ -1111,7 +1130,8 @@
"nixpkgs-for-bootstrap": "nixpkgs-for-bootstrap_2",
"nixpkgs-unstable": "nixpkgs-unstable",
"podman": "podman",
"robotnix": "robotnix"
"robotnix": "robotnix",
"systems": "systems_5"
}
},
"rotate-text": {
@@ -1191,6 +1211,36 @@
"type": "github"
}
},
"systems_4": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"systems_5": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"ts-fold": {
"flake": false,
"locked": {

View File

@@ -64,15 +64,33 @@
podman.url = "github:ES-Nix/podman-rootless";
flake-utils.url = "github:numtide/flake-utils";
systems.url = "github:nix-systems/default";
};
outputs = { self, nixpkgs, nixos-generators, ... }@inputs:
outputs = { self, nixpkgs, nixos-generators, flake-utils, systems, ... }@inputs:
let
confDir = "/home/me/work/config";
workDir = "/home/me/work";
secretsDir = "/home/me/work/here/secrets";
persistentDir = "/home/me/work/app-data";
tunepkgs = import nixpkgs {
localSystem = {
gcc.arch = "kabylake";
gcc.tune = "kabylake";
system = "x86_64-linux";
};
#system = "x86_64-linux";
#overlays = [
#(self: super: {
#stdenv = super.impureUseNativeOptimizations super.stdenv;
#})
#];
};
mypkgs = import nixpkgs {
system = "x86_64-linux";
config = {
@@ -89,7 +107,7 @@
};
specialArgs = {
inherit inputs confDir workDir secretsDir persistentDir self;
inherit inputs confDir workDir secretsDir persistentDir self tunepkgs;
system = "x86_64-linux";
pkgs = mypkgs;
};
@@ -340,6 +358,16 @@
};
packages.x86_64-linux = {
tunefox = mypkgs.firefox-unwrapped.overrideAttrs (final: prev: {
NIX_CFLAGS_COMPILE = [ (prev.NIX_CFLAGS_COMPILE or "") ] ++ [ "-O3" "-march=native" "-fPIC" ];
requireSigning = false;
});
pkgsWithOverlays = import nixpkgs {
system = "x86_64-linux";
overlays = [ ./overlays/static-overlay.nix ./overlays/my-overlay.nix ];
};
hi = self.nixosConfigurations.the-most-default.config.system.build.toplevel;
#testing = nixpkgs.legacyPackages.x86_64-linux;
testing = (nixpkgs.legacyPackages.x86_64-linux.writeShellApplication {
@@ -349,14 +377,6 @@
text = ''${inputs.my-log.packages.x86_64-linux.pythonForLog}/bin/python ${workDir}/log/new/client.py "$@"'';
});
test = nixpkgs.legacyPackages.x86_64-linux.firefox-devedition-unwrapped.overrideAttrs (old: {
NIX_CFLAGS_COMPILE = [ (old.NIX_CFLAGS_COMPILE or "") ] ++ [ "-O3" "-march=native" "-fPIC" ];
#hi = builtins.trace ("hello world: " + old.passthru.unwrapped.name) 4;
#passthru.unwrapped = old.passthru.unwrapped.overrideAttrs (innerOld: {
#NIX_CFLAGS_COMPILE = [ (innerOld.NIX_CFLAGS_COMPILE or "") ] ++ [ "-O3" "-march=native" "-fPIC" ];
#});
});
#test = inputs.firefox.packages.${nixpkgs.legacyPackages.x86_64-linux.pkgs.system}; #.firefox-nightly-bin.overrideAttrs (old: {
#NIX_CFLAGS_COMPILE = [ (old.NIX_CFLAGS_COMPILE or "") ] ++ [ "-O3" "-march=native" "-fPIC" ];
#});
@@ -408,8 +428,10 @@
};
};
tunepkgs = tunepkgs;
pkgs = mypkgs;
home.me = import ./users/me/gui-home.nix;
top = builtins.mapAttrs (name: value: value.config.system.build.toplevel) (self.nixOnDroidConfigurations // self.nixosConfigurations);
#nur = let nur-systems = [ "x86_64-linux" "aarch64-linux" ]; in flake-utils.eachDefaultSystem (system: inputs.nixpkgs-unstable.legacyPackages.${system}.callPackage ./nur.nix {});
};
}

View File

@@ -0,0 +1,20 @@
diff --git a/buildtools/wafsamba/wscript b/buildtools/wafsamba/wscript
index dcc8a65..3e42d43 100644
--- a/buildtools/wafsamba/wscript
+++ b/buildtools/wafsamba/wscript
@@ -305,7 +305,15 @@ def configure(conf):
conf.CHECK_CC_ENV()
conf.load('compiler_c')
+
+ # This seems to be the only way to not include the -Wl,-Bdynamic in the linker gcc cmdline
+ # because it is assumed as a common gcc flag in $src/third_party/waf/waflib/Tools/gcc.py
+ # and disabled only for certain platforms with no way to disable it from eg an ENV Variable
+ # export SHLIB_MARKER = "" is picked up by waf (just before conf.load conf.env.SHLIB_MARKER is "")
+ # but the conf.load("compiler_c") overwrites that
+ # on the alpine static build it is no problem to have both -Wl,-Bdynamic and -Wl,-Bstatic
+ # but on nix it is a problem
+ conf.env.SHLB_MARKER = ""
conf.CHECK_STANDARD_LIBPATH()

120
overlays/static-overlay.nix Normal file
View File

@@ -0,0 +1,120 @@
{ nixpkgs, ... }: final: prev: {
# talloc for proot
talloc = prev.talloc.overrideAttrs (innerFinal: innerPrev: {
wafConfigureFlags = innerPrev.wafConfigureFlags ++ [ "--disable-python" ];
patches = innerPrev.patches ++ [ ./patches/talloc-satic.patch ];
});
# for static builds
duktape = prev.duktape.overrideAttrs (innerFinal: innerPrev: {
patches = innerPrev.patches or [] ++ [
./static/duktape.patch
];
#unpackPhase = "echo hiiiiiiiiiiiiiiiiiiiiiiiiiii";
#buildPhase = "echo hiiiiiiiiiiiiiiiiiiiiiiiiii";
buildPhase = ''
make -f dist-files/Makefile.staticlibrary
make -f Makefile.cmdline
'';
installPhase = ''
install -d $out/bin
install -m755 duk $out/bin/
install -d $out/lib/pkgconfig
install -d $out/include
make -f dist-files/Makefile.staticlibrary install INSTALL_PREFIX=$out
substituteAll ${nixpkgs}/pkgs/development/interpreters/duktape/duktape.pc.in $out/lib/pkgconfig/duktape.pc
'';
});
dconf = prev.dconf.overrideAttrs (innerFinal: innerPrev: {
patches = innerPrev.patches or [] ++ [
./static/dconf.patch
];
});
at-spi2-core = prev.at-spi2-core.overrideAttrs (innerFinal: innerPrev: {
mesonFlags = innerPrev.mesonFlags or [] ++ [
"-Dintrospection=disabled"
"-Ddbus_broker=default"
"-Dgtk2_atk_adaptor=false"
];
});
cdparanoia = prev.cdparanoia.overrideAttrs (innerFinal: innerPrev: {
patches = innerPrev.patches or [] ++ [
./static/cdparanoia.patch
];
});
# this is a mess....
#pkgsStatic = prev.pkgsStatic // {gobject-introspection = prev.callPackage ./static/gobject-introspection.nix { inherit nixpkgs; };};
#gobject-introspection = prev.callPackage ./static/gobject-introspection.nix { inherit nixpkgs; };
#buildPackges = prev.buildPackges // {gobject-introspection = prev.callPackage ./static/gobject-introspection.nix { inherit nixpkgs; };};
# .... gobject-introspection is just not made for dyn linking
python311Packages = prev.python311Packages // { lxml = prev.python311Packages.lxml.overrideAttrs (innerFinal: innerPrev:
let
libxmlSrc = prev.fetchurl {
url = "mirror://gnome/sources/libxml2/${prev.lib.versions.majorMinor "2.12.4"}/libxml2-2.12.4.tar.xz";
sha256 = "sha256-SXNg5CPPC9merNt8YhXeqS5tbonulAOTwrrg53y5t9A=";
};
zlibSrc = let version = "1.3.1"; in prev.fetchurl {
urls = [
# This URL works for 1.2.13 only; hopefully also for future releases.
"https://github.com/madler/zlib/releases/download/v${version}/zlib-${version}.tar.gz"
# Stable archive path, but captcha can be encountered, causing hash mismatch.
"https://www.zlib.net/fossils/zlib-${version}.tar.gz"
];
hash = "sha256-mpOyt9/ax3zrpaVYpYDnRmfdb+3kWFuR7vtg8Dty3yM=";
};
libiconvSrc = prev.fetchurl {
url = "https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.17.tar.gz";
hash = "sha256-j3QhO1YjjIWlClMp934GGYdx5w3Zpzl3n0wC9l2XExM=";
};
libxsltSrc = let version = "1.1.37"; pname = "libxslt"; in prev.fetchurl {
url = "mirror://gnome/sources/${pname}/${prev.lib.versions.majorMinor version}/${pname}-${version}.tar.xz";
sha256 = "Oksn3IAnzNYUZyWVAzbx7FIJKPMg8UTrX6eZCuYSOrQ=";
};
in
{
setupPyBuildFlags = [
"--libxml2-version=2.12.4"
"--libxslt-version=1.1.37"
"--zlib-version=1.3.1"
"--libiconv-version=1.17"
"--without-cython"
];
patches = [
./static/python311Packages-lxml.patch
# built without any extensions ... hardcoded with a patch
];
STATICBUILD = true;
preConfigure = ''
mkdir -p ./libs
cp ${zlibSrc} ./libs/${zlibSrc.name}
cp ${libiconvSrc} ./libs/${libiconvSrc.name}
cp ${libxmlSrc} ./libs/${libxmlSrc.name}
cp ${libxsltSrc} ./libs/${libxsltSrc.name}
ls ./libs
'';
#cat ${libxsltSrc} | xz -d | gzip > ./libs/${libxsltSrc.name}
#cat ${libxmlSrc} | xz -d | gzip > ./libs/${libxmlSrc.name}
#mv ./libs/libxslt-1.1.37.tar.xz ./libs/libxslt-1.1.37.tar.gz
#mv ./libs/libxml2-2.10.4.tar.xz ./libs/libxml2-2.10.4.tar.gz
});
};
pkgsStatic = prev.pkgsStatic // {
libglvnd = prev.libglvnd;
gonme2.libIDL = prev.gnome2.libIDL;
libjpeg-turbe = prev.libjpeg-turbo;
};
}