mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-01-30 22:57:55 +00:00
lib: init flake subset
This commit is contained in:
parent
976d402f7b
commit
2426ff0adc
27
lib/flake.nix
Normal file
27
lib/flake.nix
Normal file
@ -0,0 +1,27 @@
|
||||
# No, this is not a flake of the library set, it is a library subset for
|
||||
# flake-related shtick. This should be used VERY RARELY in most parts of the
|
||||
# configuration because they are set up to be usable both in flakes- and
|
||||
# non-flakes-enabled environment.
|
||||
#
|
||||
# Take note it has a very strict design constraint of not relying on the
|
||||
# `inputs` attribute of the flake output. Instead, we're relying on the
|
||||
# builtins and the flake lockfile for this.
|
||||
#
|
||||
# Because Nix under the hood is a bit of a mess especially relating with
|
||||
# flakes, we'll have to thoroughly document which versions this is working. So
|
||||
# far, it is working on flake format version 7. AAAAAND also because apparently
|
||||
# it requires flakes to be enabled to use `builtins.fetchTree`, this is pretty
|
||||
# much a flakes-only subset.
|
||||
#
|
||||
# If anything else is pretty much in despair, we could always ste- I mean...
|
||||
# copy edolstra's flake-compat implementation.
|
||||
rec {
|
||||
importFlakeMetadata = flakeLockfile:
|
||||
builtins.fromJSON (builtins.readFile flakeLockfile);
|
||||
|
||||
fetchTree = metadata: inputName:
|
||||
builtins.fetchTree metadata.nodes.${inputName}.locked;
|
||||
|
||||
fetchInput = metadata: inputName:
|
||||
(fetchTree metadata inputName).outPath;
|
||||
}
|
Loading…
Reference in New Issue
Block a user