clan-config: improve and add flake-parts module for clan-config
This commit is contained in:
40
flakeModules/clan-config.nix
Normal file
40
flakeModules/clan-config.nix
Normal file
@@ -0,0 +1,40 @@
|
||||
{ self, inputs, ... }:
|
||||
let
|
||||
|
||||
# take the default nixos configuration
|
||||
options = self.nixosConfigurations.default.options;
|
||||
|
||||
# this is actually system independent as it uses toFile
|
||||
docs = inputs.nixpkgs.legacyPackages.x86_64-linux.nixosOptionsDoc {
|
||||
inherit options;
|
||||
};
|
||||
|
||||
optionsJSONFile = docs.optionsJSON.options;
|
||||
|
||||
warnIfNoDefaultConfig = return:
|
||||
if ! self ? nixosConfigurations.default
|
||||
then
|
||||
builtins.trace
|
||||
"WARNING: .#nixosConfigurations.default could not be found. Please define it."
|
||||
return
|
||||
else return;
|
||||
|
||||
in
|
||||
{
|
||||
flake.clanOptions = warnIfNoDefaultConfig optionsJSONFile;
|
||||
|
||||
flake.clanSettings = self + /clan-settings.json;
|
||||
|
||||
perSystem = { pkgs, inputs', ... }: {
|
||||
devShells.clan-config = pkgs.mkShell {
|
||||
packages = [
|
||||
inputs'.clan-core.packages.clan-cli
|
||||
];
|
||||
shellHook = ''
|
||||
export CLAN_OPTIONS_FILE=$(nix eval --raw .#clanOptions)
|
||||
export XDG_DATA_DIRS="${inputs'.clan-core.packages.clan-cli}/share''${XDG_DATA_DIRS:+:$XDG_DATA_DIRS}"
|
||||
export fish_complete_path="${inputs'.clan-core.packages.clan-cli}/share/fish/vendor_completions.d''${fish_complete_path:+:$fish_complete_path}"
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user