diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-02-23 18:13:06 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-02-23 18:13:37 +0900 |
| commit | 8bf162820b291cc3889fd05f4ba7cd4fcbc1d15d (patch) | |
| tree | 53b44cc353629e300d6096345ea0e8cfcc64595f /tests/fortify/default.nix | |
| parent | dccb3666080686da73159680590352c23cf69c4f (diff) | |
nix: separate fsu from package
This appears to be the only way to build them with different configuration. This enables static linking in the main package.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'tests/fortify/default.nix')
| -rw-r--r-- | tests/fortify/default.nix | 60 |
1 files changed, 28 insertions, 32 deletions
diff --git a/tests/fortify/default.nix b/tests/fortify/default.nix index 44879413..4342567f 100644 --- a/tests/fortify/default.nix +++ b/tests/fortify/default.nix @@ -1,44 +1,40 @@ { - system, - self, + lib, nixosTest, writeShellScriptBin, + + system, + self, + withRace ? false, }: nixosTest { - name = "fortify"; - nodes.machine = { - environment.systemPackages = [ - # For go tests: - self.packages.${system}.fhs - (writeShellScriptBin "fortify-src" "echo -n ${self.packages.${system}.fortify.src}") - ]; - - # Run with Go race detector: - environment.fortify.package = - let - inherit (self.packages.${system}) fortify; - in - fortify.overrideAttrs (previousAttrs: { - GOFLAGS = previousAttrs.GOFLAGS ++ [ "-race" ]; + name = "fortify" + (if withRace then "-race" else ""); + nodes.machine = + { options, pkgs, ... }: + { + environment.systemPackages = [ + # For go tests: + self.packages.${system}.fhs + (writeShellScriptBin "fortify-src" "echo -n ${self.packages.${system}.fortify.src}") + ]; - # fsu does not like cgo - disallowedReferences = previousAttrs.disallowedReferences ++ [ fortify ]; - postInstall = - previousAttrs.postInstall - + '' - cp -a "${fortify}/libexec/fsu" "$out/libexec/fsu" - sed -i 's:${fortify}:${placeholder "out"}:' "$out/libexec/fsu" - ''; - }); + # Run with Go race detector: + environment.fortify = lib.mkIf withRace rec { + # race detector does not support static linking + package = (pkgs.callPackage ../../package.nix { }).overrideAttrs (previousAttrs: { + GOFLAGS = previousAttrs.GOFLAGS ++ [ "-race" ]; + }); + fsuPackage = options.environment.fortify.fsuPackage.default.override { fortify = package; }; + }; - imports = [ - ./configuration.nix + imports = [ + ./configuration.nix - self.nixosModules.fortify - self.inputs.home-manager.nixosModules.home-manager - ]; - }; + self.nixosModules.fortify + self.inputs.home-manager.nixosModules.home-manager + ]; + }; # adapted from nixos sway integration tests |
