Skip to content

Commit

Permalink
flake.nix: Use builtins.derivation to produce error message
Browse files Browse the repository at this point in the history
This will fail a lot faster and won't start substituting files from a
remote before failing.
  • Loading branch information
adisbladis committed Sep 6, 2022
1 parent 642d81a commit b3b86d1
Showing 1 changed file with 31 additions and 20 deletions.
51 changes: 31 additions & 20 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,36 @@
{
packages = import ./default.nix { inherit pkgs; };

devShells.default = pkgs.mkShell {
packages = [
(
let
errorMessage = ''
Developing Trustix using Flakes is unsupported.
We are using the stable nix-shell interface together with direnv to recursively
load development shells for subpackages and relying on relative environment variables
for state directories and such, something which is not supported using Flakes.
For supported development methods see ./packages/trustix-doc/src/hacking.md.
'';
in
pkgs.runCommand "flakes-nein-danke" { } "echo '${errorMessage}' && exit 1"
)
];
};

})
# Fake shell derivation that evaluates but doesn't build and producec an error message
# explaining the supported setup.
devShells.default =
let
errorMessage = ''
Developing Trustix using Flakes is unsupported.
We are using the stable nix-shell interface together with direnv to recursively
load development shells for subpackages and relying on relative environment variables
for state directories and such, something which is not supported using Flakes.
For supported development methods see ./packages/trustix-doc/src/hacking.md.
'';
in
builtins.derivation {
name = "flakes-nein-danke-shell";
builder = "bash";
inherit system;
preferLocalBuild = true;
allowSubstitutes = false;
fail = builtins.derivation {
name = "flakes-nein-danke";
builder = "/bin/sh";
args = [ "-c" "echo '${errorMessage}' && exit 1" ];
preferLocalBuild = true;
allowSubstitutes = false;
inherit system;
};
};
}
)
);
}

0 comments on commit b3b86d1

Please sign in to comment.