|
6 | 6 | nixMods = inputs.self.nixosModules; |
7 | 7 | inherit (inputs.self) lib; |
8 | 8 |
|
9 | | - laptop-configuration = import ./mkLaptopConfiguration.nix { inherit inputs; }; |
10 | | - installer-config = import ./mkInstaller.nix { inherit inputs; }; |
| 9 | + # The versionRev is used to identify the current version of the configuration. |
| 10 | + # rev is used when there is a clean repo |
| 11 | + # dirtyRev is used when there are uncommitted changes |
| 12 | + # if building in a rebased ci pre-merge check the state will be unknown. |
| 13 | + versionRev = |
| 14 | + if (inputs.self ? shortRev) then |
| 15 | + inputs.self.shortRev |
| 16 | + else if (inputs.self ? dirtyShortRev) then |
| 17 | + inputs.self.dirtyShortRev |
| 18 | + else |
| 19 | + "unknown-dirty-rev"; |
| 20 | + |
| 21 | + # Use the builder functions exported from ghaf |
| 22 | + mkLaptopConfiguration = inputs.ghaf.builders.mkLaptopConfiguration { |
| 23 | + self = inputs.ghaf; |
| 24 | + inherit inputs; |
| 25 | + inherit (inputs.ghaf) lib; |
| 26 | + inherit system; |
| 27 | + }; |
| 28 | + |
| 29 | + mkLaptopInstaller = inputs.ghaf.builders.mkLaptopInstaller { |
| 30 | + self = inputs.ghaf; |
| 31 | + inherit (inputs.ghaf) lib; |
| 32 | + inherit system; |
| 33 | + }; |
| 34 | + |
| 35 | + # Wrapper function to adapt to our naming convention and add versionRev |
| 36 | + laptop-configuration = |
| 37 | + name: extraModules: |
| 38 | + let |
| 39 | + # Extract machine type from name (everything before the last "-debug" or "-release") |
| 40 | + parts = lib.splitString "-" name; |
| 41 | + variant = lib.last parts; |
| 42 | + machineType = lib.concatStringsSep "-" (lib.init parts); |
| 43 | + |
| 44 | + # Create base configuration with ghaf function |
| 45 | + baseConfig = mkLaptopConfiguration machineType variant ( |
| 46 | + [ |
| 47 | + { |
| 48 | + nixpkgs.overlays = [ |
| 49 | + inputs.self.overlays.custom-packages |
| 50 | + inputs.self.overlays.own-pkgs-overlay |
| 51 | + ]; |
| 52 | + system = { |
| 53 | + configurationRevision = versionRev; |
| 54 | + nixos.label = versionRev; |
| 55 | + }; |
| 56 | + } |
| 57 | + ] |
| 58 | + ++ extraModules |
| 59 | + ); |
| 60 | + in |
| 61 | + { |
| 62 | + hostConfig = baseConfig.hostConfiguration; |
| 63 | + inherit (baseConfig) package variant; |
| 64 | + inherit name; # Use original FMO name for output |
| 65 | + }; |
| 66 | + |
| 67 | + # Wrapper function for installer to match our existing interface |
| 68 | + installer-config = |
| 69 | + name: imagePath: extraModules: |
| 70 | + let |
| 71 | + installerResult = mkLaptopInstaller name imagePath extraModules; |
| 72 | + in |
| 73 | + { |
| 74 | + hostConfig = installerResult.hostConfiguration; |
| 75 | + inherit (installerResult) name package; |
| 76 | + }; |
11 | 77 |
|
12 | 78 | installerModules = [ |
13 | 79 | ( |
|
0 commit comments