From 03c5f82dbfe8877ddbbea05a66d8bb77bd4c8d9c Mon Sep 17 00:00:00 2001 From: Colin Date: Tue, 27 Feb 2024 10:34:20 +0000 Subject: [PATCH] flake: fix sourceInfo propagation (and hence, nixosConfiguration naming!) --- flake.nix | 34 ++++++++++++++++++++++------------ nixpatches/flake.nix | 5 +++-- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/flake.nix b/flake.nix index e5838c164..a29cf6fdb 100644 --- a/flake.nix +++ b/flake.nix @@ -98,19 +98,29 @@ inherit variant nixpkgs; self = patchNixpkgs variant nixpkgs; } // { - # provide values that nixpkgs ordinarily sources from the flake.lock file, - # inaccessible to it here because of the import-from-derivation. - # rev and shortRev seem to not always exist (e.g. if the working tree is dirty), - # so those are made conditional. + # sourceInfo includes fields (square brackets for the ones which are not always present): + # - [dirtyRev] + # - [dirtyShortRev] + # - lastModified + # - lastModifiedDate + # - narHash + # - outPath + # - [rev] + # - [revCount] + # - [shortRev] + # - submodules # - # these values impact the name of a produced nixos system. having date/rev in the - # `readlink /run/current-system` store path helps debuggability. - inherit (self) lastModifiedDate lastModified; - } // optionalAttrs (self ? rev) { - inherit (self) rev; - } // optionalAttrs (self ? shortRev) { - inherit (self) shortRev; - }; + # these values are used within nixpkgs: + # - to give a friendly name to the nixos system (`readlink /run/current-system` -> `...nixos-system-desko-24.05.20240227.dirty`) + # - to alias `import ` so that nix uses the system's nixpkgs when called externally (supposedly). + # + # these values seem to exist both within the `sourceInfo` attrset and at the top-level. + # for a list of all implicit flake outputs (which is what these seem to be): + # $ nix-repl + # > lf . + # > + inherit (self) sourceInfo; + } // self.sourceInfo; nixpkgs' = patchNixpkgs "master" nixpkgs-unpatched; nixpkgsCompiledBy = system: nixpkgs'.legacyPackages."${system}"; diff --git a/nixpatches/flake.nix b/nixpatches/flake.nix index ed247fd05..cff5a0f2c 100644 --- a/nixpatches/flake.nix +++ b/nixpatches/flake.nix @@ -14,8 +14,9 @@ ); }; patchedFlakeFor = system: import "${patchedPkgsFor system}/flake.nix"; - patchedFlakeOutputsFor = system: - (patchedFlakeFor system).outputs { self = self._forSystem system; }; + patchedFlakeOutputsFor = system: (patchedFlakeFor system).outputs { + self = self // self._forSystem system; + }; extractBuildPlatform = nixosSystemArgs: builtins.foldl'