flake: fix sourceInfo propagation (and hence, nixosConfiguration naming!)

This commit is contained in:
2024-02-27 10:34:20 +00:00
parent e90bbfe551
commit 03c5f82dbf
2 changed files with 25 additions and 14 deletions

View File

@@ -98,19 +98,29 @@
inherit variant nixpkgs; inherit variant nixpkgs;
self = patchNixpkgs variant nixpkgs; self = patchNixpkgs variant nixpkgs;
} // { } // {
# provide values that nixpkgs ordinarily sources from the flake.lock file, # sourceInfo includes fields (square brackets for the ones which are not always present):
# inaccessible to it here because of the import-from-derivation. # - [dirtyRev]
# rev and shortRev seem to not always exist (e.g. if the working tree is dirty), # - [dirtyShortRev]
# so those are made conditional. # - lastModified
# - lastModifiedDate
# - narHash
# - outPath
# - [rev]
# - [revCount]
# - [shortRev]
# - submodules
# #
# these values impact the name of a produced nixos system. having date/rev in the # these values are used within nixpkgs:
# `readlink /run/current-system` store path helps debuggability. # - to give a friendly name to the nixos system (`readlink /run/current-system` -> `...nixos-system-desko-24.05.20240227.dirty`)
inherit (self) lastModifiedDate lastModified; # - to alias `import <nixpkgs>` so that nix uses the system's nixpkgs when called externally (supposedly).
} // optionalAttrs (self ? rev) { #
inherit (self) rev; # these values seem to exist both within the `sourceInfo` attrset and at the top-level.
} // optionalAttrs (self ? shortRev) { # for a list of all implicit flake outputs (which is what these seem to be):
inherit (self) shortRev; # $ nix-repl
}; # > lf .
# > <tab>
inherit (self) sourceInfo;
} // self.sourceInfo;
nixpkgs' = patchNixpkgs "master" nixpkgs-unpatched; nixpkgs' = patchNixpkgs "master" nixpkgs-unpatched;
nixpkgsCompiledBy = system: nixpkgs'.legacyPackages."${system}"; nixpkgsCompiledBy = system: nixpkgs'.legacyPackages."${system}";

View File

@@ -14,8 +14,9 @@
); );
}; };
patchedFlakeFor = system: import "${patchedPkgsFor system}/flake.nix"; patchedFlakeFor = system: import "${patchedPkgsFor system}/flake.nix";
patchedFlakeOutputsFor = system: patchedFlakeOutputsFor = system: (patchedFlakeFor system).outputs {
(patchedFlakeFor system).outputs { self = self._forSystem system; }; self = self // self._forSystem system;
};
extractBuildPlatform = nixosSystemArgs: extractBuildPlatform = nixosSystemArgs:
builtins.foldl' builtins.foldl'