fix systemsFromFile

- make use of config.projectRoot to ge relative path of systems file
This commit is contained in:
DavHau 2022-07-16 18:58:04 +02:00
parent 7cd64d386d
commit 932ccb13dc
4 changed files with 12 additions and 6 deletions

View File

@ -26,6 +26,5 @@ The intention is to integrate many existing 2nix converters into this framework,
- [Architectural Considerations](./intro/architectural-considerations.md)
- [Potential impact on nixpkgs](./intro/nixpkgs-improvements.md)
- [Development Roundups](./development-roundups.md)
[glossary]: https://nixos.wiki/wiki/Glossary "glossary"

View File

@ -70,6 +70,7 @@
source,
pkgs ? null,
systems ? [],
systemsFromFile ? null,
config ? {},
inject ? {},
pname ? throw "Please pass `pname` to makeFlakeOutputs",
@ -77,6 +78,11 @@
settings ? [],
sourceOverrides ? oldSources: {},
} @ args: let
systems =
if systemsFromFile == null
then args.systems or []
else dlib.systemsFromFile systemsFromFile;
allPkgs = makeNixpkgs pkgs systems;
config = loadConfig (args.config or {});
@ -179,7 +185,6 @@
flakeOutputs;
in rec {
inherit init makeFlakeOutputs makeFlakeOutputsForIndexes;
inherit (dlib) systemsFromFile;
dlib = import ./lib {
inherit lib;
config = (import ./utils/config.nix).loadConfig {};

View File

@ -298,12 +298,15 @@
systemsFromFile = file:
if ! l.pathExists file
then
then let
relPathFile =
l.removePrefix (l.toString config.projectRoot) (l.toString file);
in
throw ''
The system for your flake.nix is not initialized yet.
Please execute the following command to initialize it:
nix eval --impure --raw --expr 'builtins.currentSystem' > ./${l.baseNameOf file} && git add ./${l.baseNameOf file}
nix eval --impure --raw --expr 'builtins.currentSystem' > .${relPathFile} && git add .${relPathFile}
''
else l.filter (l: l != "") (l.splitString "\n" (l.readFile file));

View File

@ -2,8 +2,7 @@
inputs.dream2nix.url = "github:nix-community/dream2nix";
outputs = inp:
inp.dream2nix.lib.makeFlakeOutputs {
# modify according to your supported systems
systems = inp.dream2nix.lib.systemsFromFile ./nix_systems;
systemsFromFile = ./nix_systems;
config.projectRoot = ./.;
source = ./.;
};