|
| 1 | +{ |
| 2 | + inputs.utils.url = path:../../; |
| 3 | + inputs.nixpkgs.url = github:NixOS/nixpkgs/; |
| 4 | + |
| 5 | + outputs = inputs@{ self, nixpkgs, utils }: |
| 6 | + utils.lib.mkFlake { |
| 7 | + inherit self inputs; |
| 8 | + supportedSystems = [ "x86_64-linux" ]; |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | + ################# |
| 14 | + ### Test Data ### |
| 15 | + ################# |
| 16 | + |
| 17 | + channelsConfig.allowBroken = true; |
| 18 | + |
| 19 | + channels.nixpkgs = { |
| 20 | + input = nixpkgs; |
| 21 | + patches = [ |
| 22 | + (pkgs: pkgs.runCommand "myNixpkgsPatch.patch" { } "cp ${./myNixpkgsPatch.patch} $out") |
| 23 | + ]; |
| 24 | + config.allowUnfree = true; |
| 25 | + }; |
| 26 | + |
| 27 | + hosts.PatchedHost.modules = [ |
| 28 | + ({ lib, ... }: { |
| 29 | + patchedModule.test = lib.patchedFunction "using patched module via patched function"; |
| 30 | + |
| 31 | + # To keep Nix from complaining |
| 32 | + boot.loader.grub.devices = [ "nodev" ]; |
| 33 | + fileSystems."/" = { device = "test"; fsType = "ext4"; }; |
| 34 | + }) |
| 35 | + ]; |
| 36 | + |
| 37 | + |
| 38 | + outputsBuilder = channels: { |
| 39 | + |
| 40 | + packages = { |
| 41 | + # Using patched channel |
| 42 | + inherit (channels.nixpkgs) flake-utils-plus-test; |
| 43 | + }; |
| 44 | + |
| 45 | + |
| 46 | + |
| 47 | + ###################### |
| 48 | + ### Test execution ### |
| 49 | + ###################### |
| 50 | + |
| 51 | + checks = |
| 52 | + let |
| 53 | + inherit (utils.lib.check-utils channels.nixpkgs) hasKey isEqual; |
| 54 | + hostConfig = self.nixosConfigurations.PatchedHost.config; |
| 55 | + in |
| 56 | + { |
| 57 | + |
| 58 | + # Patched package gets passed to `packageBuilder` |
| 59 | + patchedPackageGetsPassedToBuilders = isEqual self.packages.x86_64-linux.flake-utils-plus-test.pname "coreutils"; |
| 60 | + |
| 61 | + # Modules (and lib) from patched nixpkgs are used |
| 62 | + patchedModuleAndFunctionWorks = isEqual hostConfig.patchedModule.test "using patched module via patched function"; |
| 63 | + |
| 64 | + # `channelsConfig.*` is used |
| 65 | + globalChannelConfigWorks = hasKey hostConfig.nixpkgs.pkgs.config "allowBroken"; |
| 66 | + |
| 67 | + # `channels.nixpkgs.config.*` is also used |
| 68 | + channelSpecificConfigWorks = hasKey hostConfig.nixpkgs.pkgs.config "allowUnfree"; |
| 69 | + |
| 70 | + }; |
| 71 | + }; |
| 72 | + |
| 73 | + |
| 74 | + }; |
| 75 | +} |
| 76 | + |
| 77 | + |
| 78 | + |
| 79 | + |
0 commit comments