Skip to content

Commit

Permalink
Export available options
Browse files Browse the repository at this point in the history
  • Loading branch information
KubqoA committed Nov 1, 2024
1 parent 1b065ca commit ae3df4e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ Further the dotfiles include:

## Usage
The dotfiles contain configuration for:
- [harmonium](./hosts/harmonium) - Personal NixOS laptop setup
- [harmonium](./hosts/harmonium) - Personal NixOS laptop
- [organ](./hosts/organ) - ARM-based server
- [nyckelharpa](./hosts/nyckelharpa) - Work MacOS setup
- [nyckelharpa](./hosts/nyckelharpa) - Work Macbook
- home-manager configurations for both systems

Refer to the respective host directories for more information.
Expand Down
3 changes: 2 additions & 1 deletion hosts/nyckelharpa/homebrew.nix
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@
"orbstack"
"raycast"
"rubymine"
"spotify"
"seadrive"
"slack"
"spotify"
"syncthing"
"tailscale"
"whatsapp"
Expand Down
17 changes: 14 additions & 3 deletions lib/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ inputs @ {
self,
...
}: systems: let
inherit ((import nixpkgs {system = "x86_64-linux";}).lib) foldl mapAttrsToList recursiveUpdate;

mapSystem = system: {
homes ? {},
hosts ? {},
Expand Down Expand Up @@ -91,7 +93,16 @@ inputs @ {
${systemSpecifics.option} = mapHosts hosts;
homeConfigurations = mapHomes homes;
};

mappedSystems = foldl recursiveUpdate {} (mapAttrsToList mapSystem systems);

# Merge all options into one attribute set for use with nixd
options = let
getOptions = configs: foldl recursiveUpdate {} (mapAttrsToList (_: value: value.options) configs);
in {
nixos = getOptions mappedSystems.nixosConfigurations;
darwin = getOptions mappedSystems.darwinConfigurations;
home-manager = getOptions mappedSystems.homeConfigurations;
};
in
builtins.zipAttrsWith
(name: values: builtins.foldl' (a: b: a // b) {} values)
(builtins.map (system: mapSystem system systems.${system}) (builtins.attrNames systems))
mappedSystems // {inherit options;}
9 changes: 6 additions & 3 deletions modules/common/neovim/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,17 @@ require("lspconfig").nixd.setup({
settings = {
nixd = {
nixpkgs = {
expr = 'import (builtins.getFlake "/persist/dotfiles").inputs.nixpkgs { }',
expr = 'import (builtins.getFlake "/Users/jakub/.config/dotfiles").inputs.nixpkgs { }',
},
options = {
nixos = {
expr = '(builtins.getFlake "/persist/dotfiles").nixosConfigurations.harmonium.options',
expr = '(builtins.getFlake "/Users/jakub/.config/dotfiles").options.nixos',
},
darwin = {
expr = '(builtins.getFlake "/Users/jakub/.config/dotfiles").options.darwin',
},
home_manager = {
expr = '(builtins.getFlake "/persist/dotfiles").homeConfigurations.jakub.options',
expr = '(builtins.getFlake "/Users/jakub/.config/dotfiles").options.home-manager',
},
},
},
Expand Down

0 comments on commit ae3df4e

Please sign in to comment.