aboutsummaryrefslogtreecommitdiffhomepage
path: root/flake.nix
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-01-16 17:32:52 +0900
committerOphestra <cat@gensokyo.uk>2025-01-16 17:32:52 +0900
commitb60c01f4405ec3b5cc4a740fe994c3b9f39cf01f (patch)
tree3d43cd726a26bba2336d2373a6dfe65a567a35a8 /flake.nix
parent124743ffd3da7c31ef9c562593e15d88bb19008e (diff)
fortify: switch to static linking
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'flake.nix')
-rw-r--r--flake.nix150
1 files changed, 96 insertions, 54 deletions
diff --git a/flake.nix b/flake.nix
index 7e156a39..0277975a 100644
--- a/flake.nix
+++ b/flake.nix
@@ -95,72 +95,114 @@
packages = forAllSystems (
system:
let
+ inherit (self.packages.${system}) fortify;
pkgs = nixpkgsFor.${system};
in
{
default = self.packages.${system}.fortify;
-
fortify = pkgs.callPackage ./package.nix { };
+
+ dist =
+ pkgs.runCommand "${fortify.name}-dist" { inherit (self.devShells.${system}.default) buildInputs; }
+ ''
+ # go requires XDG_CACHE_HOME for the build cache
+ export XDG_CACHE_HOME="$(mktemp -d)"
+
+ # get a different workdir as go does not like /build
+ cd $(mktemp -d) && cp -r ${fortify.src}/. . && chmod -R +w .
+
+ export FORTIFY_VERSION="v${fortify.version}"
+ ./dist/release.sh && mkdir $out && cp -v "dist/fortify-$FORTIFY_VERSION.tar.gz"* $out
+ '';
+
+ fhs = pkgs.buildFHSEnv {
+ pname = "fortify-fhs";
+ inherit (fortify) version;
+ targetPkgs =
+ pkgs:
+ with pkgs;
+ [
+ go
+ gcc
+ pkg-config
+ wayland-scanner
+ ]
+ ++ (
+ with pkgs.pkgsStatic;
+ [
+ musl
+ libffi
+ acl
+ wayland
+ wayland-protocols
+ ]
+ ++ (with xorg; [
+ libxcb
+ libXau
+ libXdmcp
+
+ xorgproto
+ ])
+ );
+ extraOutputsToInstall = [ "dev" ];
+ profile = ''
+ export PKG_CONFIG_PATH="/usr/share/pkgconfig:$PKG_CONFIG_PATH"
+ '';
+ };
}
);
- devShells = forAllSystems (system: {
- default = nixpkgsFor.${system}.mkShell {
- buildInputs = with nixpkgsFor.${system}; self.packages.${system}.fortify.buildInputs;
- };
+ devShells = forAllSystems (
+ system:
+ let
+ inherit (self.packages.${system}) fortify fhs;
+ pkgs = nixpkgsFor.${system};
+ in
+ {
+ default = pkgs.mkShell {
+ buildInputs =
+ with pkgs;
+ [
+ go
+ gcc
+ ]
+ ++ fortify.buildInputs
+ ++ fortify.nativeBuildInputs;
+ };
- fhs = nixpkgsFor.${system}.buildFHSEnv {
- pname = "fortify-fhs";
- inherit (self.packages.${system}.fortify) version;
- targetPkgs =
- pkgs: with pkgs; [
- go
- gcc
- pkg-config
- acl
- wayland
- wayland-scanner
- wayland-protocols
- xorg.libxcb
- ];
- extraOutputsToInstall = [ "dev" ];
- profile = ''
- export PKG_CONFIG_PATH="/usr/share/pkgconfig:$PKG_CONFIG_PATH"
- '';
- };
+ fhs = fhs.env;
- withPackage = nixpkgsFor.${system}.mkShell {
- buildInputs =
- with nixpkgsFor.${system};
- self.packages.${system}.fortify.buildInputs ++ [ self.packages.${system}.fortify ];
- };
+ withPackage = nixpkgsFor.${system}.mkShell {
+ buildInputs = [ self.packages.${system}.fortify ] ++ self.devShells.${system}.default.buildInputs;
+ };
- generateDoc =
- let
- pkgs = nixpkgsFor.${system};
- inherit (pkgs) lib;
+ generateDoc =
+ let
+ pkgs = nixpkgsFor.${system};
+ inherit (pkgs) lib;
- doc =
- let
- eval = lib.evalModules {
- specialArgs = {
- inherit pkgs;
+ doc =
+ let
+ eval = lib.evalModules {
+ specialArgs = {
+ inherit pkgs;
+ };
+ modules = [ ./options.nix ];
};
- modules = [ ./options.nix ];
- };
- cleanEval = lib.filterAttrsRecursive (n: _: n != "_module") eval;
- in
- pkgs.nixosOptionsDoc { inherit (cleanEval) options; };
- docText = pkgs.runCommand "fortify-module-docs.md" { } ''
- cat ${doc.optionsCommonMark} > $out
- sed -i '/*Declared by:*/,+1 d' $out
- '';
- in
- nixpkgsFor.${system}.mkShell {
- shellHook = ''
- exec cat ${docText} > options.md
- '';
- };
- });
+ cleanEval = lib.filterAttrsRecursive (n: _: n != "_module") eval;
+ in
+ pkgs.nixosOptionsDoc { inherit (cleanEval) options; };
+ docText = pkgs.runCommand "fortify-module-docs.md" { } ''
+ cat ${doc.optionsCommonMark} > $out
+ sed -i '/*Declared by:*/,+1 d' $out
+ '';
+ in
+ nixpkgsFor.${system}.mkShell {
+ shellHook = ''
+ exec cat ${docText} > options.md
+ '';
+ };
+ }
+ );
};
}